Class SmithyPattern.Segment
- java.lang.Object
-
- software.amazon.smithy.model.pattern.SmithyPattern.Segment
-
- Enclosing class:
- SmithyPattern
public static final class SmithyPattern.Segment extends java.lang.ObjectSegment within a SmithyPattern.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSmithyPattern.Segment.Type
-
Constructor Summary
Constructors Constructor Description Segment(java.lang.String content, SmithyPattern.Segment.Type segmentType)
-
Method Summary
Modifier and Type Method Description booleanequals(java.lang.Object other)java.lang.StringgetContent()Get the content of the segment.inthashCode()booleanisGreedyLabel()booleanisLabel()static SmithyPattern.Segmentparse(java.lang.String content, int offset)Parse a segment from the given offset.java.lang.StringtoString()Get the segment as a literal value to be used in a pattern.
-
-
-
Constructor Detail
-
Segment
public Segment(java.lang.String content, SmithyPattern.Segment.Type segmentType)
-
-
Method Detail
-
parse
public static SmithyPattern.Segment parse(java.lang.String content, int offset)
Parse a segment from the given offset.- Parameters:
content- Content of the segment.offset- Character offset where the segment starts.- Returns:
- Returns the created segment.
- Throws:
InvalidPatternException- if the segment is invalid.
-
getContent
public java.lang.String getContent()
Get the content of the segment.The return value contains the segment in its entirety for non-labels, and the label name for both labels and greedy labels. For example, given a segment of "{label+}", the return value of getContent would be "label".
- Returns:
- Content of the segment.
-
isLabel
public boolean isLabel()
- Returns:
- True if the segment is a label.
-
isGreedyLabel
public boolean isGreedyLabel()
- Returns:
- True if the segment is a greedy label.
-
toString
public java.lang.String toString()
Get the segment as a literal value to be used in a pattern.Unlike the result of
getContent(), the return value oftoStringincludes braces for labels and "+" for greedy labels.- Overrides:
toStringin classjava.lang.Object- Returns:
- The literal segment.
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-