Package org.codehaus.preon.annotation

Examples of org.codehaus.preon.annotation.BoundObject.type()


    @SuppressWarnings("unchecked")
    private <T> Codec<T> createCodec(Class<T> type, ResolverContext context,
                                     AnnotatedElement metadata) {
        BoundObject settings = metadata.getAnnotation(BoundObject.class);
        // TODO: Handle type incompatibility
        if (Void.class.equals(settings.type())) {
            if (settings.selectFrom().alternatives().length > 0
                    || settings.selectFrom().defaultType() != Void.class) {
                return (Codec<T>) new SelectFromCodec(type, settings
                        .selectFrom(), context, codecFactory,
                        hideChoices(metadata));
View Full Code Here


            CodecSelectorFactory selectorFactory = null;
            selectorFactory = new TypePrefixSelectorFactory();
            CodecSelector selector = selectorFactory.create(context, codecs);
            return (Codec<T>) new SwitchingCodec(selector);
        } else {
            return (Codec<T>) createCodec(settings.type(), context);
        }
    }

    private AnnotatedElement hideChoices(AnnotatedElement metadata) {
        return new HidingAnnotatedElement(BoundObject.class, metadata);
View Full Code Here

    }

    private <T> Codec<?> createElementCodec(ResolverContext context, BoundList settings) {
        if (settings.types().length > 0) {
            BoundObject objectSettings = getObjectSettings(settings);
            return delegate.create(toAnnotatedElemented(objectSettings), objectSettings.type() == Void.class ? Object.class : objectSettings.type(), context);
        } else if (settings.type() != null) {
            return delegate.create(null, settings.type(), context);
        } else {
            throw new CodecConstructionException("Failed to determine the type of element.");
        }
View Full Code Here

    }

    private <T> Codec<?> createElementCodec(ResolverContext context, BoundList settings) {
        if (settings.types().length > 0) {
            BoundObject objectSettings = getObjectSettings(settings);
            return delegate.create(toAnnotatedElemented(objectSettings), objectSettings.type() == Void.class ? Object.class : objectSettings.type(), context);
        } else if (settings.type() != null) {
            return delegate.create(null, settings.type(), context);
        } else {
            throw new CodecConstructionException("Failed to determine the type of element.");
        }
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.