com.amazon.carbonado.filter
Class FilterValues<S extends Storable>

java.lang.Object
  extended by com.amazon.carbonado.filter.FilterValues<S>
All Implemented Interfaces:
Appender, Serializable

public class FilterValues<S extends Storable>
extends Object
implements Serializable, Appender

Assigns values to Filter placeholders. FilterValues instances are immutable.

Author:
Brian S O'Neill
See Also:
Serialized Form

Method Summary
 void appendTo(Appendable app)
          Append the string representation of this object to the given Appendable.
 boolean equals(Object obj)
           
 Object getAssignedValue(PropertyFilter<S> propFilter)
          Returns the value assigned to the given PropertyFilter, throwing an exception if not assigned.
 int getBlankParameterCount()
          Returns the amount of values yet to be assigned.
 Filter<S> getFilter()
          Returns the Filter that this FilterValues instance applies to.
 Object[] getSuppliedValues()
          Returns all supplied values in this object.
 Object[] getSuppliedValuesFor(Filter<S> filter)
          Returns all supplied values in this object, as required by the given Filter.
 Object getValue(PropertyFilter<S> propFilter)
          Returns the value assigned to the given PropertyFilter.
 Object[] getValues()
          Returns all values in this object, including those provided by filter constants.
 Object[] getValuesFor(Filter<S> filter)
          Returns all values in this object, as required by the given Filter.
 int hashCode()
           
 boolean isAssigned(PropertyFilter<S> propFilter)
          Returns true if a value is assigned to the given PropertyFilter.
 String toString()
          Returns the string value of the filter with any values substituted.
 FilterValues<S> with(boolean value)
          Returns a new FilterValues instance with the next blank parameter filled in.
 FilterValues<S> with(byte value)
          Returns a new FilterValues instance with the next blank parameter filled in.
 FilterValues<S> with(char value)
          Returns a new FilterValues instance with the next blank parameter filled in.
 FilterValues<S> with(double value)
          Returns a new FilterValues instance with the next blank parameter filled in.
 FilterValues<S> with(float value)
          Returns a new FilterValues instance with the next blank parameter filled in.
 FilterValues<S> with(int value)
          Returns a new FilterValues instance with the next blank parameter filled in.
 FilterValues<S> with(long value)
          Returns a new FilterValues instance with the next blank parameter filled in.
 FilterValues<S> with(Object value)
          Returns a new FilterValues instance with the next blank parameter filled in.
 FilterValues<S> with(short value)
          Returns a new FilterValues instance with the next blank parameter filled in.
 FilterValues<S> withValues(Object... values)
          Returns a new FilterValues instance with the next blank parameters filled in.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getFilter

public Filter<S> getFilter()
Returns the Filter that this FilterValues instance applies to.


with

public FilterValues<S> with(int value)
Returns a new FilterValues instance with the next blank parameter filled in.

Parameters:
value - parameter value to fill in
Throws:
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't match

with

public FilterValues<S> with(long value)
Returns a new FilterValues instance with the next blank parameter filled in.

Parameters:
value - parameter value to fill in
Throws:
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't match

with

public FilterValues<S> with(float value)
Returns a new FilterValues instance with the next blank parameter filled in.

Parameters:
value - parameter value to fill in
Throws:
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't match

with

public FilterValues<S> with(double value)
Returns a new FilterValues instance with the next blank parameter filled in.

Parameters:
value - parameter value to fill in
Throws:
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't match

with

public FilterValues<S> with(boolean value)
Returns a new FilterValues instance with the next blank parameter filled in.

Parameters:
value - parameter value to fill in
Throws:
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't match

with

public FilterValues<S> with(char value)
Returns a new FilterValues instance with the next blank parameter filled in.

Parameters:
value - parameter value to fill in
Throws:
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't match

with

public FilterValues<S> with(byte value)
Returns a new FilterValues instance with the next blank parameter filled in.

Parameters:
value - parameter value to fill in
Throws:
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't match

with

public FilterValues<S> with(short value)
Returns a new FilterValues instance with the next blank parameter filled in.

Parameters:
value - parameter value to fill in
Throws:
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't match

with

public FilterValues<S> with(Object value)
Returns a new FilterValues instance with the next blank parameter filled in.

Parameters:
value - parameter value to fill in
Throws:
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't match

withValues

public FilterValues<S> withValues(Object... values)
Returns a new FilterValues instance with the next blank parameters filled in.

Parameters:
values - parameter values to fill in; if null or empty, this FilterValues instance is returned
Throws:
IllegalStateException - if no blank parameters or if too many parameter values supplied
IllegalArgumentException - if type doesn't match

getBlankParameterCount

public int getBlankParameterCount()
Returns the amount of values yet to be assigned.


getValue

public Object getValue(PropertyFilter<S> propFilter)
Returns the value assigned to the given PropertyFilter. If null, value may be unassigned. Call getAssignedValue to have an exception thrown instead.


getAssignedValue

public Object getAssignedValue(PropertyFilter<S> propFilter)
                        throws IllegalStateException
Returns the value assigned to the given PropertyFilter, throwing an exception if not assigned. Call getValue to have null returned instead.

Throws:
IllegalStateException - if value is blank

isAssigned

public boolean isAssigned(PropertyFilter<S> propFilter)
Returns true if a value is assigned to the given PropertyFilter.


getValues

public Object[] getValues()
                   throws IllegalStateException
Returns all values in this object, including those provided by filter constants. An IllegalStateException will result if any values are blank.

Returns:
new object array
Throws:
IllegalStateException - if any values are blank

getSuppliedValues

public Object[] getSuppliedValues()
Returns all supplied values in this object. Constant filter values are not included.

Returns:
new object array

getValuesFor

public Object[] getValuesFor(Filter<S> filter)
                      throws IllegalStateException
Returns all values in this object, as required by the given Filter. The given Filter must be composed only of the same PropertyFilter instances as used to construct this object. An IllegalStateException will result otherwise.

Parameters:
filter - filter must be bound
Returns:
new object array
Throws:
IllegalStateException - if any values are blank

getSuppliedValuesFor

public Object[] getSuppliedValuesFor(Filter<S> filter)
                              throws IllegalStateException
Returns all supplied values in this object, as required by the given Filter. Constant filter values are not included. The given Filter must be composed only of the same PropertyFilter instances as used to construct this object. An IllegalStateException will result otherwise.

Parameters:
filter - filter must be bound
Returns:
new object array
Throws:
IllegalStateException

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Returns the string value of the filter with any values substituted.

Overrides:
toString in class Object

appendTo

public void appendTo(Appendable app)
              throws IOException
Description copied from interface: Appender
Append the string representation of this object to the given Appendable.

Specified by:
appendTo in interface Appender
Parameters:
app - Appendable object to receive string representation
Throws:
IOException - if thrown from given Appendable


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.