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

cdm.base.staticdata.asset.common.util.InstrumentDeepPathUtil Maven / Gradle / Ivy

package cdm.base.staticdata.asset.common.util;

import cdm.base.staticdata.asset.common.AssetIdentifier;
import cdm.base.staticdata.asset.common.Instrument;
import cdm.base.staticdata.asset.common.ListedDerivative;
import cdm.base.staticdata.asset.common.Loan;
import cdm.base.staticdata.asset.common.Security;
import cdm.base.staticdata.asset.common.Taxonomy;
import cdm.base.staticdata.party.LegalEntity;
import com.rosetta.model.lib.mapper.MapperS;
import java.util.Collections;
import java.util.List;

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

public class InstrumentDeepPathUtil {
	public Boolean chooseIsExchangeListed(Instrument instrument) {
		final MapperS listedDerivative = MapperS.of(instrument).map("getListedDerivative", _instrument -> _instrument.getListedDerivative());
		if (exists(listedDerivative).getOrDefault(false)) {
			return listedDerivative.map("getIsExchangeListed", _listedDerivative -> _listedDerivative.getIsExchangeListed()).get();
		}
		final MapperS loan = MapperS.of(instrument).map("getLoan", _instrument -> _instrument.getLoan());
		if (exists(loan).getOrDefault(false)) {
			return loan.map("getIsExchangeListed", _loan -> _loan.getIsExchangeListed()).get();
		}
		final MapperS security = MapperS.of(instrument).map("getSecurity", _instrument -> _instrument.getSecurity());
		if (exists(security).getOrDefault(false)) {
			return security.map("getIsExchangeListed", _security -> _security.getIsExchangeListed()).get();
		}
		return null;
	}
	
	public List chooseIdentifier(Instrument instrument) {
		final MapperS listedDerivative = MapperS.of(instrument).map("getListedDerivative", _instrument -> _instrument.getListedDerivative());
		if (exists(listedDerivative).getOrDefault(false)) {
			return listedDerivative.mapC("getIdentifier", _listedDerivative -> _listedDerivative.getIdentifier()).getMulti();
		}
		final MapperS loan = MapperS.of(instrument).map("getLoan", _instrument -> _instrument.getLoan());
		if (exists(loan).getOrDefault(false)) {
			return loan.mapC("getIdentifier", _loan -> _loan.getIdentifier()).getMulti();
		}
		final MapperS security = MapperS.of(instrument).map("getSecurity", _instrument -> _instrument.getSecurity());
		if (exists(security).getOrDefault(false)) {
			return security.mapC("getIdentifier", _security -> _security.getIdentifier()).getMulti();
		}
		return Collections.emptyList();
	}
	
	public List chooseRelatedExchange(Instrument instrument) {
		final MapperS listedDerivative = MapperS.of(instrument).map("getListedDerivative", _instrument -> _instrument.getListedDerivative());
		if (exists(listedDerivative).getOrDefault(false)) {
			return listedDerivative.mapC("getRelatedExchange", _listedDerivative -> _listedDerivative.getRelatedExchange()).getMulti();
		}
		final MapperS loan = MapperS.of(instrument).map("getLoan", _instrument -> _instrument.getLoan());
		if (exists(loan).getOrDefault(false)) {
			return loan.mapC("getRelatedExchange", _loan -> _loan.getRelatedExchange()).getMulti();
		}
		final MapperS security = MapperS.of(instrument).map("getSecurity", _instrument -> _instrument.getSecurity());
		if (exists(security).getOrDefault(false)) {
			return security.mapC("getRelatedExchange", _security -> _security.getRelatedExchange()).getMulti();
		}
		return Collections.emptyList();
	}
	
	public LegalEntity chooseExchange(Instrument instrument) {
		final MapperS listedDerivative = MapperS.of(instrument).map("getListedDerivative", _instrument -> _instrument.getListedDerivative());
		if (exists(listedDerivative).getOrDefault(false)) {
			return listedDerivative.map("getExchange", _listedDerivative -> _listedDerivative.getExchange()).get();
		}
		final MapperS loan = MapperS.of(instrument).map("getLoan", _instrument -> _instrument.getLoan());
		if (exists(loan).getOrDefault(false)) {
			return loan.map("getExchange", _loan -> _loan.getExchange()).get();
		}
		final MapperS security = MapperS.of(instrument).map("getSecurity", _instrument -> _instrument.getSecurity());
		if (exists(security).getOrDefault(false)) {
			return security.map("getExchange", _security -> _security.getExchange()).get();
		}
		return null;
	}
	
	public List chooseTaxonomy(Instrument instrument) {
		final MapperS listedDerivative = MapperS.of(instrument).map("getListedDerivative", _instrument -> _instrument.getListedDerivative());
		if (exists(listedDerivative).getOrDefault(false)) {
			return listedDerivative.mapC("getTaxonomy", _listedDerivative -> _listedDerivative.getTaxonomy()).getMulti();
		}
		final MapperS loan = MapperS.of(instrument).map("getLoan", _instrument -> _instrument.getLoan());
		if (exists(loan).getOrDefault(false)) {
			return loan.mapC("getTaxonomy", _loan -> _loan.getTaxonomy()).getMulti();
		}
		final MapperS security = MapperS.of(instrument).map("getSecurity", _instrument -> _instrument.getSecurity());
		if (exists(security).getOrDefault(false)) {
			return security.mapC("getTaxonomy", _security -> _security.getTaxonomy()).getMulti();
		}
		return Collections.emptyList();
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy