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

org.loom.appengine.guice.LoomSimpledsModule Maven / Gradle / Ivy

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

import java.util.List;

import org.loom.annotation.processor.AnnotationProcessor;
import org.loom.converter.AnnotationDrivenConverterFactory;
import org.loom.guice.Plugins;
import org.loom.simpleds.RetrieveEntityAnnotationProcessor;
import org.loom.simpleds.SimpledsKeyConverterFactory;
import org.loom.simpleds.annotations.processor.PropertyAnnotationProcessor;
import org.loom.simpleds.json.CursorListJacksonMixin;
import org.loom.simpleds.json.PagedListJacksonMixin;
import org.simpleds.CursorList;
import org.simpleds.PagedList;

import com.google.appengine.repackaged.com.google.common.collect.Lists;
import com.google.inject.AbstractModule;

public class LoomSimpledsModule extends AbstractModule {

	/** true to use {@link CursorList} */
	private boolean cursorList;
	
	/** true to use {@link PagedList} */
	private boolean pagedList;
	
	/** true to use RetrieveEntity */
	private boolean retrieveEntity;
	
	@Override
	protected void configure() {
		List jacksonMixins = Lists.newArrayList();
		List> annotationProcessors = Lists.newArrayList();
		List> converterFactories = Lists.newArrayList();

		annotationProcessors.add(PropertyAnnotationProcessor.class);
		converterFactories.add(SimpledsKeyConverterFactory.class);
		if (cursorList) {
			jacksonMixins.add(CursorListJacksonMixin.class);
		}
		if (pagedList) {
			jacksonMixins.add(PagedListJacksonMixin.class);
		}
		if (retrieveEntity) {
			annotationProcessors.add(RetrieveEntityAnnotationProcessor.class);
		}
		Plugins.bindJacksonMixins(binder(), jacksonMixins);
		Plugins.bindAnnotationProcessors(binder(), annotationProcessors);
		Plugins.bindConverterFactories(binder(), converterFactories);
	}

	public LoomSimpledsModule withCursorLists() {
		this.cursorList = true;
		return this;
	}
	
	public LoomSimpledsModule withPagedLists() {
		this.pagedList = true;
		return this;
	}
	
	public LoomSimpledsModule withRetrieveEntity() {
		this.retrieveEntity = true;
		return this;
	}
	
	
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy