de.matthiasmann.twl.utils
Class StringList

java.lang.Object
  extended by de.matthiasmann.twl.utils.StringList
All Implemented Interfaces:
java.lang.Iterable<java.lang.String>

public final class StringList
extends java.lang.Object
implements java.lang.Iterable<java.lang.String>

An immutable single linked list of strings.


Constructor Summary
StringList(java.lang.String value)
          Constructs a string list with a single entry.
StringList(java.lang.String value, StringList next)
          Constructs a new head of a string list.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 StringList getNext()
          Returns the next element in the string list, or null if this is the last
 java.lang.String getValue()
          Returns the string value of this element, never null
 int hashCode()
           
 java.util.Iterator<java.lang.String> iterator()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringList

public StringList(java.lang.String value)
Constructs a string list with a single entry. This is equivalent to new StringList(value, null);

Parameters:
value - the string value
Throws:
java.lang.NullPointerException - if value is null

StringList

public StringList(java.lang.String value,
                  StringList next)
Constructs a new head of a string list.

Parameters:
value - the string value
next - the rest/tail of the string list, can be null
Throws:
java.lang.NullPointerException - if value is null
Method Detail

getNext

public StringList getNext()
Returns the next element in the string list, or null if this is the last

Returns:
the next element in the string list, or null if this is the last

getValue

public java.lang.String getValue()
Returns the string value of this element, never null

Returns:
the string value of this element, never null

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

iterator

public java.util.Iterator<java.lang.String> iterator()
Specified by:
iterator in interface java.lang.Iterable<java.lang.String>