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

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

public static sealed interface ValueAttributeDefinition.Builder<T,B extends ValueAttributeDefinition.Builder<T,B>> extends AttributeDefinition.Builder<T,B> permits ColumnDefinition.Builder<T,B>, TransientAttributeDefinition.Builder<T,B> (not exhaustive)
Builds a ValueAttributeDefinition instance
  • Method Details

    • 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
    • minimum

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

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

      B range(Number minimum, Number maximum)
      Only applicable to numerical attributes
      Parameters:
      minimum - the minimum allowed value for this attribute
      maximum - the maximum allowed value for this attribute
      Returns:
      this builder instance
      Throws:
      IllegalStateException - in case this is not a numerical attribute
    • 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
    • trim

      B trim(boolean trim)
      Specifies whether string values should be trimmed, this applies to String (varchar) based attributes.
      Parameters:
      trim - true if strings values should be trimmed
      Returns:
      this builder instance
      Throws:
      IllegalStateException - in case this is not a String attribute
      See Also:
    • items

      B items(List<Item<T>> items)
      Note that by default items are sorted by to their caption, not their value. Use AttributeDefinition.Builder.comparator(java.util.Comparator) to set a custom comparator.
      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
    • 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
    • build

      Description copied from interface: AttributeDefinition.Builder
      Builds a new attribute definition instance
      Specified by:
      build in interface AttributeDefinition.Builder<T,B extends ValueAttributeDefinition.Builder<T,B>>
      Returns:
      a new attribute definition instance based on this builder