Package info.archinnov.achilles.codec

Examples of info.archinnov.achilles.codec.Codec.sourceType()


        Codec codec = getValueCodecInstance(field);

        validateNotIdentityCodec(fieldName, className, codec);

        final Class<?> sourceType = codec.sourceType();
        final Class<?> targetType = codec.targetType();

        validateTypesNotNull(fieldName, className, sourceType, targetType);

        final Class<?> listValueType = TypeParser.inferValueClassForListOrSet(field.getGenericType(), field.getDeclaringClass());
View Full Code Here


        Codec codec = getValueCodecInstance(field);

        validateNotIdentityCodec(fieldName, className, codec);

        final Class<?> sourceType = codec.sourceType();
        final Class<?> targetType = codec.targetType();

        validateTypesNotNull(fieldName, className, sourceType, targetType);

        final Class<?> listValueType = TypeParser.inferValueClassForListOrSet(field.getGenericType(), field.getDeclaringClass());
View Full Code Here

        log.debug("Parse list codec for field {}", field);
        if (filter.hasAnnotation(field, TypeTransformer.class)) {
            return typeTransformerParser.parseAndValidateListCodec(field);
        } else {
            final Codec simpleCodec = createSimpleCodecForCollection(context);
            return new ListCodecImpl(simpleCodec.sourceType(), simpleCodec.targetType(), simpleCodec);
        }
    }

    SetCodec parseSetField(PropertyParsingContext context) {
        final Field field = context.getCurrentField();
View Full Code Here

        log.debug("Parse set codec for field {}", field);
        if (filter.hasAnnotation(field, TypeTransformer.class)) {
            return typeTransformerParser.parseAndValidateSetCodec(field);
        } else {
            final Codec simpleCodec = createSimpleCodecForCollection(context);
            return new SetCodecImpl(simpleCodec.sourceType(), simpleCodec.targetType(), simpleCodec);
        }
    }

    MapCodec parseMapField(PropertyParsingContext context) {
        final Field field = context.getCurrentField();
View Full Code Here

            final Codec valueCodec = createSimpleCodec(context, sourceTargetTypes.right, maybeEncodingValue);

            return MapCodecBuilder.fromKeyType(keyCodec.sourceType())
                    .toKeyType(keyCodec.targetType())
                    .withKeyCodec(keyCodec)
                    .fromValueType(valueCodec.sourceType())
                    .toValueType(valueCodec.targetType())
                    .withValueCodec(valueCodec);
        }

    }
View Full Code Here

        //When
        final Codec codec = factory.parseSimpleField(createContext(field));

        //Then
        assertThat(codec.sourceType()).isSameAs(Long.class);
        assertThat(codec.targetType()).isSameAs(String.class);
    }

    @Test
    public void should_create_enum_name_codec() throws Exception {
View Full Code Here

        //When
        final Codec actual = parser.parseAndValidateSimpleCodec(Test.class.getDeclaredField("longToString"));

        //Then
        assertThat(actual).isInstanceOf(LongToStringCodec.class);
        assertThat(actual.sourceType()).isSameAs(Long.class);
        assertThat(actual.targetType()).isSameAs(String.class);
    }

    @Test
    public void should_exception_when_codec_class_not_instance_of_codec() throws Exception {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.