Class TraitContainer.VersionAwareTraitContainer

java.lang.Object
software.amazon.smithy.model.loader.TraitContainer.VersionAwareTraitContainer
All Implemented Interfaces:
TraitContainer
Enclosing interface:
TraitContainer

public static final class TraitContainer.VersionAwareTraitContainer extends Object implements TraitContainer
Performs version-specific validation on traits as they are added.

For example, this class will throw a ModelSyntaxException if the mixin trait is used in Smithy IDL 1.0.

  • Method Details

    • traits

      public Map<ShapeId,Map<ShapeId,Trait>> traits()
      Specified by:
      traits in interface TraitContainer
      Returns:
      Gets all traits in the value map.
    • getTraitsForShape

      public Map<ShapeId,Trait> getTraitsForShape(ShapeId shape)
      Description copied from interface: TraitContainer
      Gets the traits applied to a shape.
      Specified by:
      getTraitsForShape in interface TraitContainer
      Parameters:
      shape - Shape to get the traits of.
      Returns:
      Returns the traits of the shape.
    • clearTraitsForShape

      public void clearTraitsForShape(ShapeId shape)
      Description copied from interface: TraitContainer
      Clears the traits applied to a shape.

      This is useful in the event of errors that occur while attempting to create a shape so that validation events about traits applied to shapes that couldn't be created are not emitted.

      Specified by:
      clearTraitsForShape in interface TraitContainer
      Parameters:
      shape - Shape to clear the traits for.
    • getTraitsAppliedToPrelude

      public Map<ShapeId,Map<ShapeId,Trait>> getTraitsAppliedToPrelude()
      Description copied from interface: TraitContainer
      Gets all traits applied to the prelude.
      Specified by:
      getTraitsAppliedToPrelude in interface TraitContainer
      Returns:
      Returns the traits applied to prelude shapes.
    • onTrait

      public void onTrait(ShapeId target, Trait value)
      Description copied from interface: TraitContainer
      Add a trait.
      Specified by:
      onTrait in interface TraitContainer
      Parameters:
      target - Shape to add the trait to.
      value - Trait to add.
    • onTrait

      public void onTrait(ShapeId target, ShapeId traitId, Node value)
      Description copied from interface: TraitContainer
      Create and add a trait.
      Specified by:
      onTrait in interface TraitContainer
      Parameters:
      target - Shape to add the trait to.
      traitId - Trait shape ID to create.
      value - The value to assign to the trait.