Package info.archinnov.achilles.internal.metadata.codec

Examples of info.archinnov.achilles.internal.metadata.codec.ByteCodec


    }
    private Codec createSimpleCodec(PropertyParsingContext context, Class type, Optional<Encoding> maybeEncoding) {
        log.debug("Create simple codec for java type {}", type);
        Codec codec;
        if (Byte.class.isAssignableFrom(type) || byte.class.isAssignableFrom(type)) {
            codec = new ByteCodec();
        } else if (byte[].class.isAssignableFrom(type)) {
            codec = new ByteArrayPrimitiveCodec();
        } else if (Byte[].class.isAssignableFrom(type)) {
            codec = new ByteArrayCodec();
        } else if (PropertyParser.isAssignableFromNativeType(type)) {
View Full Code Here


    @Test
    public void should_encode_and_decode() throws Exception {
        //Given
        ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[]{5});
        ByteCodec codec = new ByteCodec();

        //When
        ByteBuffer encoded = codec.encode((byte) 3);
        Byte decoded = codec.decode(byteBuffer);

        //Then
        assertThat(encoded.array()[0]).isEqualTo((byte)3);
        assertThat(decoded).isEqualTo(new Byte((byte)5));
    }
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.internal.metadata.codec.ByteCodec

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.