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

cdm.base.staticdata.asset.common.functions.DifferentOrdinalsCondition Maven / Gradle / Ivy

There is a newer version: 6.0.0-dev.89
Show newest version
package cdm.base.staticdata.asset.common.functions;

import cdm.base.staticdata.asset.common.Taxonomy;
import cdm.base.staticdata.asset.common.TaxonomyClassification;
import cdm.base.staticdata.asset.common.TaxonomyValue;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.expression.CardinalityOperator;
import com.rosetta.model.lib.functions.RosettaFunction;
import com.rosetta.model.lib.mapper.MapperS;

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

@ImplementedBy(DifferentOrdinalsCondition.DifferentOrdinalsConditionDefault.class)
public abstract class DifferentOrdinalsCondition implements RosettaFunction {

	/**
	* @param taxonomy 
	* @return result 
	*/
	public Boolean evaluate(Taxonomy taxonomy) {
		Boolean result = doEvaluate(taxonomy);
		
		return result;
	}

	protected abstract Boolean doEvaluate(Taxonomy taxonomy);

	public static class DifferentOrdinalsConditionDefault extends DifferentOrdinalsCondition {
		@Override
		protected Boolean doEvaluate(Taxonomy taxonomy) {
			Boolean result = null;
			return assignOutput(result, taxonomy);
		}
		
		protected Boolean assignOutput(Boolean result, Taxonomy taxonomy) {
			result = areEqual(MapperS.of(taxonomy).map("getValue", _taxonomy -> _taxonomy.getValue())
				.mapSingleToItem(item -> areEqual(item.mapC("getClassification", taxonomyValue -> taxonomyValue.getClassification()).map("getOrdinal", taxonomyClassification -> taxonomyClassification.getOrdinal()), distinct(item.mapC("getClassification", taxonomyValue -> taxonomyValue.getClassification()).map("getOrdinal", taxonomyClassification -> taxonomyClassification.getOrdinal())), CardinalityOperator.All).asMapper()), MapperS.of(true), CardinalityOperator.All).get();
			
			return result;
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy