Interface DerivedField<F extends DerivedField<F>>

All Superinterfaces:
Comparable<F>, Component<F>, Copyable<F>, Field<F>, FormComponent<F>, Serializable
All Known Implementing Classes:
DefaultDerivedField

public interface DerivedField<F extends DerivedField<F>> extends Field<F>
Represents the metadata for a FieldTypes.DERIVED field component. These fields derive their values from that of other fields. The values can also be transformed into a different case if it's a string. The default field type is FieldTypes.STRING.

By default, the values will only be derived if undefined—not if the field has a value including null. However, this can be changed be setting persist() to false. In this case, the derived value will not be persisted but only displayed. When this is the case, null is treated the same as undefined since Java does not distinguish between them.

The default transformation type for strings is "camel", which means the original value wil be transformed to came-case: camelCase. Use kebab(), snake(), etc. to do a different transformation, or use none() to perform no transformation.

Author:
Jon Fleschler (jfleschler)
See Also:
  • Method Details

    • source

      default F source(String source)
      The source field on the entity. Use $parent to reference a field on the parent entity.
    • fieldType

      default F fieldType(String type)
      Set the type of field to render such as STRING or INTEGER.
    • kebab

      default F kebab()
      Indicates that the source value will be transformed to kebab case: some-value.
    • camel

      default F camel()
      Indicates that the source value will be transformed to camel case: someValue.

      This is the default value.

    • snake

      default F snake()
      Indicates that the source value will be transformed to snake case: some_value.
    • pascal

      default F pascal()
      Indicates that the source value will be transformed to pascal case: SomeValue.
    • upper

      default F upper()
      Indicates that the source value will be transformed to upper case: SOME VALUE.
    • lower

      default F lower()
      Indicates that the source value will be transformed to lower case: some value.
    • capitalize

      default F capitalize()
      Indicates that the source value will be transformed so that only the first character is capitalized: Some value. This is not the same as capital/title case or sentence case—those are too complicated to support.
    • startCase

      default F startCase()
      Indicates that the source value will be transformed to start case: Some Value.
    • none

      default F none()
      Indicates that no transformation of the source will occur.
    • type

      default F type(String type)
      Set the transformation type. This only affects string fields.
      Specified by:
      type in interface Component<F extends DerivedField<F>>
      Parameters:
      type - the type
      Returns:
      this
    • persist

      default F persist()
      Whether the derived value should be persisted or merely displayed. This applies until the field is directly modified—once modified the value is always persisted regardless of this flag. Default is true.

      Since the backend is using Java, the value will be nulled if this is false. To make up for this, null values will be treated the same as undefined by the frontend when this is false.

    • persist

      default F persist(boolean persist)
      See Also:
    • removePersist

      default F removePersist()
    • removeType

      default F removeType()
    • removeFieldType

      default F removeFieldType()
    • removeSource

      default F removeSource()