Package com.storedobject.ui.util
Class SOFieldCreator<T>
java.lang.Object
com.storedobject.ui.util.SOFieldCreator<T>
- All Implemented Interfaces:
ObjectFieldCreator<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the field creator once the "field creation" process is over.create
(ObjectForm<T> form) Create an instance of this interface for a particular "form".com.vaadin.flow.component.HasValue
<?, ?> createField
(String fieldName, Class<?> fieldType, String label) Create a "field" for the name, type and label provided.void
customizeField
(String fieldName, com.vaadin.flow.component.HasValue<?, ?> field) Customize a field.getFieldGetMethod
(String fieldName) Get the "getXXX" method for a given field name.Get the "getXXX" methods of the object from which name of the "fields" can be determined.getFieldName
(Method getMethod) Get field name for a method (typically a getXXX or isXXX method).Get additional field names (in addition to the ones got fromObjectFieldCreator.getFieldGetMethods()
.int
getFieldOrder
(String fieldName) Determine the order in which field is displayed on the form.Determine the label to be used for a field.getValueGetter
(String fieldName) Get the function that can obtain the value for a field from the object.BiConsumer
<T, ?> getValueSetter
(String fieldName) Get the function that can be used to set the value of a field to the object.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.storedobject.vaadin.ObjectFieldCreator
getFieldSetMethod
-
Constructor Details
-
SOFieldCreator
public SOFieldCreator()
-
-
Method Details
-
create
Description copied from interface:ObjectFieldCreator
Create an instance of this interface for a particular "form".- Specified by:
create
in interfaceObjectFieldCreator<T>
- Parameters:
form
- Form- Returns:
- An instance of this interface. Default implementation returns the same instance.
-
create
-
getObjectClass
-
getFieldGetMethods
Description copied from interface:ObjectFieldCreator
Get the "getXXX" methods of the object from which name of the "fields" can be determined.- Specified by:
getFieldGetMethods
in interfaceObjectFieldCreator<T>
- Returns:
- The default implementation returns
null
. Ifnull
is returned, reflection will be used on the object's class to determine the "getXXX" methods. (For example, if getFirstName() method exists, a field name of "FirstName" is assumed).
-
getFieldGetMethod
Description copied from interface:ObjectFieldCreator
Get the "getXXX" method for a given field name.- Specified by:
getFieldGetMethod
in interfaceObjectFieldCreator<T>
- Parameters:
fieldName
- Name of the field- Returns:
- The default implementation returns
null
. Ifnull
is returned, reflection will be used on the object's class to determine the "getXXX" method. (For example, getFirstName() method for field named "FirsrName").
-
getAnchors
-
getFieldNames
Description copied from interface:ObjectFieldCreator
Get additional field names (in addition to the ones got fromObjectFieldCreator.getFieldGetMethods()
.- Specified by:
getFieldNames
in interfaceObjectFieldCreator<T>
- Returns:
- Default implementation returns
null
(means no extra fields are added).
-
getFieldName
Description copied from interface:ObjectFieldCreator
Get field name for a method (typically a getXXX or isXXX method).- Specified by:
getFieldName
in interfaceObjectFieldCreator<T>
- Parameters:
getMethod
- Method- Returns:
- Default implementation returns "XXX" for method
getXXX()
orisXXX()
.
-
getFieldOrder
Description copied from interface:ObjectFieldCreator
Determine the order in which field is displayed on the form. Fields with smaller "field orders" are displayed first.- Specified by:
getFieldOrder
in interfaceObjectFieldCreator<T>
- Parameters:
fieldName
- Field name- Returns:
- Default implentation returns
Integer.MAX_VALUE
.
-
close
public void close()Description copied from interface:ObjectFieldCreator
Close the field creator once the "field creation" process is over. The default implemntation does nothing.- Specified by:
close
in interfaceObjectFieldCreator<T>
-
getValueGetter
Description copied from interface:ObjectFieldCreator
Get the function that can obtain the value for a field from the object.- Specified by:
getValueGetter
in interfaceObjectFieldCreator<T>
- Parameters:
fieldName
- Field name- Returns:
- Default implementation returns
null
and in that case, it will try to get it from its "get" method if one exists. (If field name is "XXX", thengetXXX()
method is used to get the value).
-
getValueSetter
Description copied from interface:ObjectFieldCreator
Get the function that can be used to set the value of a field to the object. Ifnull
is returned from this method, set method (setXXX()
for field "XXX") of the object is used for setting the value and if no such method exists, the field will be set to "read only".- Specified by:
getValueSetter
in interfaceObjectFieldCreator<T>
- Parameters:
fieldName
- Field name- Returns:
- Default implementaton returns
null
.
-
getLabel
Description copied from interface:ObjectFieldCreator
Determine the label to be used for a field.- Specified by:
getLabel
in interfaceObjectFieldCreator<T>
- Parameters:
fieldName
- Field name- Returns:
- Default implementation returns the value obtained from
ApplicationEnvironment.createLabel(String)
.
-
customizeField
Description copied from interface:ObjectFieldCreator
Customize a field. This is invoked after the field is created. The default implementation does nothing.- Specified by:
customizeField
in interfaceObjectFieldCreator<T>
- Parameters:
fieldName
- Name of the fieldfield
- Field
-
createField
public com.vaadin.flow.component.HasValue<?,?> createField(String fieldName, Class<?> fieldType, String label) Description copied from interface:ObjectFieldCreator
Create a "field" for the name, type and label provided.- Specified by:
createField
in interfaceObjectFieldCreator<T>
- Parameters:
fieldName
- Name of the fieldfieldType
- Type of the fieldlabel
- Label of the field- Returns:
- Field created.
-
getMD
-