Package org.apache.empire.data.bean
Class BeanRecordProxy<T>
java.lang.Object
org.apache.empire.data.bean.BeanRecordProxy<T>
- Type Parameters:
T- the type of the class proxied by thisBeanRecordProxy
- All Implemented Interfaces:
Record,RecordData
BeanRecordProxy
This class defines proxy that allows any POJO to behave like a record object.
- Author:
- Rainer
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBeanRecordProxy(List<Column> columns, Column[] keyColumns, Entity entity) BeanRecordProxy(BeanClass beanClass) BeanRecordProxy(T data, BeanClass beanClass) -
Method Summary
Modifier and TypeMethodDescriptionvoidclears the modification status of the object and all fields.protected StringformatValue(ColumnExpr column, Object value) Convert a non-string value to a stringfinal Objectget(ColumnExpr column) returns the record value for a particular column<V> Vget(ColumnExpr column, Class<V> valueType) returns the record value for a particular columngetBean()protected ObjectgetBeanProperty(Object bean, String property) protected final ObjectgetBeanProperty(Object bean, ColumnExpr column) getColumn(int index) Overridden to change return type from ColumnExpr to ColumnReturns the entity this Record belongs tointreturns the number of field availableintgetFieldIndex(String columnName) returns the index of the column expression with the given nameintgetFieldIndex(ColumnExpr column) returns the index of the given column expression Indexed operations provide better performance for bulk processinggetFieldOptions(Column column) returns the Options list for the given record field.Object[]getKey()Returns the array of primary key columns.Column[]returns an array of key columns which uniquely identify the record.final StringgetText(ColumnExpr column) Returns the value of a column as a formatted text This converts the value to a string if necessary and performs an options lookup To customize conversion please override convertToString()final ObjectgetValue(int index) Returns the raw field value based on the field index.final <V> Vreturns the record value for a particular columnbooleanisFieldReadOnly(Column column) returns true if the field is read-only.booleanisFieldRequired(Column column) returns true if the field is required.booleanisFieldVisible(Column column) returns true if the field is visible to the client.booleanreturns true if the record has been modified.booleanisNew()returns true if this record is a new record.booleanisNull(int index) checks if the field at the given index position contains no value (null) Indexed operations provide better performance for bulk processing compared to isNull(ColumnExpr)booleanisNull(ColumnExpr column) checks if the record contains no value (null) for the given columnbooleanreturns true if this record is readOnly.booleanisValid()returns true if the record is valid.sets the value of a field.voidintsetBeanProperties(Object bean) intsetBeanProperties(Object bean, Collection<? extends ColumnExpr> ignoreList) copies all field values into a static Java Bean.protected voidsetBeanProperty(Object bean, Column column, Object value) intsetRecordValues(Object bean) sets all record values from a particular bean.intsetRecordValues(Object bean, Collection<Column> ignoreList) sets all record values from a particular bean.final voidsets the value of a field.validateValue(Column column, Object value) Validates a value before it is set in the record.booleanwasModified(Column column) Detects whether or not a particular field has been modified.
-
Field Details
-
log
protected static final org.slf4j.Logger log -
entity
-
columns
-
keyColumns
-
data
-
modified
protected boolean[] modified
-
-
Constructor Details
-
BeanRecordProxy
-
BeanRecordProxy
-
BeanRecordProxy
-
BeanRecordProxy
-
-
Method Details
-
getBean
-
setBean
-
getColumn
Description copied from interface:RecordOverridden to change return type from ColumnExpr to Column- Specified by:
getColumnin interfaceRecord- Specified by:
getColumnin interfaceRecordData- Parameters:
index- field index of the column expression- Returns:
- the column expression object or null if the index is out of range
-
getKeyColumns
Description copied from interface:Recordreturns an array of key columns which uniquely identify the record.- Specified by:
getKeyColumnsin interfaceRecord- Returns:
- the array of key columns if any
-
getKey
Returns the array of primary key columns. -
getFieldCount
public int getFieldCount()Description copied from interface:RecordDatareturns the number of field available- Specified by:
getFieldCountin interfaceRecordData- Returns:
- field count
-
getFieldIndex
Description copied from interface:RecordDatareturns the index of the given column expression Indexed operations provide better performance for bulk processing- Specified by:
getFieldIndexin interfaceRecordData- Parameters:
column- the column for which to return the index- Returns:
- the field index of the given column
-
getFieldIndex
Description copied from interface:RecordDatareturns the index of the column expression with the given name- Specified by:
getFieldIndexin interfaceRecordData- Parameters:
columnName- the name of the column for which to return the index- Returns:
- the field index of the given column
-
getFieldOptions
Description copied from interface:Recordreturns the Options list for the given record field.- Specified by:
getFieldOptionsin interfaceRecord- Parameters:
column- the column to check for visibility- Returns:
- an options collection containing all allowed field values
-
isFieldVisible
Description copied from interface:Recordreturns true if the field is visible to the client.- Specified by:
isFieldVisiblein interfaceRecord- Parameters:
column- the column to check for visibility- Returns:
- true if the field is visible to the client
-
isFieldReadOnly
Description copied from interface:Recordreturns true if the field is read-only.- Specified by:
isFieldReadOnlyin interfaceRecord- Parameters:
column- the requested column- Returns:
- true if the field is read-only
-
isFieldRequired
Description copied from interface:Recordreturns true if the field is required.- Specified by:
isFieldRequiredin interfaceRecord- Parameters:
column- the requested column- Returns:
- true if the field is required
-
isModified
public boolean isModified()Description copied from interface:Recordreturns true if the record has been modified.- Specified by:
isModifiedin interfaceRecord- Returns:
- true if the record has been modified or false otherwise
-
isNew
public boolean isNew()Description copied from interface:Recordreturns true if this record is a new record. -
getEntity
Description copied from interface:RecordReturns the entity this Record belongs to -
isValid
public boolean isValid()Description copied from interface:Recordreturns true if the record is valid. -
isReadOnly
public boolean isReadOnly()Description copied from interface:Recordreturns true if this record is readOnly.- Specified by:
isReadOnlyin interfaceRecord- Returns:
- true if this record is readOnly
-
getValue
Description copied from interface:RecordDataReturns the raw field value based on the field index. Indexed operations provide better performance for bulk processing compared to get(ColumnExpr)- Specified by:
getValuein interfaceRecordData- Parameters:
index- the field index- Returns:
- the raw field value
-
getValue
Description copied from interface:RecordDatareturns the record value for a particular column- Specified by:
getValuein interfaceRecordData- Type Parameters:
V- the desired return type for the value- Parameters:
index- the field index for which to return the valuevalueType- the desired value type- Returns:
- the record value for the given column
-
get
Description copied from interface:RecordDatareturns the record value for a particular column- Specified by:
getin interfaceRecordData- Parameters:
column- the column for which to return the valuevalueType- the desired value type- Returns:
- the record value for the given column
-
get
Description copied from interface:RecordDatareturns the record value for a particular column- Specified by:
getin interfaceRecordData- Parameters:
column- the column for which to return the value- Returns:
- the record value for the given column
-
isNull
Description copied from interface:RecordDatachecks if the record contains no value (null) for the given column- Specified by:
isNullin interfaceRecordData- Parameters:
column- the column- Returns:
- true if the value for the column is null or false otherwise
-
isNull
public boolean isNull(int index) Description copied from interface:RecordDatachecks if the field at the given index position contains no value (null) Indexed operations provide better performance for bulk processing compared to isNull(ColumnExpr)- Specified by:
isNullin interfaceRecordData- Parameters:
index- the field index- Returns:
- true if the field value is null or false otherwise
-
validateValue
Validates a value before it is set in the record.- Specified by:
validateValuein interfaceRecord- Parameters:
column- the columnvalue- the value to validate- Returns:
- the value
-
set
sets the value of a field. -
setValue
sets the value of a field. -
wasModified
Detects whether or not a particular field has been modified.- Specified by:
wasModifiedin interfaceRecord- Parameters:
column- the requested column- Returns:
- Returns true if a column has been modified
-
clearModified
public void clearModified()clears the modification status of the object and all fields. -
getText
Returns the value of a column as a formatted text This converts the value to a string if necessary and performs an options lookup To customize conversion please override convertToString()- Parameters:
column- the column for which to get the formatted value- Returns:
- the formatted value
-
setBeanProperties
-
setBeanProperties
Description copied from interface:RecordDatacopies all field values into a static Java Bean. In order to map column names to property names the property name is detected by ColumnExpr.getBeanPropertyName()- Specified by:
setBeanPropertiesin interfaceRecordData- Parameters:
bean- the Java Bean for which to set the propertiesignoreList- list of columns to skip (optional)- Returns:
- number of fields that have been copied
-
setRecordValues
Description copied from interface:Recordsets all record values from a particular bean.The bean must provide corresponding getter functions for all desired column.
In order to map column names to property names the property name is detected by ColumnExpr.getBeanPropertyName()
- Specified by:
setRecordValuesin interfaceRecord- Parameters:
bean- the Java Bean from which to read the value fromignoreList- list of column to ignore- Returns:
- the number of fields that have been set
-
setRecordValues
Description copied from interface:Recordsets all record values from a particular bean.The bean must provide corresponding getter functions for all desired column.
- Specified by:
setRecordValuesin interfaceRecord- Parameters:
bean- the Java Bean from which to read the value from- Returns:
- the number of fields that have been set
-
getBeanProperty
-
getBeanProperty
-
setBeanProperty
-
formatValue
Convert a non-string value to a string- Parameters:
column- the column expressionvalue- the value to format- Returns:
- the formatted string
-