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

com.regnosys.rosetta.translate.synonymmap.SynonymConditionFuncTest Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.regnosys.rosetta.translate.synonymmap;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

import com.regnosys.rosetta.common.translation.Path;
import com.regnosys.rosetta.rosetta.RosettaCallableWithArgs;
import com.regnosys.rosetta.rosetta.RosettaMapTestFunc;
import com.regnosys.rosetta.rosetta.RosettaModel;

public class SynonymConditionFuncTest implements SynonymTest {

	private final String funcClassName;
	private final List predicatePathEndsWith;
	
	public SynonymConditionFuncTest(RosettaMapTestFunc test) {
		RosettaCallableWithArgs func = test.getFunc();
		this.funcClassName = String.format("%s.functions.%s", 
				((RosettaModel) func.eContainer()).getName(),
				func.getName());
		this.predicatePathEndsWith = Optional.ofNullable(test.getPredicatePath())
				.map(p -> p.getPath())
				.map(p -> Arrays.asList(p.split("->")))
				.orElse(null);
	}
	
	/**
	 * For conditional paths capture.  Not required as this looks up the path in the mappings.
	 */
	@Override
	public List getPaths() {
		return Collections.emptyList();
	}

	public String getFuncClassName() {
		return funcClassName;
	}

	public List getPredicatePathEndsWith() {
		return predicatePathEndsWith;
	}

	@Override
	public int hashCode() {
		return Objects.hash(funcClassName, predicatePathEndsWith);
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SynonymConditionFuncTest other = (SynonymConditionFuncTest) obj;
		return Objects.equals(funcClassName, other.funcClassName)
				&& Objects.equals(predicatePathEndsWith, other.predicatePathEndsWith);
	}

	@Override
	public String toString() {
		return "SynonymConditionFuncTest [funcClassName=" + funcClassName + ", predicatePathEndsWith="
				+ predicatePathEndsWith + "]";
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy