예제 #1
0
 @SuppressWarnings("unchecked")
 public <T extends ItemSpecification> T getSpecification(Class<T> type) {
   for (ItemSpecification itemSpecification : getSpecifications()) {
     if (itemSpecification.getClass() == type) return (T) itemSpecification;
   }
   return null;
 }
예제 #2
0
  public void addSpecification(ItemSpecification itemSpecification) {
    int version = 0;

    for (ItemSpecification specification : itemSpecs) {
      if (specification.getClass().equals(itemSpecification.getClass())) {
        version++;
      }
    }

    itemSpecification.setVersion(version);
    itemSpecification.setItem(this);

    itemSpecs.add(itemSpecification);

    if (itemSpecification.getType() != null) {
      if (TextUtils.isEmpty(itemTypes)) itemTypes = ITEM_TYPES_SEP;
      itemTypes = itemTypes.concat(itemSpecification.getType().name() + ITEM_TYPES_SEP);
    }
  }
예제 #3
0
 public boolean hasSpecification(Class<? extends ItemSpecification> type) {
   for (ItemSpecification itemSpecification : getSpecifications()) {
     if (itemSpecification.getClass() == type) return true;
   }
   return false;
 }