package +zoccolo+.jpa; import javax.persistence.metamodel.SingularAttribute; public class SearchParameterBuilder { public static SearchParameter getStringParam(String name, String value) { return new StringParameter(name, value); } /** * Per parametri anonimi. */ public static SearchParameter getStringParam(String value) { return getStringParam("", value); } public static SearchParameter getParam(SingularAttribute sa, final T value) { return new SingularParameter(sa, value); } /** * Il value non deve essere null. */ public static SearchParameter getParam(final String name, final T value) { return new SearchParameter() { @Override public String getName() { return name; } @Override public T getValue() { return value; } @SuppressWarnings("unchecked") @Override public Class getType() { return (Class) value.getClass(); } }; } /** * Per parametri anonimi. */ public static SearchParameter getParam(String value) { return getParam("", value); } public static SearchParameter getParam(final String name, final T value, final Class clazz) { return new SearchParameter() { @Override public String getName() { return name; } @Override public T getValue() { return value; } @Override public Class getType() { return clazz; } }; } }