Interface Trait

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      static <S extends Shape,​T extends Trait>
      java.util.stream.Stream<Pair<S,​T>>
      flatMapStream​(S shape, java.lang.Class<T> traitClass)
      Deprecated.
      static java.lang.String getIdiomaticTraitName​(java.lang.String traitName)
      Gets the idiomatic name of a prelude trait by stripping off the smithy.api# prefix.
      static java.lang.String getIdiomaticTraitName​(ToShapeId id)
      Gets the idiomatic name of a prelude trait by stripping off the smithy.api# prefix.
      default boolean isSynthetic()
      Checks if this trait is persisted with the shape, or if it is a synthetic, or transient trait, only meant to temporarily aid in some kind of in-memory model transformation.
      static java.lang.String makeAbsoluteName​(java.lang.String traitName)
      Makes the given trait name absolute if it is relative.
      static java.lang.String makeAbsoluteName​(java.lang.String traitName, java.lang.String defaultNamespace)
      Makes the given trait name absolute if it is relative.
      ShapeId toShapeId()
      Gets the shape ID of the trait.
      • Methods inherited from interface software.amazon.smithy.model.node.ToNode

        toNode
    • Method Detail

      • toShapeId

        ShapeId toShapeId()
        Gets the shape ID of the trait.
        Specified by:
        toShapeId in interface ToShapeId
        Returns:
        Returns the fully-qualified shape ID of the trait.
      • isSynthetic

        default boolean isSynthetic()
        Checks if this trait is persisted with the shape, or if it is a synthetic, or transient trait, only meant to temporarily aid in some kind of in-memory model transformation.

        Because synthetic traits are not persisted with shapes, they also do not need to be defined in Smithy's semantic model before they can be used in the model.

        Returns:
        Returns true if the trait is not persisted on the shape.
      • flatMapStream

        @Deprecated
        static <S extends Shape,​T extends Trait> java.util.stream.Stream<Pair<S,​T>> flatMapStream​(S shape,
                                                                                                              java.lang.Class<T> traitClass)
        Deprecated.
        Used in a stream flatMapStream to return a Stream with a Pair of Shape and Trait if the trait is present on the given shape.

        This method is deprecated because it generally results in harder to read code using unnamed tuples. Use Shape.hasTrait(Class) and Shape.expectTrait(Class) instead.

        Type Parameters:
        S - Shape
        T - Trait
        Parameters:
        shape - Shape to query for the trait.
        traitClass - Trait to retrieve.
        Returns:
        Returns the Stream of the found trait or an empty stream.
      • getIdiomaticTraitName

        static java.lang.String getIdiomaticTraitName​(java.lang.String traitName)
        Gets the idiomatic name of a prelude trait by stripping off the smithy.api# prefix. This is used in various error messages.
        Parameters:
        traitName - Trait name to make idiomatic.
        Returns:
        Returns the idiomatic trait name.
      • getIdiomaticTraitName

        static java.lang.String getIdiomaticTraitName​(ToShapeId id)
        Gets the idiomatic name of a prelude trait by stripping off the smithy.api# prefix. This is used in various error messages.
        Parameters:
        id - Trait name to make idiomatic.
        Returns:
        Returns the idiomatic trait name.
      • makeAbsoluteName

        static java.lang.String makeAbsoluteName​(java.lang.String traitName)
        Makes the given trait name absolute if it is relative.

        The namespace used to resolve with the trait name is the prelude namespace, smithy.api.

        Parameters:
        traitName - Trait name to make absolute.
        Returns:
        Returns the absolute trait name.
      • makeAbsoluteName

        static java.lang.String makeAbsoluteName​(java.lang.String traitName,
                                                 java.lang.String defaultNamespace)
        Makes the given trait name absolute if it is relative.
        Parameters:
        traitName - Trait name to make absolute.
        defaultNamespace - Namespace to use if the name is relative.
        Returns:
        Returns the absolute trait name.