Class DefaultValueTrait

  • All Implemented Interfaces:
    Trait

    public final class DefaultValueTrait
    extends Object
    implements Trait
    Trait that supplies a default value when none is present for a given field.
    • Method Detail

      • resolveValue

        public Object resolveValue​(Object val)
        If the value is null then the default value supplier is used to get a default value for the field. Otherwise 'val' is returned.
        Parameters:
        val - Value to resolve.
        Returns:
        Resolved value.
      • idempotencyToken

        public static DefaultValueTrait idempotencyToken()
        Creates a precanned DefaultValueTrait using the idempotency token generation which creates a new UUID if a field is null. This is used when the 'idempotencyToken' trait in the service model is present.
        Returns:
        New trait instance.