All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cdm.product.template.util.ProductDeepPathUtil Maven / Gradle / Ivy

There is a newer version: 6.0.0-dev.89
Show newest version
package cdm.product.template.util;

import cdm.product.template.EconomicTerms;
import cdm.product.template.NonTransferableProduct;
import cdm.product.template.Product;
import cdm.product.template.TransferableProduct;
import com.rosetta.model.lib.mapper.MapperS;

import static com.rosetta.model.lib.expression.ExpressionOperators.*;

public class ProductDeepPathUtil {
	public EconomicTerms chooseEconomicTerms(Product product) {
		final MapperS transferableProduct = MapperS.of(product).map("getTransferableProduct", _product -> _product.getTransferableProduct());
		if (exists(transferableProduct).getOrDefault(false)) {
			return transferableProduct.map("getEconomicTerms", _transferableProduct -> _transferableProduct.getEconomicTerms()).get();
		}
		final MapperS nonTransferableProduct = MapperS.of(product).map("getNonTransferableProduct", _product -> _product.getNonTransferableProduct());
		if (exists(nonTransferableProduct).getOrDefault(false)) {
			return nonTransferableProduct.map("getEconomicTerms", _nonTransferableProduct -> _nonTransferableProduct.getEconomicTerms()).get();
		}
		return null;
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy