java.lang.Object
com.github.cafapi.common.util.naming.Name
All Implemented Interfaces:
Iterable<String>

public class Name extends Object implements Iterable<String>
A class that is similar to java.naming.Name, but is iterable. A Name is a tokenized character String, delimited by forward-slashes.
  • Constructor Details

    • Name

      public Name(String name)
      Create a new Name. Leading and trailing forward-slashes are allowed.
      Parameters:
      name - the String to create the name from
    • Name

      public Name(List<String> components)
      Createa a new Name from a list of tokens.
      Parameters:
      components - the parts that will make up the Name, already tokenized into a List
  • Method Details

    • size

      public int size()
      Returns:
      the number of tokenized components of this Name
    • getIndex

      public String getIndex(int index)
      Get the components of the Name at the specified numeric index
      Parameters:
      index - the index of the token to return, starting from 0
      Returns:
      the requested Name component
      Throws:
      IllegalArgumentException - if you request an index that does not exist
    • getPrefix

      public Name getPrefix(int upperIndex)
      Return a Name that consists of a subsection of the current Name.
      Parameters:
      upperIndex - the upper index (exclusive) of components to build the Name from
      Returns:
      a new Name, that is a sub-set of the current Name
      Throws:
      IllegalArgumentException - if you request an index that is no in the range of components of this Name
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • iterator

      public Iterator<String> iterator()
      Specified by:
      iterator in interface Iterable<String>
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object