GeneratedAttributeSupport { public static Byte valueOf(byte value) { return value; } GeneratedAttributeSupport(); static Byte valueOf(byte value); static Short valueOf(short value); static Integer valueOf(int value); static Long valueOf(long value); static Float valueOf(float value); static Double valueOf(double value); static Boolean valueOf(boolean value); static Character valueOf(char value); static List<Byte> valueOf(byte[] value); static List<Short> valueOf(short[] value); static List<Integer> valueOf(int[] value); static List<Long> valueOf(long[] value); static List<Float> valueOf(float[] value); static List<Double> valueOf(double[] value); static List<Boolean> valueOf(boolean[] value); static List<Character> valueOf(char[] value); static List<T> valueOf(T[] value); static List<T> valueOf(List<T> value); static T valueOf(T value);  }
@Test public void testAsList_PrimitiveArray() throws Exception { int[] input = new int[] {1, 2, 3, 4, 5}; List<Integer> list = GeneratedAttributeSupport.valueOf(input); Assert.assertEquals(5, list.size()); for (int i = 0; i < 5; i++) { Assert.assertEquals(Integer.valueOf(input[i]), list.get(i)); } list.set(2, 7); Assert.assertEquals(Integer.valueOf(7), list.get(2)); Assert.assertEquals(7, input[2]); }
@Test public void testAsList_ObjectArray() throws Exception { Integer[] input = new Integer[] {1, 2, 3, 4, 5}; List<Integer> list = GeneratedAttributeSupport.valueOf(input); Assert.assertEquals(5, list.size()); for (int i = 0; i < 5; i++) { Assert.assertEquals(input[i], list.get(i)); } list.set(2, 7); Assert.assertEquals(Integer.valueOf(7), list.get(2)); Assert.assertEquals(Integer.valueOf(7), input[2]); }
@Test public void testValueOfPrimitiveMethods() { assertEquals(Byte.valueOf((byte)5), GeneratedAttributeSupport.valueOf((byte)5)); assertEquals(Short.valueOf((short)5), GeneratedAttributeSupport.valueOf((short)5)); assertEquals(Integer.valueOf(5), GeneratedAttributeSupport.valueOf(5)); assertEquals(Long.valueOf(5L), GeneratedAttributeSupport.valueOf(5L)); assertEquals(Float.valueOf(5.0F), GeneratedAttributeSupport.valueOf(5.0F)); assertEquals(Double.valueOf(5.0), GeneratedAttributeSupport.valueOf(5.0)); assertEquals(Boolean.TRUE, GeneratedAttributeSupport.valueOf(true)); assertEquals(Character.valueOf('c'), GeneratedAttributeSupport.valueOf('c')); }
@Test public void testValueOfPrimitiveArrayMethods() { assertEquals(asList((byte)5, (byte)6), GeneratedAttributeSupport.valueOf(new byte[]{(byte)5, (byte)6})); assertEquals(asList((short) 5, (short) 6), GeneratedAttributeSupport.valueOf(new short[]{(short)5, (short)6})); assertEquals(asList(5, 6), GeneratedAttributeSupport.valueOf(new int[]{5, 6})); assertEquals(asList(5L, 6L), GeneratedAttributeSupport.valueOf(new long[]{5L, 6L})); assertEquals(asList(5.0F, 6.0F), GeneratedAttributeSupport.valueOf(new float[]{5.0F, 6.0F})); assertEquals(asList(5.0, 6.0), GeneratedAttributeSupport.valueOf(new double[]{5.0, 6.0})); assertEquals(asList(true, false), GeneratedAttributeSupport.valueOf(new boolean[]{true, false})); assertEquals(asList('c', 'd'), GeneratedAttributeSupport.valueOf(new char[]{'c', 'd'})); }
@Test public void testValueOfObjectArray() { assertEquals(asList("a", "b"), GeneratedAttributeSupport.valueOf(new String[]{"a", "b"})); }
@Test public void testValueOfList() { ArrayList<String> input = new ArrayList<String>(asList("a", "b")); assertSame(input, GeneratedAttributeSupport.valueOf(input)); }
@Test public void testValueOfObject() { Object input = new Object(); assertSame(input, GeneratedAttributeSupport.valueOf(input)); }