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

com.avaje.ebeaninternal.server.deploy.BeanCollectionHelpFactory Maven / Gradle / Ivy

package com.avaje.ebeaninternal.server.deploy;

import com.avaje.ebeaninternal.api.SpiQuery;
import com.avaje.ebeaninternal.server.core.OrmQueryRequest;


/**
 * Creates Helpers specific to the type of the property (List Set or Map).
 */
public class BeanCollectionHelpFactory {

	/**
	 * Create the helper based on the many property.
	 */
	public static  BeanCollectionHelp create(BeanPropertyAssocMany manyProperty) {

		ManyType manyType = manyProperty.getManyType();
		switch (manyType.getUnderlying()) {
		case LIST:
			return new BeanListHelp(manyProperty);
		case SET:
			return new BeanSetHelp(manyProperty);
		case MAP:
			return new BeanMapHelp(manyProperty);
		default:
			throw new RuntimeException("Invalid type "+manyType);
		}
		
	}
		
	public static  BeanCollectionHelp create(OrmQueryRequest request) {

		SpiQuery.Type manyType = request.getQuery().getType();
		
		if (manyType.equals(SpiQuery.Type.LIST)){
			return new BeanListHelp();
		
		} else if (manyType.equals(SpiQuery.Type.SET)) {
			return new BeanSetHelp();
		
		} else {
			BeanDescriptor target = request.getBeanDescriptor();
			String mapKey = request.getQuery().getMapKey();
			return new BeanMapHelp(target, mapKey);
		}
	}

	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy