Class SmithyPattern
- java.lang.Object
-
- software.amazon.smithy.model.pattern.SmithyPattern
-
- Direct Known Subclasses:
UriPattern
public class SmithyPattern extends java.lang.Object
Represents a contained pattern.A pattern is a series of segments, some of which may be labels.
Labels may appear in the pattern in the form of "{label}". Labels must not be repeated, must not contain other labels (e.g., "{fo{bar}oo}"), and the label name must match the regex "^[a-zA-Z0-9_]+$". No labels can appear after the query string.
Greedy labels, a specialized type of label, may be specified using "{label+}". Only a single greedy label may appear in a pattern, and it must be the last label in a pattern. Greedy labels may be disabled for a pattern as part of the builder construction.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SmithyPattern.Builder
Builder used to create a SmithyPattern.static class
SmithyPattern.Segment
Segment within a SmithyPattern.
-
Constructor Summary
Constructors Modifier Constructor Description protected
SmithyPattern(SmithyPattern.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SmithyPattern.Builder
builder()
boolean
equals(java.lang.Object other)
java.util.Map<SmithyPattern.Segment,SmithyPattern.Segment>
getConflictingLabelSegmentsMap(SmithyPattern otherPattern)
Gets a map of explicitly conflicting label segments between this pattern and another.java.util.Optional<SmithyPattern.Segment>
getGreedyLabel()
Gets the greedy label of the pattern, if present.java.util.Optional<SmithyPattern.Segment>
getLabel(java.lang.String name)
Get a label by case-insensitive name.java.util.List<SmithyPattern.Segment>
getLabels()
Get a list of all segments that are labels.java.util.List<SmithyPattern.Segment>
getSegments()
Gets all segments, in order.int
hashCode()
java.lang.String
toString()
-
-
-
Constructor Detail
-
SmithyPattern
protected SmithyPattern(SmithyPattern.Builder builder)
-
-
Method Detail
-
getSegments
public final java.util.List<SmithyPattern.Segment> getSegments()
Gets all segments, in order.- Returns:
- All segments, in order, in an unmodifiable list.
-
getLabels
public final java.util.List<SmithyPattern.Segment> getLabels()
Get a list of all segments that are labels.- Returns:
- Label segments in an unmodifiable list.
-
getLabel
public final java.util.Optional<SmithyPattern.Segment> getLabel(java.lang.String name)
Get a label by case-insensitive name.- Parameters:
name
- Name of the label to retrieve.- Returns:
- An optionally found label.
-
getGreedyLabel
public final java.util.Optional<SmithyPattern.Segment> getGreedyLabel()
Gets the greedy label of the pattern, if present.- Returns:
- Returns the optionally found segment that is a greedy label.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
getConflictingLabelSegmentsMap
public java.util.Map<SmithyPattern.Segment,SmithyPattern.Segment> getConflictingLabelSegmentsMap(SmithyPattern otherPattern)
Gets a map of explicitly conflicting label segments between this pattern and another.- Parameters:
otherPattern
- SmithyPattern to check against.- Returns:
- A map of Segments where each pair represents a conflict and where the key is a segment from this pattern. This map is ordered so segments that appear first in this pattern appear first when iterating the map.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
builder
public static SmithyPattern.Builder builder()
- Returns:
- Returns a builder used to create a SmithyPattern.
-
-