Class CorsTrait

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

public final class CorsTrait extends AbstractTrait implements ToSmithyBuilder<CorsTrait>
  • Field Details

    • ID

      public static final ShapeId ID
  • Method Details

    • getOrigin

      @Deprecated public String getOrigin()
      Deprecated.
      Gets the single origin value of the cors trait.

      Defaults to "*" when not explicitly set. Use resolveOrigin(String) to resolve the effective origin when the origins map may be in use.

      Returns:
      the origin value.
      Throws:
      IllegalStateException - if the origins map is set.
    • getSpecifiedOrigin

      public Optional<String> getSpecifiedOrigin()
      Gets the explicitly set origin value, if any.
      Returns:
      the specified origin, or empty if not explicitly set.
    • getOrigins

      public Map<String,String> getOrigins()
      Gets the map of named origins.

      Each key is a user-defined name for the origin, and each value is the origin URL. Returns an empty map when not set.

      Returns:
      the named origins map.
    • resolveOrigin

      public String resolveOrigin(String originKey)
      Resolves the effective origin value using the given key.

      When originKey is null and the origins map is empty, the single origin value is returned. When the origins map is populated, the key is required and must match an entry in the map.

      Parameters:
      originKey - the key to look up in the origins map, or null to use the single origin value.
      Returns:
      the resolved origin URL.
      Throws:
      IllegalStateException - if the key is null when origins is populated.
      NoSuchElementException - if the key is not found in the origins map.
    • getMaxAge

      public int getMaxAge()
    • getAdditionalAllowedHeaders

      public Set<String> getAdditionalAllowedHeaders()
    • getAdditionalExposedHeaders

      public Set<String> getAdditionalExposedHeaders()
    • toBuilder

      public CorsTrait.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<CorsTrait>
      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.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class AbstractTrait
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class AbstractTrait
    • builder

      public static CorsTrait.Builder builder()