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

com.regnosys.rosetta.translate.RootHandler Maven / Gradle / Ivy

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

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.regnosys.rosetta.common.translation.Path;
import com.rosetta.model.lib.RosettaModelObjectBuilder;

/**
 * A handler that expects the dataDocument attribute from the front of the sample xml files and returns the proper handler.
 */
public class RootHandler extends ROMParseHandler {

	public RootHandler(String rootRosettaElement, ROMParseHandler properHandler, List rootElements) {
		super(properHandler.getInjector(), properHandler.getMappingContext());
		setUnderlying(properHandler.getUnderlying());
		Builder, HandlerSupplier> builder = ImmutableMultimap., HandlerSupplier>builder();
		for (String s:rootElements) {
			builder.put(Collections.singletonList(s), (a, b)->properHandler);
		}
		handlers = builder.build();
		mappingProcessors = ImmutableMultimap.of();
		properHandler.setRosettaPath(Path.valueOf(rootRosettaElement));
		properHandler.addXmlPath(new Path());
	}

	
	protected List getAllowedRootElements() {
		return handlers.keySet().stream()
				.flatMap(List::stream)
				.collect(Collectors.toList());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy