Improved StringList constructors
This commit is contained in:
parent
a3737ddfa1
commit
668bb8fbb7
2 changed files with 119 additions and 32 deletions
|
@ -56,7 +56,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
|
||||||
* @param source
|
* @param source
|
||||||
* the source
|
* the source
|
||||||
*/
|
*/
|
||||||
public StringList(final boolean... source)
|
public StringList(final boolean[] source)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
|
||||||
* @param source
|
* @param source
|
||||||
* the source
|
* the source
|
||||||
*/
|
*/
|
||||||
public StringList(final char... source)
|
public StringList(final char[] source)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
|
||||||
* @param source
|
* @param source
|
||||||
* the source
|
* the source
|
||||||
*/
|
*/
|
||||||
public StringList(final double... source)
|
public StringList(final double[] source)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
|
||||||
* @param source
|
* @param source
|
||||||
* the source
|
* the source
|
||||||
*/
|
*/
|
||||||
public StringList(final float... source)
|
public StringList(final float[] source)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
|
||||||
* @param source
|
* @param source
|
||||||
* the source
|
* the source
|
||||||
*/
|
*/
|
||||||
public StringList(final int... source)
|
public StringList(final int[] source)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
|
||||||
* @param source
|
* @param source
|
||||||
* the source
|
* the source
|
||||||
*/
|
*/
|
||||||
public StringList(final long... source)
|
public StringList(final long[] source)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
|
||||||
* @param source
|
* @param source
|
||||||
* the source
|
* the source
|
||||||
*/
|
*/
|
||||||
public StringList(final short... source)
|
public StringList(final short[] source)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -281,31 +281,6 @@ public class StringList extends ArrayList<String> implements CharSequence, Appen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Appends the string of the array argument to this string list.
|
|
||||||
*
|
|
||||||
* @param values
|
|
||||||
* the values
|
|
||||||
* @return the string list
|
|
||||||
*/
|
|
||||||
public StringList append(final boolean... values)
|
|
||||||
{
|
|
||||||
StringList result;
|
|
||||||
|
|
||||||
if (values != null)
|
|
||||||
{
|
|
||||||
for (boolean value : values)
|
|
||||||
{
|
|
||||||
this.append(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result = this;
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see java.lang.Appendable#append(char)
|
* @see java.lang.Appendable#append(char)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -209,6 +209,118 @@ public class StringListTest
|
||||||
this.logger.debug("===== test done.");
|
this.logger.debug("===== test done.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test constructor 03.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testConstructor03()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
this.logger.debug("===== test starting...");
|
||||||
|
|
||||||
|
//
|
||||||
|
StringList target;
|
||||||
|
|
||||||
|
// Boolean.
|
||||||
|
target = new StringList(true, true, false);
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("true,true,false", target.toStringWithCommas());
|
||||||
|
|
||||||
|
target = new StringList(new boolean[] { true, true, false });
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("true,true,false", target.toStringWithCommas());
|
||||||
|
|
||||||
|
target = new StringList(new Boolean[] { true, true, false });
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("true,true,false", target.toStringWithCommas());
|
||||||
|
|
||||||
|
// Char.
|
||||||
|
target = new StringList('a', 'b', 'c');
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("a,b,c", target.toStringWithCommas());
|
||||||
|
|
||||||
|
target = new StringList(new char[] { 'a', 'b', (char) 67 });
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("a,b,C", target.toStringWithCommas());
|
||||||
|
|
||||||
|
target = new StringList(new Character[] { 'a', 'b', 'c' });
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("a,b,c", target.toStringWithCommas());
|
||||||
|
|
||||||
|
// Short.
|
||||||
|
target = new StringList((short) 0, (short) 1, (short) 2);
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0,1,2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
target = new StringList(new short[] { 0, 1, 2 });
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0,1,2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
target = new StringList(new Short[] { 0, 1, 2 });
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0,1,2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
// Integer.
|
||||||
|
target = new StringList(0, 1, 2);
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0,1,2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
target = new StringList(new int[] { 0, 1, 2 });
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0,1,2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
target = new StringList(new Integer[] { 0, 1, 2 });
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0,1,2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
// Long.
|
||||||
|
target = new StringList(0L, 1L, 2L);
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0,1,2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
target = new StringList(new long[] { 0L, 1L, 2L });
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0,1,2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
target = new StringList(new Long[] { 0L, 1L, 2L });
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0,1,2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
// Double.
|
||||||
|
target = new StringList(0.1d, 1.1d, 2.2d);
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0.1,1.1,2.2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
target = new StringList(new double[] { 0.1d, 1.1d, 2.2d });
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0.1,1.1,2.2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
target = new StringList(new Double[] { 0.1d, 1.1d, 2.2d });
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0.1,1.1,2.2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
// Float.
|
||||||
|
target = new StringList(0.1f, 1.1f, 2.2f);
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0.1,1.1,2.2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
target = new StringList(new float[] { 0.1f, 1.1f, 2.2f });
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0.1,1.1,2.2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
target = new StringList(new Float[] { 0.1f, 1.1f, 2.2f });
|
||||||
|
Assert.assertEquals(3, target.size());
|
||||||
|
Assert.assertEquals("0.1,1.1,2.2", target.toStringWithCommas());
|
||||||
|
|
||||||
|
// Foo.
|
||||||
|
target = new StringList(true, 1, 1.1, 2L, 3);
|
||||||
|
Assert.assertEquals(5, target.size());
|
||||||
|
Assert.assertEquals("true,1,1.1,2,3", target.toStringWithCommas());
|
||||||
|
|
||||||
|
//
|
||||||
|
this.logger.debug("===== test done.");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test contains 01.
|
* Test contains 01.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue