/** * Set the named parameter's value for this filter. * * @param name The parameter's name. * @param value The value to be applied. * @return This FilterImpl instance (for method chaining). * @throws IllegalArgumentException Indicates that either the parameter was undefined or that the type * of the passed value did not match the configured type. */ public Filter setParameter(String name, Object value) throws IllegalArgumentException { // Make sure this is a defined parameter and check the incoming value type // TODO: what should be the actual exception type here? Type type = definition.getParameterType( name ); if ( type == null ) { throw new IllegalArgumentException( "Undefined filter parameter [" + name + "]" ); } if ( value != null && !type.getReturnedClass().isAssignableFrom( value.getClass() ) ) { throw new IllegalArgumentException( "Incorrect type for parameter [" + name + "]" ); } parameters.put( name, value ); return this; }
/** * Set the named parameter's value for this filter. * * @param name The parameter's name. * @param value The value to be applied. * @return This FilterImpl instance (for method chaining). * @throws IllegalArgumentException Indicates that either the parameter was undefined or that the type * of the passed value did not match the configured type. */ public Filter setParameter(String name, Object value) throws IllegalArgumentException { // Make sure this is a defined parameter and check the incoming value type // TODO: what should be the actual exception type here? Type type = definition.getParameterType( name ); if ( type == null ) { throw new IllegalArgumentException( "Undefined filter parameter [" + name + "]" ); } if ( value != null && !type.getReturnedClass().isAssignableFrom( value.getClass() ) ) { throw new IllegalArgumentException( "Incorrect type for parameter [" + name + "]" ); } parameters.put( name, value ); return this; }
public Type getFilterParameterType(String filterParameterName) { String[] parsed = parseFilterParameterName(filterParameterName); FilterDefinition filterDef = factory.getFilterDefinition( parsed[0] ); if (filterDef == null) { throw new IllegalArgumentException("Filter [" + parsed[0] + "] not defined"); } Type type = filterDef.getParameterType( parsed[1] ); if (type == null) { // this is an internal error of some sort... throw new InternalError("Unable to locate type for filter parameter"); } return type; }
/** * Set the named parameter's value list for this filter. Used * in conjunction with IN-style filter criteria. * * @param name The parameter's name. * @param values The values to be expanded into an SQL IN list. * @return This FilterImpl instance (for method chaining). */ public Filter setParameterList(String name, Collection values) throws IllegalArgumentException { // Make sure this is a defined parameter and check the incoming value type // TODO: what should be the actual exception types here? if ( values == null ) { throw new IllegalArgumentException( "Collection must be not null!" ); } Type type = definition.getParameterType( name ); if ( type == null ) { throw new IllegalArgumentException( "Undefined filter parameter [" + name + "]" ); } if ( values != null && values.size() > 0 ) { Class elementClass = values.iterator().next().getClass(); if ( !type.getReturnedClass().isAssignableFrom( elementClass ) ) { throw new IllegalArgumentException("Incorrect type for parameter [" + name + "]"); } } parameters.put( name, values ); return this; }
/** * Set the named parameter's value list for this filter. Used * in conjunction with IN-style filter criteria. * * @param name The parameter's name. * @param values The values to be expanded into an SQL IN list. * @return This FilterImpl instance (for method chaining). */ public Filter setParameterList(String name, Collection values) throws HibernateException { // Make sure this is a defined parameter and check the incoming value type if ( values == null ) { throw new IllegalArgumentException( "Collection must be not null!" ); } Type type = definition.getParameterType( name ); if ( type == null ) { throw new HibernateException( "Undefined filter parameter [" + name + "]" ); } if ( values.size() > 0 ) { Class elementClass = values.iterator().next().getClass(); if ( !type.getReturnedClass().isAssignableFrom( elementClass ) ) { throw new HibernateException( "Incorrect type for parameter [" + name + "]" ); } } parameters.put( name, values ); return this; }
public Type getFilterParameterType(String filterParameterName) { errorIfClosed(); checkTransactionSynchStatus(); String[] parsed = parseFilterParameterName(filterParameterName); FilterDefinition filterDef = factory.getFilterDefinition( parsed[0] ); if (filterDef == null) { throw new IllegalArgumentException("Filter [" + parsed[0] + "] not defined"); } Type type = filterDef.getParameterType( parsed[1] ); if (type == null) { // this is an internal error of some sort... throw new InternalError("Unable to locate type for filter parameter"); } return type; }