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 TypeMethodDescriptionvoidclose()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.voidcustomizeField(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().intgetFieldOrder(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, waitMethods inherited from interface com.storedobject.vaadin.ObjectFieldCreator
getFieldSetMethod
-
Constructor Details
-
SOFieldCreator
public SOFieldCreator()
-
-
Method Details
-
create
Description copied from interface:ObjectFieldCreatorCreate an instance of this interface for a particular "form".- Specified by:
createin interfaceObjectFieldCreator<T>- Parameters:
form- Form- Returns:
- An instance of this interface. Default implementation returns the same instance.
-
create
-
getObjectClass
-
getFieldGetMethods
Description copied from interface:ObjectFieldCreatorGet the "getXXX" methods of the object from which name of the "fields" can be determined.- Specified by:
getFieldGetMethodsin interfaceObjectFieldCreator<T>- Returns:
- The default implementation returns
null. Ifnullis 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:ObjectFieldCreatorGet the "getXXX" method for a given field name.- Specified by:
getFieldGetMethodin interfaceObjectFieldCreator<T>- Parameters:
fieldName- Name of the field- Returns:
- The default implementation returns
null. Ifnullis 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:ObjectFieldCreatorGet additional field names (in addition to the ones got fromObjectFieldCreator.getFieldGetMethods().- Specified by:
getFieldNamesin interfaceObjectFieldCreator<T>- Returns:
- Default implementation returns
null(means no extra fields are added).
-
getFieldName
Description copied from interface:ObjectFieldCreatorGet field name for a method (typically a getXXX or isXXX method).- Specified by:
getFieldNamein interfaceObjectFieldCreator<T>- Parameters:
getMethod- Method- Returns:
- Default implementation returns "XXX" for method
getXXX()orisXXX().
-
getFieldOrder
Description copied from interface:ObjectFieldCreatorDetermine the order in which field is displayed on the form. Fields with smaller "field orders" are displayed first.- Specified by:
getFieldOrderin interfaceObjectFieldCreator<T>- Parameters:
fieldName- Field name- Returns:
- Default implentation returns
Integer.MAX_VALUE.
-
close
public void close()Description copied from interface:ObjectFieldCreatorClose the field creator once the "field creation" process is over. The default implemntation does nothing.- Specified by:
closein interfaceObjectFieldCreator<T>
-
getValueGetter
Description copied from interface:ObjectFieldCreatorGet the function that can obtain the value for a field from the object.- Specified by:
getValueGetterin interfaceObjectFieldCreator<T>- Parameters:
fieldName- Field name- Returns:
- Default implementation returns
nulland 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:ObjectFieldCreatorGet the function that can be used to set the value of a field to the object. Ifnullis 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:
getValueSetterin interfaceObjectFieldCreator<T>- Parameters:
fieldName- Field name- Returns:
- Default implementaton returns
null.
-
getLabel
Description copied from interface:ObjectFieldCreatorDetermine the label to be used for a field.- Specified by:
getLabelin interfaceObjectFieldCreator<T>- Parameters:
fieldName- Field name- Returns:
- Default implementation returns the value obtained from
ApplicationEnvironment.createLabel(String).
-
customizeField
Description copied from interface:ObjectFieldCreatorCustomize a field. This is invoked after the field is created. The default implementation does nothing.- Specified by:
customizeFieldin 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:ObjectFieldCreatorCreate a "field" for the name, type and label provided.- Specified by:
createFieldin interfaceObjectFieldCreator<T>- Parameters:
fieldName- Name of the fieldfieldType- Type of the fieldlabel- Label of the field- Returns:
- Field created.
-
getMD
-