Package com.yahoo.processing.request
Class CompoundName
java.lang.Object
com.yahoo.processing.request.CompoundName
An immutable compound name of the general form "a.bb.ccc",
where there can be any number of such compounds, including one or zero.
Using CompoundName is generally substantially faster than using strings.
- Author:
- bratseth
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCompoundName
(String name) Constructs this from a string which may contains dot-separated componentsCompoundName
(List<String> compounds) Constructs this from a list of compounds. -
Method Summary
Modifier and TypeMethodDescriptionappend
(CompoundName name) Returns a compound name which has the given compounds appended to itReturns a compound name which has the given compound string appended to itasList()
Returns an immutable list of the components of thisboolean
first()
Returns the name before the first dot.first
(int n) Returns the first n components of this.static CompoundName
static CompoundName
fromComponents
(String... components) Constructs this from an array of name components which are assumed not to contain dotsget
(int i) Returns the compound element as the given indexint
hashCode()
boolean
hasPrefix
(CompoundName prefix) Returns whether the given name is a prefix of this.boolean
Returns whether this name has more than one elementboolean
isEmpty()
last()
Returns the name after the last dot.Returns a compound name which has the given name components prepended to this name, in the given order, i.e new ComponentName("c").prepend("a","b") will yield "a.b.c".rest()
Returns the name after the first dot, or "" if this name has no dotsrest
(int n) Returns the name starting after the n first components (i.e dots).Returns a compound which have the name component at index i set to the given name.int
size()
Returns the number of compound elements in this.toString()
Returns the string representation of this - all the name components in order separated by dots.
-
Field Details
-
empty
The empty compound
-
-
Constructor Details
-
CompoundName
Constructs this from a string which may contains dot-separated components- Throws:
NullPointerException
- if name is null
-
CompoundName
Constructs this from a list of compounds.
-
-
Method Details
-
fromComponents
Constructs this from an array of name components which are assumed not to contain dots -
append
Returns a compound name which has the given compound string appended to it- Parameters:
name
- if name is empty this returnsthis
-
append
Returns a compound name which has the given compounds appended to it- Parameters:
name
- if name is empty this returnsthis
-
prepend
Returns a compound name which has the given name components prepended to this name, in the given order, i.e new ComponentName("c").prepend("a","b") will yield "a.b.c".- Parameters:
nameParts
- if name is empty this returnsthis
-
last
Returns the name after the last dot. If there are no dots, the full name is returned. -
first
Returns the name before the first dot. If there are no dots the full name is returned. -
first
Returns the first n components of this.- Throws:
IllegalArgumentException
- if this does not have at least n components
-
rest
Returns the name after the first dot, or "" if this name has no dots -
rest
Returns the name starting after the n first components (i.e dots). This may be the empty name.- Throws:
IllegalArgumentException
- if this does not have at least that many components
-
size
public int size()Returns the number of compound elements in this. Which is exactly the number of dots in the string plus one. The size of an empty compound is 0. -
get
Returns the compound element as the given index -
set
Returns a compound which have the name component at index i set to the given name. As an optimization, if the given name == the name component at this index, this is returned. -
isCompound
public boolean isCompound()Returns whether this name has more than one element -
isEmpty
public boolean isEmpty() -
hasPrefix
Returns whether the given name is a prefix of this. Prefixes are taken on the component, not character level, so "a" is a prefix of "a.b", but not a prefix of "ax.b -
asList
Returns an immutable list of the components of this -
hashCode
public int hashCode() -
equals
-
toString
Returns the string representation of this - all the name components in order separated by dots. -
getLowerCasedName
-
from
-