org.mayocat.model.Association.isLoaded()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.mayocat.model.Association.isLoaded()方法的一些代码示例,展示了Association.isLoaded()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Association.isLoaded()方法的具体详情如下:
包路径:org.mayocat.model.Association
类名称:Association
方法名:isLoaded

Association.isLoaded介绍

暂无

代码示例

代码示例来源:origin: jvelo/mayocat-shop

public T or(T t)
{
  return this.isLoaded() ? reference : t;
}

代码示例来源:origin: jvelo/mayocat-shop

public T get()
{
  if (!isLoaded()) {
    throw new IllegalStateException("Cannot access a value not loaded");
  }
  return reference;
}

代码示例来源:origin: jvelo/mayocat-shop

private boolean hasLoadedAddons(Entity entity)
{
  return HasAddons.class.isAssignableFrom(entity.getClass()) && ((HasAddons) entity).getAddons().isLoaded();
}

代码示例来源:origin: jvelo/mayocat-shop

public BigDecimal getItemTotal(Taxable item)
{
  BigDecimal total = BigDecimal.ZERO;
  BigDecimal unitPrice = item.getUnitPrice();
  if (unitPrice == null && item.getParent().isPresent() && item.getParent().get().isLoaded()) {
    unitPrice = item.getParent().get().get().getUnitPrice();
  }
  if (items.containsKey(item) && unitPrice != null && items.get(item) > 0) {
    total = total.add(unitPrice.multiply(BigDecimal.valueOf(items.get(item))));
  }
  return total;
}

代码示例来源:origin: jvelo/mayocat-shop

public Optional<BigDecimal> getActualUnitPrice()
{
  if (this.price != null) {
    return Optional.of(price);
  } else if (this.getParent().isPresent() && this.getParent().get().isLoaded()) {
    Purchasable parent = this.getParent().get().get();
    if (!Product.class.isAssignableFrom(parent.getClass())) {
      throw new RuntimeException("Cannot handle a parent purchasable that is not a product");
    }
    Product parentProduct = (Product) parent;
    return Optional.fromNullable(parentProduct.getPrice());
  }
  return Optional.absent();
}

代码示例来源:origin: jvelo/mayocat-shop

public Optional<BigDecimal> getActualWeight()
{
  if (this.weight != null) {
    return Optional.of(weight);
  } else if (this.getParent().isPresent() && this.getParent().get().isLoaded()) {
    Purchasable parent = this.getParent().get().get();
    if (!Product.class.isAssignableFrom(parent.getClass())) {
      throw new RuntimeException("Cannot handle a parent purchasable that is not a product");
    }
    Product parentProduct = (Product) parent;
    return Optional.fromNullable(parentProduct.getWeight());
  }
  return Optional.absent();
}

代码示例来源:origin: jvelo/mayocat-shop

public boolean apply(@Nullable Product input)
  {
    return input.getCollections().isLoaded() && input.getCollections().get().contains(collection);
  }
}).toList();

代码示例来源:origin: jvelo/mayocat-shop

public boolean apply(@Nullable Product input)
  {
    return input.getCollections().isLoaded() && input.getCollections().get().isEmpty();
  }
}).toList();

代码示例来源:origin: jvelo/mayocat-shop

public boolean apply(@Nullable Product input)
  {
    return input.getCollections().isLoaded() && input.getCollections().get().contains(collection)
        && input.getOnShelf();
  }
}).toList();

代码示例来源:origin: jvelo/mayocat-shop

public void addItem(Taxable item, Long quantity)
{
  LOGGER.debug("Adding item {} ({}) to cart", item, quantity);
  Preconditions.checkNotNull(item);
  Preconditions.checkNotNull(quantity);
  Preconditions.checkNotNull(item.getId());
  Preconditions.checkNotNull(quantity);
  Preconditions.checkArgument(quantity > 0);
  BigDecimal unitPrice = null;
  if (item.getUnitPrice() != null) {
    unitPrice = item.getUnitPrice();
  } else if (item.getParent().isPresent() && item.getParent().get().isLoaded()) {
    unitPrice = item.getParent().get().get().getUnitPrice();
  }
  Preconditions.checkNotNull(unitPrice);
  Preconditions.checkArgument(unitPrice.compareTo(BigDecimal.ZERO) > 0);
  if (items.containsKey(item)) {
    Long newQuantity = items.get(item) + quantity;
    items.put(item, newQuantity);
  } else {
    items.put(item, quantity);
  }
  LOGGER.debug("Cart now contains {} items", this.items.size());
}

代码示例来源:origin: jvelo/mayocat-shop

public void setItem(Taxable item, Long quantity)
{
  Preconditions.checkNotNull(item);
  Preconditions.checkNotNull(quantity);
  Preconditions.checkNotNull(item.getId());
  Preconditions.checkNotNull(quantity);
  Preconditions.checkArgument(quantity > 0);
  BigDecimal unitPrice = null;
  if (item.getUnitPrice() != null || !item.getParent().isPresent()) {
    unitPrice = item.getUnitPrice();
  } else if (item.getParent().get().isLoaded()) {
    unitPrice = item.getParent().get().get().getUnitPrice();
  }
  Preconditions.checkNotNull(unitPrice, "Can't set cart item with no unit price");
  Preconditions.checkArgument(unitPrice.compareTo(BigDecimal.ZERO) > 0);
  items.put(item, quantity);
}

