public final class CompoundName extends Object
Using CompoundName is generally substantially faster than using strings.
Modifier and Type | Field and Description |
---|---|
private com.google.common.collect.ImmutableList<String> |
compounds |
static CompoundName |
empty
The empty compound
|
private int |
hashCode
A hashcode which is always derived from the compounds (NEVER the string)
|
private String |
lowerCasedName |
private String |
name
The string name of this compound.
|
private CompoundName |
rest
This name with the first component removed
|
Modifier | Constructor and Description |
---|---|
|
CompoundName(List<String> compounds)
Constructs this from a list of compounds.
|
|
CompoundName(String name)
Constructs this from a string which may contains dot-separated components
|
private |
CompoundName(String name,
List<String> compounds)
Constructs this from a name with already parsed compounds.
|
Modifier and Type | Method and Description |
---|---|
CompoundName |
append(CompoundName name)
Returns a compound name which has the given compounds appended to it
|
CompoundName |
append(String name)
Returns a compound name which has the given compound string appended to it
|
List<String> |
asList()
Returns an immutable list of the components of this
|
private String |
concat(String name1,
String name2) |
boolean |
equals(Object o) |
String |
first()
Returns the name before the first dot.
|
CompoundName |
first(int n)
Returns the first n components of this.
|
static CompoundName |
fromComponents(String... components)
Constructs this from an array of name components which are assumed not to contain dots
|
String |
get(int i)
Returns the compound element as the given index
|
String |
getLowerCasedName() |
int |
hashCode() |
boolean |
hasPrefix(CompoundName prefix)
Returns whether the given name is a prefix of this.
|
boolean |
isCompound()
Returns whether this name has more than one element
|
boolean |
isEmpty() |
String |
last()
Returns the name after the last dot.
|
private static List<String> |
parse(String s) |
CompoundName |
prepend(String... nameParts)
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".
|
CompoundName |
rest()
Returns the name after the first dot, or "" if this name has no dots
|
CompoundName |
rest(int n)
Returns the name starting after the n first components (i.e dots).
|
CompoundName |
set(int i,
String name)
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.
|
private static String |
toCompoundString(List<String> compounds) |
String |
toString()
Returns the string representation of this - all the name components in order separated by dots.
|
private final String name
private final String lowerCasedName
private final com.google.common.collect.ImmutableList<String> compounds
private final int hashCode
private final CompoundName rest
public static final CompoundName empty
public CompoundName(String name)
NullPointerException
- if name is nullpublic static CompoundName fromComponents(String... components)
public CompoundName append(String name)
name
- if name is empty this returns this
public CompoundName append(CompoundName name)
name
- if name is empty this returns this
public CompoundName prepend(String... nameParts)
nameParts
- if name is empty this returns this
public String last()
public String first()
public CompoundName first(int n)
IllegalArgumentException
- if this does not have at least n componentspublic CompoundName rest()
public CompoundName rest(int n)
IllegalArgumentException
- if this does not have at least that many componentspublic int size()
public String get(int i)
public CompoundName set(int i, String name)
public boolean isCompound()
public boolean isEmpty()
public boolean hasPrefix(CompoundName prefix)
public String toString()
public String getLowerCasedName()
Copyright © 2018. All rights reserved.