Interface AttributeDefinition.Builder<T,B extends AttributeDefinition.Builder<T,B>>

Type Parameters:
T - the value type
B - the builder type
All Known Subinterfaces:
ColumnDefinition.Builder<T,B>, DerivedAttributeDefinition.Builder<T,B>, ForeignKeyDefinition.Builder, TransientAttributeDefinition.Builder<T,B>
Enclosing interface:
AttributeDefinition<T>

public static interface AttributeDefinition.Builder<T,B extends AttributeDefinition.Builder<T,B>>
Builds a attribute definition instance
  • Method Summary

    Modifier and Type
    Method
    Description
     
    Builds a new attribute definition instance
    caption(String caption)
    Note that this method has a side-effect, when setting the caption to a null value this attribute is automatically hidden via hidden(boolean), when a non-null value is used it is automatically made visible (as in, not hidden).
    captionResourceKey(String captionResourceKey)
    Specifies the key to use when retrieving the caption for this attribute from the entity resource bundle, in case it differes from the attribute name (Attribute.name()), which is the default value.
    comparator(Comparator<T> comparator)
     
    dateTimePattern(String dateTimePattern)
    Sets the date/time format pattern used when presenting and inputtind values
    decimalRoundingMode(RoundingMode decimalRoundingMode)
    Sets the rounding mode to use when working with decimals
    Sets the default value supplier, use in case of dynamic default values.
    defaultValue(T defaultValue)
    Sets the default value for this attribute, overrides the underlying column default value, if any
    description(String description)
    Sets the description for this attribute, used for tooltips f.ex.
    format(Format format)
    Sets the Format to use when presenting attribute values
    hidden(boolean hidden)
    Specifies whether this attribute should be hidden in table views
    items(List<Item<T>> items)
     
    Sets the locale aware date/time format pattern used when presenting and inputting values
    maximumFractionDigits(int maximumFractionDigits)
    Sets the maximum fraction digits to show for this attribute, only applicable to attributes based on decimal types.
    maximumLength(int maximumLength)
    Sets the maximum length of this attribute value, this applies to String (varchar) based attributes
    maximumValue(Number maximumValue)
    Only applicable to numerical attributes
    minimumValue(Number minimumValue)
    Only applicable to numerical attributes
    mnemonic(char mnemonic)
    Sets the mnemonic to use when creating a label for this attribute
    nullable(boolean nullable)
    Specifies whether this attribute is nullable.
    numberFormatGrouping(boolean numberFormatGrouping)
    Specifies whether to use number grouping when presenting the value associated with this attribute.
    valueRange(Number minimumValue, Number maximumValue)
    Only applicable to numerical attributes
  • Method Details

    • attribute

      Attribute<T> attribute()
      Returns:
      the underying attribute
    • caption

      B caption(String caption)
      Note that this method has a side-effect, when setting the caption to a null value this attribute is automatically hidden via hidden(boolean), when a non-null value is used it is automatically made visible (as in, not hidden).
      Parameters:
      caption - the caption
      Returns:
      this builder instance
      See Also:
    • captionResourceKey

      B captionResourceKey(String captionResourceKey)
      Specifies the key to use when retrieving the caption for this attribute from the entity resource bundle, in case it differes from the attribute name (Attribute.name()), which is the default value. Note that this configures the attribute to not be hidden.
      Parameters:
      captionResourceKey - the caption resource bundle key
      Returns:
      this builder instance
      Throws:
      IllegalStateException - in case the caption has already been set
      IllegalStateException - in case no resource bundle is specified for the entity
      IllegalStateException - in case the caption resource is not found in the entity resource bundle
      See Also:
    • defaultValue

      B defaultValue(T defaultValue)
      Sets the default value for this attribute, overrides the underlying column default value, if any
      Parameters:
      defaultValue - the value to use as default
      Returns:
      this builder instance
    • defaultValue

      B defaultValue(AttributeDefinition.ValueSupplier<T> supplier)
      Sets the default value supplier, use in case of dynamic default values.
      Parameters:
      supplier - the default value supplier
      Returns:
      this builder instance
    • hidden

      B hidden(boolean hidden)
      Specifies whether this attribute should be hidden in table views
      Parameters:
      hidden - true if this attribute should be hidden
      Returns:
      this builder instance
    • minimumValue

      B minimumValue(Number minimumValue)
      Only applicable to numerical attributes
      Parameters:
      minimumValue - the minimum allowed value for this attribute
      Returns:
      this builder instance
      Throws:
      IllegalStateException - in case this is not a numerical attribute
    • maximumValue

      B maximumValue(Number maximumValue)
      Only applicable to numerical attributes
      Parameters:
      maximumValue - the maximum allowed value for this attribute
      Returns:
      this builder instance
      Throws:
      IllegalStateException - in case this is not a numerical attribute
    • valueRange

      B valueRange(Number minimumValue, Number maximumValue)
      Only applicable to numerical attributes
      Parameters:
      minimumValue - the minimum allowed value for this attribute
      maximumValue - the maximum allowed value for this attribute
      Returns:
      this builder instance
      Throws:
      IllegalStateException - in case this is not a numerical attribute
    • maximumFractionDigits

      B maximumFractionDigits(int maximumFractionDigits)
      Sets the maximum fraction digits to show for this attribute, only applicable to attributes based on decimal types. This setting is overridden during subsequent calls to format(Format). Note that values associated with this attribute are automatically rounded to maximumFractionDigits digits.
      Parameters:
      maximumFractionDigits - the maximum fraction digits
      Returns:
      this builder instance
      Throws:
      IllegalStateException - in case this is not a decimal attribute
      See Also:
    • decimalRoundingMode

      B decimalRoundingMode(RoundingMode decimalRoundingMode)
      Sets the rounding mode to use when working with decimals
      Parameters:
      decimalRoundingMode - the rounding mode
      Returns:
      this builder instance
      Throws:
      IllegalStateException - in case this is not a decimal attribute
      See Also:
    • numberFormatGrouping

      B numberFormatGrouping(boolean numberFormatGrouping)
      Specifies whether to use number grouping when presenting the value associated with this attribute. i.e. 1234567 shown as 1.234.567 or 1,234,567 depending on locale. By default, grouping is not used. Only applicable to numerical attributes. This setting is overridden during subsequent calls to format(Format)
      Parameters:
      numberFormatGrouping - if true then number grouping is used
      Returns:
      this builder instance
      Throws:
      IllegalStateException - in case this is not a numerical attribute
    • nullable

      B nullable(boolean nullable)
      Specifies whether this attribute is nullable. Note that this will not prevent the value from being set to null, only prevent successful validation of the entity.
      Parameters:
      nullable - specifies whether null is a valid value for this attribute
      Returns:
      this builder instance
    • maximumLength

      B maximumLength(int maximumLength)
      Sets the maximum length of this attribute value, this applies to String (varchar) based attributes
      Parameters:
      maximumLength - the maximum length
      Returns:
      this builder instance
      Throws:
      IllegalStateException - in case this is not a String attribute
    • mnemonic

      B mnemonic(char mnemonic)
      Sets the mnemonic to use when creating a label for this attribute
      Parameters:
      mnemonic - the mnemonic character
      Returns:
      this builder instance
    • description

      B description(String description)
      Sets the description for this attribute, used for tooltips f.ex.
      Parameters:
      description - a String describing this attribute
      Returns:
      this builder instance
    • comparator

      B comparator(Comparator<T> comparator)
      Parameters:
      comparator - the Comparator to use when comparing values for this attribute
      Returns:
      this builder instance
    • format

      B format(Format format)
      Sets the Format to use when presenting attribute values
      Parameters:
      format - the format to use
      Returns:
      this builder instance
      Throws:
      NullPointerException - in case format is null
      IllegalArgumentException - in case this is a numerical attribute and the given format is not a NumberFormat.
      IllegalStateException - if the underlying attribute is temporal, in which case dateTimePattern(String) or localeDateTimePattern(LocaleDateTimePattern) should be used.
    • dateTimePattern

      B dateTimePattern(String dateTimePattern)
      Sets the date/time format pattern used when presenting and inputtind values
      Parameters:
      dateTimePattern - the format pattern
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - in case the pattern is invalid
      IllegalStateException - in case this is not a temporal attribute
      IllegalStateException - in case localeDateTimePattern(LocaleDateTimePattern) has been set
    • localeDateTimePattern

      B localeDateTimePattern(LocaleDateTimePattern localeDateTimePattern)
      Sets the locale aware date/time format pattern used when presenting and inputting values
      Parameters:
      localeDateTimePattern - the format pattern
      Returns:
      this builder instance
      Throws:
      IllegalStateException - in case this is not a temporal attribute
      IllegalStateException - in case dateTimePattern(String) has been set
    • items

      B items(List<Item<T>> items)
      Parameters:
      items - the Items representing all the valid values for this attribute
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - in case the valid item list contains duplicate values
    • build

      Builds a new attribute definition instance
      Returns:
      a new attribute definition instance based on this builder