Class Pattern

  • Direct Known Subclasses:
    UriPattern

    public class Pattern
    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.

    • Method Detail

      • getSegments

        public java.util.List<Pattern.Segment> getSegments()
        Gets all segments, in order.
        Returns:
        All segments, in order, in an unmodifiable list.
      • getLabels

        public java.util.List<Pattern.Segment> getLabels()
        Get a list of all segments that are labels.
        Returns:
        Label segments in an unmodifiable list.
      • getLabel

        public java.util.Optional<Pattern.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 java.util.Optional<Pattern.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 class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • builder

        public static Pattern.Builder builder()
        Returns:
        Returns a builder used to create a Pattern.