Package org.dellroad.stuff.vaadin7
Class StringValuePropertyDef
- java.lang.Object
-
- org.dellroad.stuff.vaadin7.PropertyDef<String>
-
- org.dellroad.stuff.vaadin7.StringValuePropertyDef
-
- All Implemented Interfaces:
Serializable,PropertyExtractor<Object>,SortingPropertyExtractor<Object>
public class StringValuePropertyDef extends PropertyDef<String> implements SortingPropertyExtractor<Object>
APropertyDefrepresenting theStringvalue of an object usingObject#toString().Instances also serve as a
SortingPropertyExtractorthat can actually extract the property from any object.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.dellroad.stuff.vaadin7.PropertyDef
SORT_BY_NAME
-
-
Constructor Summary
Constructors Constructor Description StringValuePropertyDef(String name)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanSort(PropertyDef<?> propertyDef)Determine if the given property can be sorted by this instance.<V> VgetPropertyValue(Object obj, PropertyDef<V> propertyDef)Read the value of the property defined bypropertyDeffrom the given object.intsort(PropertyDef<?> propertyDef, Object obj1, Object obj2)Sort two values based on the given property.-
Methods inherited from class org.dellroad.stuff.vaadin7.PropertyDef
addTo, addTo, addTo, cast, createProperty, createProperty, createProperty, equals, get, get, getDefaultValue, getName, getPropertyId, getType, hashCode, isSortable, read, sort, toString
-
-
-
-
Constructor Detail
-
StringValuePropertyDef
public StringValuePropertyDef(String name)
Constructor.- Parameters:
name- property name; also serves as the property ID
-
-
Method Detail
-
getPropertyValue
public <V> V getPropertyValue(Object obj, PropertyDef<V> propertyDef)
Description copied from interface:PropertyExtractorRead the value of the property defined bypropertyDeffrom the given object.- Specified by:
getPropertyValuein interfacePropertyExtractor<Object>- Type Parameters:
V- value type- Parameters:
obj- Java objectpropertyDef- definition of which property to read- Returns:
- property value
-
canSort
public boolean canSort(PropertyDef<?> propertyDef)
Description copied from interface:SortingPropertyExtractorDetermine if the given property can be sorted by this instance. If this method returns false, then the property's sorting resorts to the default behavior, i.e., depending on whether the property value implementsComparable.- Specified by:
canSortin interfaceSortingPropertyExtractor<Object>- Parameters:
propertyDef- definition of property- Returns:
- true if the property defined by
propertyDefcan be sorted by this instance
-
sort
public int sort(PropertyDef<?> propertyDef, Object obj1, Object obj2)
Description copied from interface:SortingPropertyExtractorSort two values based on the given property.- Specified by:
sortin interfaceSortingPropertyExtractor<Object>- Parameters:
propertyDef- definition of property to sort onobj1- first Java objectobj2- second Java object- Returns:
- result of comparing
obj1's property value toobj2's property value
-
-