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

org.isda.cdm.processor.CdmMappingProcessorUtils Maven / Gradle / Ivy

There is a newer version: 6.0.0-dev.89
Show newest version
package org.isda.cdm.processor;

import cdm.base.staticdata.asset.common.ISOCurrencyCodeEnum;
import com.regnosys.rosetta.common.translation.MappingProcessorUtils;
import com.rosetta.model.metafields.FieldWithMetaString;
import com.rosetta.model.metafields.MetaFields;
import org.jsoup.Jsoup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Optional;
import java.util.function.Consumer;

import static java.util.Optional.ofNullable;

public class CdmMappingProcessorUtils {

	private static final Logger LOGGER = LoggerFactory.getLogger(MappingProcessorUtils.class);

	public static FieldWithMetaString toFieldWithMetaString(String c) {
		return FieldWithMetaString.builder()
				.setValue(c)
				.build();
	}

	public static FieldWithMetaString toFieldWithMetaString(String c, String scheme) {
		return FieldWithMetaString.builder()
				.setValue(c)
				.setMeta(MetaFields.builder()
						.setScheme(scheme)
						.build())
				.build();
	}

	public static boolean setIsoCurrency(ISOCurrencyCodeEnum isoCurrencyCodeEnum, Consumer setter) {
		Optional isoCurrencyCode = ofNullable(isoCurrencyCodeEnum);
		isoCurrencyCode.ifPresent(c -> setter.accept(toFieldWithMetaString(c.name(), "http://www.fpml.org/ext/iso4217")));
		return isoCurrencyCode.isPresent();
	}

	public static String removeHtml(String value) {
		return Jsoup.parse(value).text();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy