Package com.humaorie.dollar.ArrayWrapper

Examples of com.humaorie.dollar.ArrayWrapper.ByteArrayWrapper


    @Override
    public ArrayWrapper<T> convert() {
        T[] array = toArray();
        Class<?> componentType = array.getClass().getComponentType();
        if (componentType.equals(Byte.class)) {
            return (ArrayWrapper<T>) new ByteArrayWrapper((Byte[]) array);
        } else if (componentType.equals(Short.class)) {
            return (ArrayWrapper<T>) new ShortArrayWrapper((Short[]) array);
        } else if (componentType.equals(Integer.class)) {
            return (ArrayWrapper<T>) new IntegerArrayWrapper((Integer[]) array);
        } else if (componentType.equals(Long.class)) {
View Full Code Here


    }

    @Test
    public void boxByteArray() {
        byte[] unboxed = new byte[]{42, 42, 42};
        ByteArrayWrapper arrayWrapper = new ByteArrayWrapper(unboxed);
        Assert.assertArrayEquals(new Byte[]{42, 42, 42}, arrayWrapper.toArray());
    }
View Full Code Here

    }

    @Test
    public void unboxByteArray() {
        Byte[] boxed = new Byte[]{42, 43, 44};
        ByteArrayWrapper arrayWrapper = new ByteArrayWrapper(boxed);
        Assert.assertArrayEquals(new byte[]{42, 43, 44}, arrayWrapper.toByteArray());
    }
View Full Code Here

    }

    @Test
    public void unboxByteArrayToCharArray() {
        Byte[] boxed = new Byte[] { 'f', 'o', 'o' };
        ByteArrayWrapper arrayWrapper = new ByteArrayWrapper(boxed);
        Assert.assertArrayEquals(new char[] { 'f', 'o', 'o' },
                arrayWrapper.toCharArray());
    }
View Full Code Here

    }

    @Test
    public void unboxByteArrayToShortArray() {
        Byte[] boxed = new Byte[]{42, 43, 44};
        ByteArrayWrapper arrayWrapper = new ByteArrayWrapper(boxed);
        Assert.assertArrayEquals(new short[]{42, 43, 44}, arrayWrapper.toShortArray());
    }
View Full Code Here

    }

    @Test
    public void unboxByteArrayToIntArray() {
        Byte[] boxed = new Byte[]{42, 43, 44};
        ByteArrayWrapper arrayWrapper = new ByteArrayWrapper(boxed);
        Assert.assertArrayEquals(new int[]{42, 43, 44}, arrayWrapper.toIntArray());
    }
View Full Code Here

    }

    @Test
    public void unboxByteArrayToLongArray() {
        Byte[] boxed = new Byte[]{42, 43, 44};
        ByteArrayWrapper arrayWrapper = new ByteArrayWrapper(boxed);
        Assert.assertArrayEquals(new long[]{42, 43, 44}, arrayWrapper.toLongArray());
    }
View Full Code Here

    }

    @Test
    public void unboxByteArrayWithNulls() {
        Byte[] boxed = new Byte[3];
        ByteArrayWrapper arrayWrapper = new ByteArrayWrapper(boxed);
        Assert.assertArrayEquals(new byte[]{0, 0, 0}, arrayWrapper.toByteArray());
    }
View Full Code Here

TOP

Related Classes of com.humaorie.dollar.ArrayWrapper.ByteArrayWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.