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

com.github.TKnudsen.ComplexDataObject.data.DataSchemas Maven / Gradle / Ivy

Go to download

A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.

The newest version!
package com.github.TKnudsen.ComplexDataObject.data;

import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;

public class DataSchemas {

	/**
	 * enables the usage of DataSchema characteristics without the need for the
	 * dataSchema class.
	 * 
	 * @param dataSchema
	 * @return
	 */
	public static Map> getClassMap(DataSchema dataSchema) {
		Objects.requireNonNull(dataSchema);

		Map> map = new LinkedHashMap>();
		for (DataSchemaEntry entry : dataSchema.getAttributeEntries())
			map.put(entry.getName(), entry.getType());

		return map;
	}

	/**
	 * enables the usage of DataSchema / DataSchemaEntry characteristics without the
	 * need for the DataSchema / DataSchemaEntry classes.
	 * 
	 * @param dataSchema
	 * @return
	 */
	public static Map> getClassMap(Collection> schemaEntries) {
		Objects.requireNonNull(schemaEntries);

		Map> map = new LinkedHashMap>();
		for (DataSchemaEntry entry : schemaEntries)
			map.put(entry.getName(), entry.getType());

		return map;
	}

	public static DataSchema create(Map> attributeCharacterization) {
		DataSchema schema = new DataSchema();

		for (String attribute : attributeCharacterization.keySet())
			schema.add(attribute, attributeCharacterization.get(attribute));

		return schema;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy