Skip to content

Commit

Permalink
#325: Use correct generic extends in BaseService.
Browse files Browse the repository at this point in the history
  • Loading branch information
heshamMassoud committed Nov 24, 2018
1 parent 1c7d2c7 commit 0a6f5bb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
Expand Up @@ -17,17 +17,17 @@

/**
* @param <U> Resource (e.g. {@link io.sphere.sdk.products.Product}, {@link io.sphere.sdk.categories.Category}, etc..
* @param <V> Resource Draft (e.g. {@link io.sphere.sdk.products.ProductDraft},
* {@link io.sphere.sdk.categories.CategoryDraft}, etc..
* @param <S> Subclass of {@link BaseSyncOptions}
*/
class BaseService<U extends Resource<U>, V> {
final BaseSyncOptions<U, V> syncOptions;
class BaseService<U extends Resource<U>, S extends BaseSyncOptions> {

final S syncOptions;
boolean isCached = false;
final Map<String, String> keyToIdCache = new ConcurrentHashMap<>();

private static final int MAXIMUM_ALLOWED_UPDATE_ACTIONS = 500;

BaseService(@Nonnull final BaseSyncOptions<U, V> syncOptions) {
BaseService(@Nonnull final S syncOptions) {
this.syncOptions = syncOptions;
}

Expand Down
Expand Up @@ -34,7 +34,9 @@
* Implementation of CategoryService interface.
* TODO: USE graphQL to get only keys. GITHUB ISSUE#84
*/
public final class CategoryServiceImpl extends BaseService<Category, CategoryDraft> implements CategoryService {
public final class CategoryServiceImpl extends BaseService<Category, CategorySyncOptions>
implements CategoryService {

private static final String FETCH_FAILED = "Failed to fetch Categories with keys: '%s'. Reason: %s";
private static final String CATEGORY_KEY_NOT_SET = "Category with id: '%s' has no key set. Keys are required for "
+ "category matching.";
Expand Down
Expand Up @@ -30,7 +30,8 @@
import static org.apache.commons.lang3.StringUtils.isBlank;


public class ProductServiceImpl extends BaseService<Product, ProductDraft> implements ProductService {
public class ProductServiceImpl extends BaseService<Product, ProductSyncOptions> implements ProductService {

private static final String FETCH_FAILED = "Failed to fetch products with keys: '%s'. Reason: %s";

public ProductServiceImpl(@Nonnull final ProductSyncOptions syncOptions) {
Expand Down
Expand Up @@ -29,7 +29,8 @@
import static java.lang.String.format;
import static java.util.stream.Collectors.toSet;

public class ProductTypeServiceImpl extends BaseService<ProductType, ProductTypeDraft> implements ProductTypeService {
public class ProductTypeServiceImpl extends BaseService<ProductType, BaseSyncOptions> implements ProductTypeService {

private static final String FETCH_FAILED = "Failed to fetch product types with keys: '%s'. Reason: %s";
private final Map<String, Map<String, AttributeMetaData>> productsAttributesMetaData = new ConcurrentHashMap<>();

Expand Down

0 comments on commit 0a6f5bb

Please sign in to comment.