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

com.dooapp.gaedo.blueprints.transformers.Literals Maven / Gradle / Ivy

There is a newer version: 1.0.16
Show newest version
package com.dooapp.gaedo.blueprints.transformers;

import java.lang.reflect.Type;
import java.net.URI;
import java.util.Date;

import com.dooapp.gaedo.blueprints.ObjectCache;
import com.dooapp.gaedo.properties.Property;
import com.tinkerpop.blueprints.Vertex;

/**
 * An helper class allowing easy literal transformer lookup
 * @author ndx
 *
 */
public enum Literals implements TransformerAssociation {
	uris(URI.class, new URILiteralTransformer()),
	strings(String.class, new StringLiteralTransformer()),
	numbers(Number.class, new NumberLiteralTransformer()),
	booleans(Boolean.class, new BooleanLiteralTransformer()),
	enums(Enum.class, new EnumLiteralTransformer()),
	dates(Date.class, new DateLiteralTransformer()),
	classes(Class.class, new ClassLiteralTransformer());

	/**
	 * Source dataclass
	 */
	private final Class dataClass;
	/**
	 * Associated transformer
	 */
	private LiteralTransformer transformer;

	Literals(Class dataClass, LiteralTransformer transformer) {
		this.dataClass = dataClass;
		this.transformer = transformer;
	}

	public static LiteralTransformer get(ClassLoader classLoader, String effectiveType) {
		return Transformers.get(Literals.values(), classLoader, effectiveType);
	}

	public static LiteralTransformer get(Class dataClass) {
		return Transformers.get(Literals.values(), dataClass);
	}

	public static LiteralTransformer get(Type genericType) {
		return Transformers.get(Literals.values(), genericType);
	}

	public static boolean containsKey(ClassLoader classLoader, String effectiveType) {
		return Transformers.containsKey(Literals.values(), classLoader, effectiveType);
	}

	public static boolean containsKey(Class valueClass) {
		return Transformers.containsKey(Literals.values(), valueClass);
	}

	@Override
	public Class getDataClass() {
		return dataClass;
	}

	@Override
	public LiteralTransformer getTransformer() {
		return transformer;
	}

	@Override
	public boolean canHandle(ClassLoader classLoader, String effectiveType) {
		return transformer.canHandle(classLoader, effectiveType);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy