public class PropertySelector extends Object
A class for retrieving properties from an entity hierarchy in a dynamic way. E.g. If you have an entity that is expected to have a property, which is itself an entity, which has a property that we want to retrieve. This class encapsulates the retrieval of such a sub-property by specifying a "path" to the property.
Constructor and Description |
---|
PropertySelector(Entity root,
Property property)
Creates a new property selector.
|
PropertySelector(Entity root,
Tag... tags)
Creates a new property selector
|
PropertySelector(PropertySelector parent,
Property property)
Creates a new property selector with the given parent selector.
|
PropertySelector(PropertySelector parent,
Tag... tags)
Creates a new property selector with the given parent selector.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(ActionListener<PropertyChangeEvent> l)
Adds a change listener on property.
|
PropertySelector |
child(int index,
Property prop) |
PropertySelector |
child(int index,
Tag... tags) |
PropertySelector |
child(Property prop)
|
PropertySelector |
child(Tag... tags)
Alias of
#createChildSelector(com.codename1.rad.models.Tag…) |
PropertySelector |
createChildSelector(int index,
Property property) |
PropertySelector |
createChildSelector(int index,
Tag... tags) |
PropertySelector |
createChildSelector(Property property)
Creates a child selector on this property selector.
|
PropertySelector |
createChildSelector(Tag... tags)
Creates a child selector for this property selector.
|
Image |
createImageToFile(EncodedImage placeholder)
|
Image |
createImageToFile(EncodedImage placeholder,
String file)
|
Image |
createImageToFile(EncodedImage placeholder,
String file,
URLImage.ImageAdapter adapter)
|
Image |
createImageToFile(EncodedImage placeholder,
URLImage.ImageAdapter adapter)
|
Image |
createImageToStorage(EncodedImage placeholder)
|
Image |
createImageToStorage(EncodedImage placeholder,
String storageFile)
|
Image |
createImageToStorage(EncodedImage placeholder,
String storageFile,
URLImage.ImageAdapter adapter)
|
Image |
createImageToStorage(EncodedImage placeholder,
URLImage.ImageAdapter adapter)
|
boolean |
exists()
Checks if the property of this selector exists.
|
<T> T |
get(ContentType<T> type,
T defaultValue)
Gets the property value as the given type.
|
<T> T |
getAs(Class<T> cls,
T defaultValue) |
Boolean |
getBoolean(boolean defaultVal)
Gets the selected property as boolean
|
Date |
getDate(Date defaultVal)
Gets the selected property value as Date.
|
Double |
getDouble(double defaultVal)
Gets the selected property value as double.
|
Entity |
getEntity(Entity defaultVal)
Gets the selected property value as Entity.
|
EntityList |
getEntityList(EntityList defaultVal)
Gets the selected property value as EntityList.
|
Float |
getFloat(float defaultVal)
Gets the selected property value as float.
|
Integer |
getInt(int defaultVal)
Gets the selected property value as int.
|
Entity |
getLeafEntity()
Resolves the entity of this property selector.
|
Property |
getLeafProperty()
Resolves the property of this property selector.
|
PropertySelector |
getParent()
Gets the parent property selector.
|
PropertySelector |
getRoot()
Gets the root property selector.
|
String |
getText(String defaultValue)
Gets the selected property value as text.
|
boolean |
isEmpty()
Checks if property is empty.
|
boolean |
isFalsey()
Checks if property is falsey.
|
static PropertySelector |
propertySelector(Entity root,
Property prop) |
static PropertySelector |
propertySelector(Entity root,
Tag... tags) |
void |
removePropertyChangeListener(ActionListener<PropertyChangeEvent> l)
Removes property change listener from property.
|
<T> boolean |
set(ContentType<T> type,
T value) |
boolean |
setBoolean(boolean val) |
boolean |
setDate(Date val) |
boolean |
setDouble(double val) |
boolean |
setEntity(Entity val) |
boolean |
setEntityList(EntityList val) |
boolean |
setFloat(float val) |
boolean |
setInt(int val) |
boolean |
setText(String value) |
public PropertySelector(Entity root, Tag... tags)
Creates a new property selector
root
- The root entity to select properties on.tags
- The tags to use for property selection.public PropertySelector(Entity root, Property property)
Creates a new property selector.
root
- The root entity to select properties on.property
- The property to get values from.public PropertySelector(PropertySelector parent, Tag... tags)
Creates a new property selector with the given parent selector.
parent
- The parent selectortags
- The tags to select from.public PropertySelector(PropertySelector parent, Property property)
Creates a new property selector with the given parent selector.
parent
- THe parent selectorproperty
- The property.public void addPropertyChangeListener(ActionListener<PropertyChangeEvent> l)
Adds a change listener on property.
l
- The listener to add.public void removePropertyChangeListener(ActionListener<PropertyChangeEvent> l)
Removes property change listener from property.
l
- public <T> boolean set(ContentType<T> type, T value)
public <T> T getAs(Class<T> cls, T defaultValue)
public <T> T get(ContentType<T> type, T defaultValue)
Gets the property value as the given type.
T
- The type to coerce the property value to.type
- The type to coerce the property value to.defaultValue
- The default value which will be returned if either the property is not found, or is null.public PropertySelector createChildSelector(Property property)
Creates a child selector on this property selector.
property
- The property to select on.public PropertySelector createChildSelector(Tag... tags)
Creates a child selector for this property selector.
tags
- The tags used to lookup the property in the child selector.public PropertySelector createChildSelector(int index, Property property)
public PropertySelector createChildSelector(int index, Tag... tags)
public PropertySelector child(Property prop)
prop
- public PropertySelector child(int index, Property prop)
public PropertySelector child(Tag... tags)
Alias of #createChildSelector(com.codename1.rad.models.Tag…)
tags
- public PropertySelector child(int index, Tag... tags)
public String getText(String defaultValue)
Gets the selected property value as text.
defaultValue
- The value to return if the property value was nullpublic boolean setText(String value)
public Boolean getBoolean(boolean defaultVal)
Gets the selected property as boolean
defaultVal
- The value to return if the property value was null.public boolean setBoolean(boolean val)
public Date getDate(Date defaultVal)
Gets the selected property value as Date.
defaultVal
- The value to return if the property value was nullpublic boolean setDate(Date val)
public Entity getEntity(Entity defaultVal)
Gets the selected property value as Entity.
defaultVal
- The value to return if the property value was nullpublic boolean setEntity(Entity val)
public EntityList getEntityList(EntityList defaultVal)
Gets the selected property value as EntityList.
defaultVal
- The value to return if the property value was nullpublic boolean setEntityList(EntityList val)
public Float getFloat(float defaultVal)
Gets the selected property value as float.
defaultVal
- The value to return if the property value was nullpublic boolean setFloat(float val)
public Double getDouble(double defaultVal)
Gets the selected property value as double.
defaultVal
- The value to return if the property value was nullpublic boolean setDouble(double val)
public Integer getInt(int defaultVal)
Gets the selected property value as int.
defaultVal
- The value to return if the property value was nullpublic boolean setInt(int val)
public boolean isEmpty()
Checks if property is empty.
public boolean isFalsey()
Checks if property is falsey.
public Image createImageToStorage(EncodedImage placeholder, URLImage.ImageAdapter adapter)
Wrapper for Entity.createImageToStorage(com.codename1.rad.models.Property, com.codename1.ui.EncodedImage)
placeholder
- adapter
- public Image createImageToStorage(EncodedImage placeholder)
placeholder
- public Image createImageToStorage(EncodedImage placeholder, String storageFile)
Wrapper for Entity.createImageToStorage(com.codename1.rad.models.Property, com.codename1.ui.EncodedImage)
placeholder
- storageFile
- public Image createImageToStorage(EncodedImage placeholder, String storageFile, URLImage.ImageAdapter adapter)
placeholder
- storageFile
- adapter
- public Image createImageToFile(EncodedImage placeholder, URLImage.ImageAdapter adapter)
Wrapper for Entity.createImageToFile(com.codename1.rad.models.Property, com.codename1.ui.EncodedImage)
placeholder
- adapter
- public Image createImageToFile(EncodedImage placeholder)
Wrapper for Entity.createImageToFile(com.codename1.rad.models.Property, com.codename1.ui.EncodedImage)
placeholder
- public Image createImageToFile(EncodedImage placeholder, String file)
Wrapper for Entity.createImageToFile(com.codename1.rad.models.Property, com.codename1.ui.EncodedImage)
placeholder
- file
- public Image createImageToFile(EncodedImage placeholder, String file, URLImage.ImageAdapter adapter)
Wrapper for Entity.createImageToFile(com.codename1.rad.models.Property, com.codename1.ui.EncodedImage)
placeholder
- file
- adapter
- public Property getLeafProperty()
Resolves the property of this property selector.
public Entity getLeafEntity()
Resolves the entity of this property selector.
public PropertySelector getParent()
Gets the parent property selector.
public PropertySelector getRoot()
Gets the root property selector. If this selector is the root selector, then this will just return itself. It it is a child selector, it will walk up its parent tree until it reaches the root.
public boolean exists()
Checks if the property of this selector exists.
public static PropertySelector propertySelector(Entity root, Property prop)
public static PropertySelector propertySelector(Entity root, Tag... tags)
Copyright © 2021. All Rights Reserved.