Added constructors for primitive types.
This commit is contained in:
parent
e6cabe2665
commit
3f28d77fea
1 changed files with 158 additions and 27 deletions
|
@ -50,6 +50,48 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
|
|||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new string list from an array of boolean.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
*/
|
||||
public StringList(final boolean... source)
|
||||
{
|
||||
super();
|
||||
|
||||
if (source != null)
|
||||
{
|
||||
ensureCapacity(source.length);
|
||||
|
||||
for (boolean value : source)
|
||||
{
|
||||
add(String.valueOf(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new string list from an array of char.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
*/
|
||||
public StringList(final char... source)
|
||||
{
|
||||
super();
|
||||
|
||||
if (source != null)
|
||||
{
|
||||
ensureCapacity(source.length);
|
||||
|
||||
for (char value : source)
|
||||
{
|
||||
add(String.valueOf(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a list of string of the specified collection, in the order they
|
||||
* are returned by the collection's iterator.
|
||||
|
@ -62,10 +104,8 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
|
|||
|
||||
if (source != null)
|
||||
{
|
||||
//
|
||||
ensureCapacity(source.size());
|
||||
|
||||
//
|
||||
for (String string : source)
|
||||
{
|
||||
this.add(string);
|
||||
|
@ -73,6 +113,48 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new string list from an array of double.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
*/
|
||||
public StringList(final double... source)
|
||||
{
|
||||
super();
|
||||
|
||||
if (source != null)
|
||||
{
|
||||
ensureCapacity(source.length);
|
||||
|
||||
for (double value : source)
|
||||
{
|
||||
add(String.valueOf(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new string list from an array of float.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
*/
|
||||
public StringList(final float... source)
|
||||
{
|
||||
super();
|
||||
|
||||
if (source != null)
|
||||
{
|
||||
ensureCapacity(source.length);
|
||||
|
||||
for (float value : source)
|
||||
{
|
||||
add(String.valueOf(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an empty list with the specified initial capacity.
|
||||
*
|
||||
|
@ -83,6 +165,48 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
|
|||
super(initialCapacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new string list from an array of int.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
*/
|
||||
public StringList(final int... source)
|
||||
{
|
||||
super();
|
||||
|
||||
if (source != null)
|
||||
{
|
||||
ensureCapacity(source.length);
|
||||
|
||||
for (int value : source)
|
||||
{
|
||||
add(String.valueOf(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new string list from an array of long.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
*/
|
||||
public StringList(final long... source)
|
||||
{
|
||||
super();
|
||||
|
||||
if (source != null)
|
||||
{
|
||||
ensureCapacity(source.length);
|
||||
|
||||
for (long value : source)
|
||||
{
|
||||
add(String.valueOf(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a list of string from an Object array.
|
||||
*
|
||||
|
@ -96,7 +220,38 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
|
|||
{
|
||||
ensureCapacity(source.length);
|
||||
|
||||
append(source);
|
||||
for (Object value : source)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
add(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
add(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new string list from an array of short.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
*/
|
||||
public StringList(final short... source)
|
||||
{
|
||||
super();
|
||||
|
||||
if (source != null)
|
||||
{
|
||||
ensureCapacity(source.length);
|
||||
|
||||
for (short value : source)
|
||||
{
|
||||
add(String.valueOf(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,30 +431,6 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the string of the array argument to this string list.
|
||||
*
|
||||
* @param values
|
||||
* @return
|
||||
*/
|
||||
public StringList append(final Long... values)
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (values != null)
|
||||
{
|
||||
for (Long value : values)
|
||||
{
|
||||
this.append(value);
|
||||
}
|
||||
}
|
||||
|
||||
result = this;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the string representation of the int argument to this string list.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue