Class MetadataTrait

java.lang.Object
software.amazon.smithy.model.traits.AbstractTrait
software.amazon.smithy.model.traits.MetadataTrait
All Implemented Interfaces:
FromSourceLocation, ToNode, ToShapeId, Trait, ToSmithyBuilder<MetadataTrait>

public final class MetadataTrait extends AbstractTrait implements ToSmithyBuilder<MetadataTrait>
Globally declares the type of a metadata key.

When this trait is applied to a shape, any metadata entry in the model with the same key is validated against the targeted shape. A given metadata key may only have its type declared once across the entire model.

  • Field Details

    • ID

      public static final ShapeId ID
  • Method Details

    • builder

      public static MetadataTrait.Builder builder()
      Returns:
      Creates a builder for a MetadataTrait.
    • getKey

      public String getKey()
      Returns:
      The metadata key that this trait defines a type for.
    • toBuilder

      public MetadataTrait.Builder toBuilder()
      Description copied from interface: ToSmithyBuilder
      Take this object and create a builder that contains all of the current property values of this object.
      Specified by:
      toBuilder in interface ToSmithyBuilder<MetadataTrait>
      Returns:
      a builder for type T
    • createNode

      protected Node createNode()
      Description copied from class: AbstractTrait
      The result of toNode is used for hashCodes and equality. Subclasses must implement createNode to turn the trait into a Node. This is then cached for subsequent retrievals.
      Specified by:
      createNode in class AbstractTrait
      Returns:
      Returns the trait as a node.