本文整理了Java中org.mayocat.model.Association.get()
方法的一些代码示例,展示了Association.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Association.get()
方法的具体详情如下:
包路径:org.mayocat.model.Association
类名称:Association
方法名:get
暂无
代码示例来源:origin: jvelo/mayocat-shop
@Override
public boolean equals(Object obj)
{
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Association<T> other = (Association<T>) obj;
return Objects.equal(this.get(), other.get());
}
代码示例来源: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 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 boolean apply(@Nullable Product input)
{
return input.getCollections().isLoaded() && input.getCollections().get().contains(collection);
}
}).toList();
代码示例来源: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().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 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
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 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
source.put("addons", extractAddons(addons.get()));
代码示例来源:origin: jvelo/mayocat-shop
return Collections.emptyMap();
Map<String, AddonGroup> addons = entity.getAddons().get();
代码示例来源:origin: jvelo/mayocat-shop
Map<String, AddonGroup> addons = product.getAddons().get();
for (String groupName : addons.keySet()) {
AddonGroup addonGroup = addons.get(groupName);
代码示例来源:origin: jvelo/mayocat-shop
Map<String, AddonGroup> entityAddons = ((HasAddons) copiedEntity).getAddons().get();
final Map<String, Object> localizedAddons =
(Map<String, Object>) copiedEntity.getLocalizedVersions().get(locale).get("addons");
代码示例来源: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
rootPurchasable = purchasable.getParent().get().get();
title = rootPurchasable.getTitle() + " - " + purchasable.getTitle();
} else {
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!