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

com.dooapp.gaedo.finders.collections.DefaultCollectionBackedFinderService Maven / Gradle / Ivy

There is a newer version: 1.0.16
Show newest version
package com.dooapp.gaedo.finders.collections;

import java.util.List;

import com.dooapp.gaedo.finders.FinderCrudService;
import com.dooapp.gaedo.finders.Informer;
import com.dooapp.gaedo.finders.id.AnnotationUtils;
import com.dooapp.gaedo.finders.id.AnnotationsFinder.Annotations;
import com.dooapp.gaedo.finders.root.InformerFactory;
import com.dooapp.gaedo.finders.root.ProxyBackedInformerFactory;
import com.dooapp.gaedo.properties.FieldBackedPropertyProvider;
import com.dooapp.gaedo.properties.Property;
import com.dooapp.gaedo.properties.PropertyProvider;

public class DefaultCollectionBackedFinderService> extends
		CollectionBackedFinderService implements
		FinderCrudService {

	/**
	 * Create a FinderCrudService for given type class and informer class. Notice that if type class reveals to have an id field, we will use a IdentifiableCollectionBackedFinderServcie
	 * @param  informed type
	 * @param  informer for the upper
	 * @param typeClass class of informed type
	 * @param informerTypeClass class of informer type
	 * @return an instance of {@link CollectionBackedFinderService}
	 * @deprecated replaced by {@link #create(Class, Class, ProxyBackedInformerFactory, PropertyProvider)}
	 */
	@Deprecated()
	public static > FinderCrudService create(
			Class typeClass, Class informerTypeClass, InformerFactory factory) {
		return create(typeClass, informerTypeClass, factory, new FieldBackedPropertyProvider());
	}

	/**
	 * Create a FinderCrudService for given type class and informer class. Notice that if type class reveals to have an id field, we will use a IdentifiableCollectionBackedFinderServcie
	 * @param  informed type
	 * @param  informer for the upper
	 * @param typeClass class of informed type
	 * @param informerTypeClass class of informer type
	 * @param provider property provider used to allow id detection
	 * @return an instance of {@link CollectionBackedFinderService}
	 */
	public static > FinderCrudService create(
			Class typeClass, Class informerTypeClass, InformerFactory factory, PropertyProvider provider) {
		List ids = AnnotationUtils.locateAllFields(provider, typeClass, Annotations.ID);
		if(ids.size()>0)
			return new IdSupportingCollectionBackedFinderService(typeClass, informerTypeClass, factory, ids);
		else
			return new DefaultCollectionBackedFinderService(typeClass, informerTypeClass, factory);
	}


	public DefaultCollectionBackedFinderService(Class containedClass,
			Class informerClass,
			InformerFactory factory) {
		super(containedClass, informerClass, factory);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy