public class StringPair extends java.lang.Object implements IMutableStringPair, IJSONConvertible, IStringRepresentation
Modifier and Type | Field and Description |
---|---|
static StringPair[] |
EMPTY_ARRAY |
static int |
NULL_HASHCODE
Defines the hash code of instances that contain two null strings.
|
JSON_ARRAY_END, JSON_ARRAY_START, JSON_ELEMENT_SEPARATOR, JSON_LITERAL_FALSE, JSON_LITERAL_NULL, JSON_LITERAL_TRUE, JSON_OBJECT_END, JSON_OBJECT_START, JSON_PAIR_SEPARATOR, JSON_STRING_DELIMITER, JSON_STRING_ESCAPE
Constructor and Description |
---|
StringPair()
Initialize the new instance with default values.
|
StringPair(IStringPair pair)
Initialize the new instance from the given string pair.
|
StringPair(java.lang.String string)
Initialize the new instance with one string.
|
StringPair(java.lang.String[] strings)
Initialize the new instance with two strings in an array.
|
StringPair(java.lang.String s1,
java.lang.String s2)
Initialize the new instance with two strings.
|
Modifier and Type | Method and Description |
---|---|
void |
appendAsJSONString(java.lang.Appendable output)
Appends the internal state as JSON string representation to the given buffer.
|
java.lang.String[] |
asArray()
Returns both strings of this pair in a String array.
|
java.lang.String |
asString()
Returns the string representation of the pair with the default separator.
|
java.lang.String |
asString(java.lang.String separator)
Returns the two strings as one string separated by the given separator.
|
static StringPair |
create(java.lang.String s1)
Initialize the a instance with a string in the first value and null in the second.
|
static StringPair |
create(java.lang.String s1,
java.lang.String s2)
Initialize the a instance with two strings.
|
boolean |
equals(java.lang.Object obj)
Returns true if the given object is an IStringPair and its both strings
are equal to the corresponding two strings of this object.
|
java.lang.String |
getDefaultSeparator()
Returns the default separator (here ":").
|
java.lang.String |
getString1()
Returns the first string of this pair.
|
java.lang.String |
getString2()
Returns the second string of this pair.
|
int |
hashCode()
Returns a hash built over the two contained strings.
|
protected boolean |
isEqual(java.lang.String s1,
java.lang.String s2) |
void |
setString1(java.lang.String newValue)
Sets the first string to the given value.
|
void |
setString2(java.lang.String newValue)
Sets the second string to the given value.
|
java.lang.String |
toJSON()
Returns a JSON string representation of this object.
|
java.lang.String |
toString()
Returns the two strings with the default separator in between.
|
public static final StringPair[] EMPTY_ARRAY
public static final int NULL_HASHCODE
public StringPair()
public StringPair(java.lang.String string)
public StringPair(java.lang.String s1, java.lang.String s2)
public StringPair(IStringPair pair)
public StringPair(java.lang.String[] strings)
java.lang.IllegalArgumentException
- If the array does not contain exactly 2 elements.public static StringPair create(java.lang.String s1, java.lang.String s2)
public static StringPair create(java.lang.String s1)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public void appendAsJSONString(java.lang.Appendable output)
appendAsJSONString
in interface IJSONConvertible
output
- The buffer to which to append the JSON string (must not be null).public java.lang.String toJSON()
toJSON
in interface IJSONConvertible
public java.lang.String[] asArray()
asArray
in interface IStringPair
public java.lang.String asString()
asString
in interface IStringRepresentation
public java.lang.String asString(java.lang.String separator)
asString
in interface IStringPair
separator
- A separator to be placed between the two strings.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getDefaultSeparator()
public java.lang.String getString1()
IStringPair
getString1
in interface IStringPair
public void setString1(java.lang.String newValue)
IMutableStringPair
setString1
in interface IMutableStringPair
newValue
- The new value (may be null).public java.lang.String getString2()
IStringPair
getString2
in interface IStringPair
public void setString2(java.lang.String newValue)
IMutableStringPair
setString2
in interface IMutableStringPair
newValue
- The new value (may be null).protected boolean isEqual(java.lang.String s1, java.lang.String s2)