代码示例来源:origin: jvelo/mayocat-shop

if (!entity.getAddons().isLoaded()) {
  return Collections.emptyMap();

代码示例来源:origin: jvelo/mayocat-shop

Product product = (Product) p;
if (product.getAddons().isLoaded()) {
  Map<String, Object> itemAddons = Maps.newHashMap();
  Map<String, AddonGroup> addons = product.getAddons().get();

代码示例来源:origin: jvelo/mayocat-shop

@Override
public BigDecimal getVatRate(Taxable taxable)
{
  BigDecimal itemVatRate = null;
  TaxesSettings taxesSettings = getTaxesSettings();
  BigDecimal defaultVatRate = taxesSettings.getVat().getValue().getDefaultRate();
  final Optional<String> vatRateId = taxable.getVatRateId();
  if (vatRateId.isPresent()) {
    Optional<Rate> rate = getRateForId(vatRateId.get());
    if (rate.isPresent()) {
      itemVatRate = rate.get().getValue();
    }
  } else if (taxable.getParent().isPresent() && taxable.getParent().get().isLoaded()) {
    final Taxable parent = (Taxable) taxable.getParent().get().get();
    if (parent.getVatRateId().isPresent()) {
      Optional<Rate> rate = getRateForId(parent.getVatRateId().get());
      if (rate.isPresent()) {
        itemVatRate = rate.get().getValue();
      }
    }
  }
  if (itemVatRate == null) {
    itemVatRate = defaultVatRate;
  }
  return itemVatRate;
}

代码示例来源:origin: jvelo/mayocat-shop

if (tenant.getAddons().isLoaded()) {
  Map<String, Object> addons = addonsWebObjectBuilder.build(tenantData);
  site.put("addons", addons);

代码示例来源:origin: jvelo/mayocat-shop

public static void createOrUpdateAddons(AddonsDAO dao, HasAddons entity)
  {
    if (!entity.getAddons().isLoaded()) {
      return;
    }
    Map<String, AddonGroup> existing = asMap(dao.findAddons(entity));

    for (String group : entity.getAddons().get().keySet()) {
      AddonGroup addonGroup = entity.getAddons().get().get(group);
      if (existing.containsKey(group)) {
        dao.updateAddonGroup(entity, addonGroup);
      } else {
        dao.createAddonGroup(entity, addonGroup);
      }
    }
  }
}

代码示例来源:origin: jvelo/mayocat-shop

if (purchasable.getParent().isPresent() && purchasable.getParent().get().isLoaded()) {
  rootPurchasable = purchasable.getParent().get().get();
  title = rootPurchasable.getTitle() + " - " + purchasable.getTitle();

代码示例来源:origin: jvelo/mayocat-shop

public void update(Product product) throws EntityDoesNotExistException, InvalidEntityException
{
  this.dao.begin();
  Product originalProduct = this.findBySlug(product.getSlug(), product.getParentId());
  if (originalProduct == null) {
    this.dao.commit();
    throw new EntityDoesNotExistException();
  }
  if (!product.getAddons().isLoaded()) {
    product.setAddons(originalProduct.getAddons().get());
  }
  getObservationManager().notify(new EntityUpdatingEvent(), product);
  product.setId(originalProduct.getId());
  Integer updatedRows = this.dao.updateProduct(product);
  this.dao.createOrUpdateAddons(product);
  if (product.getLocalizedVersions() != null && !product.getLocalizedVersions().isEmpty()) {
    Map<Locale, Map<String, Object>> localizedVersions = product.getLocalizedVersions();
    for (Locale locale : localizedVersions.keySet()) {
      this.dao.createOrUpdateTranslation(product.getId(), locale, localizedVersions.get(locale));
    }
  }
  this.dao.commit();
  if (updatedRows <= 0) {
    throw new StoreException("No rows was updated when updating product");
  }
  getObservationManager().notify(new EntityUpdatedEvent(), product);
}

代码示例来源:origin: jvelo/mayocat-shop

public Feature createFeature(final Feature feature) throws InvalidEntityException, EntityAlreadyExistsException
{
  if (feature.getParentId() == null) {
    throw new InvalidEntityException("Cannot create a feature without a parent product specified");
  }
  Product product = this.findById(feature.getParentId());
  if (product == null) {
    throw new InvalidEntityException("Specified parent product does not exist");
  }
  boolean exists = findFeature(product, feature.getFeature(), feature.getFeatureSlug()) != null;
  if (exists) {
    throw new EntityAlreadyExistsException();
  }
  if (!feature.getAddons().isLoaded()) {
    feature.setAddons(new HashMap<String, AddonGroup>());
  }
  getObservationManager().notify(new EntityCreatingEvent(), feature);
  this.featureDao.begin();
  UUID entityId = UUID.randomUUID();
  feature.setId(entityId);
  this.featureDao.createChildEntity(feature, FEATURE_TABLE_NAME, getTenant());
  this.featureDao.createFeature(feature);
  this.featureDao.createOrUpdateAddons(feature);
  this.featureDao.commit();
  getObservationManager().notify(new EntityCreatedEvent(), feature);
  return feature;
}

代码示例来源:origin: jvelo/mayocat-shop

if (!product.getAddons().isLoaded()) {
  product.setAddons(new HashMap<String, AddonGroup>());

相关文章

微信公众号

最新文章

更多