Class DefaultValueTrait

java.lang.Object
software.amazon.awssdk.core.traits.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 Details

    • 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.
    • create

      public static DefaultValueTrait create(Supplier<?> supplier)
      Creates a new DefaultValueTrait with a custom Supplier.
      Parameters:
      supplier - Supplier of default value for the field.
      Returns:
      New trait instance.
    • 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.