public class PropertyWrapperDefinition extends Object
Provides access to the meta-data defined on a single java property of a class, and provides methods for reading and writing the value of the property on target objects. Instances of this class are not bound to specific target objects, nor are they bound to specific database definitions.
For binding to specific target objects and database definitions, use the
PropertyWrapper class.
DB properties can be seen to have the types and values in the table that
follows. This class provides a virtual view over the property whereby the
DBv-centric type and value are easily accessible via the
value()
and
setValue()
methods.
Note: instances of this class are expensive to create and should be cached.
This class is thread-safe.
This class is not serializable. References to it within serializable classes
should be marked as transient.
| Modifier and Type | Class and Description |
|---|---|
static class |
PropertyWrapperDefinition.ColumnAspects |
| Modifier and Type | Field and Description |
|---|---|
ArrayList<PropertyWrapperDefinition.ColumnAspects> |
allColumnAspects |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj)
Equality of this property wrapper definition, based on the java property it
wraps in a specific class.
|
List<PropertyWrapperDefinition.ColumnAspects> |
getColumnAspects(DBDefinition defn,
RowDefinition actualRow) |
DBExpression[] |
getColumnExpression()
Support DBvolution at Patreon |
Integer |
getColumnIndex()
Support DBvolution at Patreon |
String |
getColumnName()
Gets the annotated column name.
|
Class<?> |
getEnumCodeType()
Gets the type of the code supplied by enum values.
|
Class<? extends Enum<?>> |
getEnumType()
Gets the enum type, or null if not appropriate
Support DBvolution at Patreon |
QueryableDatatype<?> |
getQueryableDatatype(RowDefinition target)
Gets the DBvolution-centric value of the property.
|
Class<?> |
getRawJavaType()
Gets the declared type of the property in the end-user's target object,
prior to type conversion to the DBvolution-centric type.
|
RowDefinitionClassWrapper |
getRowDefinitionClassWrapper()
Gets the wrapper for the RowDefinition (DBRow or DBReport) subclass
containing this property.
|
int |
hashCode()
Generates a hash-code of this property wrapper definition, based entirely
on the java property it wraps.
|
boolean |
isColumn()
Indicates whether this property is a column.
|
boolean |
isForeignKey()
Indicates whether this property is a foreign key.
|
boolean |
isInstanceOf(Class<? extends QueryableDatatype<?>> refType)
Convenience method for testing the type.
|
boolean |
isInstanceOfLargeObject()
Convenience method for testing the type.
|
boolean |
isPrimaryKey()
Indicates whether this property is a primary key.
|
boolean |
isReadable()
Indicates whether the value of the property can be retrieved.
|
boolean |
isTypeAdapted()
Indicates whether the property's type is adapted by an explicit or implicit
type adaptor.
|
boolean |
isWritable()
Indicates whether the value of the property can be modified.
|
String |
javaName()
Gets the name of the java property, without the containing class name.
|
String |
qualifiedJavaName()
Gets the fully qualified name of the underlying java property, including
the fully qualified name of the containing class.
|
Object |
rawJavaValue(Object target)
Gets the value of the declared property in the end-user's target object,
prior to type conversion to the DBvolution-centric type.
|
Class<? extends DBRow> |
referencedClass()
Gets the class referenced by this property, if this property is a foreign
key.
|
String |
referencedColumnName()
Gets the column name in the foreign table referenced by this property.
|
PropertyWrapperDefinition |
referencedPropertyDefinitionIdentity()
Gets identity information for the referenced property in the referenced
table.
|
String |
referencedTableName()
Gets the table referenced by this property, if this property is a foreign
key.
|
void |
setQueryableDatatype(RowDefinition target,
QueryableDatatype<?> value)
Sets the DBvolution-centric value of the property.
|
void |
setRawJavaValue(Object target,
Object value)
Set the value of the declared property in the end-user's target object,
without type conversion to/from the DBvolution-centric type.
|
String |
shortQualifiedJavaName()
Gets the partially qualified name of the underlying java property, using
the short-name of the containing class.
|
String |
tableName()
Gets the annotated table name of the table this property belongs to.
|
String |
toString()
Gets a string representation of the wrapped property, suitable for
debugging and logging.
|
Class<QueryableDatatype<?>> |
type()
Gets the DBvolution-centric type of the property.
|
public ArrayList<PropertyWrapperDefinition.ColumnAspects> allColumnAspects
public String toString()
Support DBvolution at Patreon
public int hashCode()
Support DBvolution at Patreon
public boolean equals(Object obj)
public String javaName()
"uid"
Use getColumnName() to determine column name.
Support DBvolution at Patreon
public String shortQualifiedJavaName()
"Customer.uid"
Use getColumnName() to determine column name.
Support DBvolution at Patreon
public String qualifiedJavaName()
"nz.co.mycompany.myproject.Customer.uid"
Use getColumnName() to determine column name.
Support DBvolution at Patreon
public Class<QueryableDatatype<?>> type()
Use getRawJavaType() in the rare case that you need to know the
underlying java property type.
Support DBvolution at Patreon
public boolean isInstanceOf(Class<? extends QueryableDatatype<?>> refType)
refType.isAssignableFrom(this.type()).refType - refType
Support DBvolution at Patreon
public boolean isInstanceOfLargeObject()
this.type().isAssignableFrom(DBLargeObject.class).
Support DBvolution at Patreon
public String tableName()
getRowDefinitionClassWrapper().tableName().
Support DBvolution at Patreon
public String getColumnName()
DBColumn
annotation is present but does not explicitly specify the column name.
If the DBColumn annotation is missing, this method returns
null.
Support DBvolution at Patreon
public boolean isColumn()
Support DBvolution at Patreon
true if this property is a columnpublic boolean isPrimaryKey()
Support DBvolution at Patreon
true if this property is a primary keypublic boolean isForeignKey()
Support DBvolution at Patreon
true if this property is a foreign keypublic Class<? extends DBRow> referencedClass()
Support DBvolution at Patreon
public String referencedTableName()
Support DBvolution at Patreon
public String referencedColumnName()
DBForeignKey.column() attribute, or it is implicitly the single
primary key of the referenced table if the DBForeignKey.column()
attribute is unset.
Support DBvolution at Patreon
public PropertyWrapperDefinition referencedPropertyDefinitionIdentity()
DBForeignKey.column() attribute, or it is implicitly the single
primary key of the referenced table.
Note that the property definition returned provides identity of the property only. It provides access to the property's: java name, column name, type, and identity information about the table it belongs to (ie: table name). Attempts to get or set its value or get the type adaptor instance will result in an internal exception.
Support DBvolution at Patreon
public Class<? extends Enum<?>> getEnumType()
Support DBvolution at Patreon
DBEnumValuepublic Class<?> getEnumCodeType()
DBEnumValue implementation in the enum.
Support DBvolution at Patreon
public boolean isReadable()
Support DBvolution at Patreon
public boolean isWritable()
Support DBvolution at Patreon
public boolean isTypeAdapted()
Support DBvolution at Patreon
true if a type adaptor is being usedpublic QueryableDatatype<?> getQueryableDatatype(RowDefinition target)
Use isReadable() beforehand to check whether the property can be
read.
target - object instance containing this property
Support DBvolution at Patreon
IllegalStateException - if not readable (you should have called
isReadable() first)DBThrownByEndUserCodeException - if any user code throws an exceptionpublic void setQueryableDatatype(RowDefinition target, QueryableDatatype<?> value)
Use isWritable() beforehand to check whether the property can be
modified.
target - object instance containing this propertyvalue - value valueIllegalStateException - if not writable (you should have called
isWritable() first)DBThrownByEndUserCodeException - if any user code throws an exceptionpublic Object rawJavaValue(Object target)
In most cases you will not need to call this method, as type conversion is
done transparently via the getQueryableDatatype(nz.co.gregs.dbvolution.query.RowDefinition) and
setQueryableDatatype(nz.co.gregs.dbvolution.query.RowDefinition, nz.co.gregs.dbvolution.datatypes.QueryableDatatype)
methods.
Use isReadable() beforehand to check whether the property can be
read.
target - object instance containing this property
Support DBvolution at Patreon
IllegalStateException - if not readable (you should have called
isReadable() first)DBThrownByEndUserCodeException - if any user code throws an exceptionpublic void setRawJavaValue(Object target, Object value)
In most cases you will not need to call this method, as type conversion is
done transparently via the getQueryableDatatype(nz.co.gregs.dbvolution.query.RowDefinition) and
setQueryableDatatype(nz.co.gregs.dbvolution.query.RowDefinition, nz.co.gregs.dbvolution.datatypes.QueryableDatatype)
methods.
Use isWritable() beforehand to check whether the property can be
modified.
target - object instance containing this propertyvalue - new valueIllegalStateException - if not writable (you should have called
isWritable() first)DBThrownByEndUserCodeException - if any user code throws an exceptionpublic Class<?> getRawJavaType()
In most cases you will not need to call this method, as type conversion is
done transparently via the getQueryableDatatype(nz.co.gregs.dbvolution.query.RowDefinition) and
setQueryableDatatype(nz.co.gregs.dbvolution.query.RowDefinition, nz.co.gregs.dbvolution.datatypes.QueryableDatatype)
methods. Use the type() method to get the DBv-centric property
type, after type conversion.
Support DBvolution at Patreon
public RowDefinitionClassWrapper getRowDefinitionClassWrapper()
Support DBvolution at Patreon
public DBExpression[] getColumnExpression()
Support DBvolution at Patreon
public List<PropertyWrapperDefinition.ColumnAspects> getColumnAspects(DBDefinition defn, RowDefinition actualRow)
Copyright © 2018. All Rights Reserved.