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

org.loom.appengine.converter.RootKeyConverterFactory Maven / Gradle / Ivy

The newest version!
package org.loom.appengine.converter;

import javax.inject.Singleton;

import org.loom.appengine.annotations.RootKey;
import org.loom.appengine.annotations.RootKey.RootKeyType;
import org.loom.binding.AnnotationContainer;
import org.loom.converter.AnnotationDrivenConverterFactory;
import org.simpleds.converter.Converter;

import com.google.appengine.api.datastore.Key;

/**
 * Create {@link Converter} for {@link Key} properties
 * @author Nacho
 *
 */
@Singleton
public class RootKeyConverterFactory implements AnnotationDrivenConverterFactory {

	public org.loom.converter.Converter getConverter(AnnotationContainer propertyWrapper, RootKey annotation) {
		if (propertyWrapper.getPropertyClass() != Key.class) {
			return null;
		}
		Class persistentClass = annotation.value();
		return annotation.type() == RootKeyType.NAME? new KeyNameConverter(persistentClass) : new KeyIdConverter(persistentClass);
	}
	
	public Class getAnnotationClass() {
		return RootKey.class;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy