Examples of BoundObject


Examples of org.codehaus.preon.annotation.BoundObject

            Codec<Object> elementCodec = null;
            if (type.getComponentType().isPrimitive()) {
                elementCodec = (Codec<Object>) factory.create(null, type
                        .getComponentType(), context);
            } else {
                BoundObject objectSettings = getObjectSettings(settings);
                elementCodec = (Codec<Object>) factory.create(
                        new AnnotationWrapper(objectSettings), type
                                .getComponentType(), context);
            }
            return (Codec<T>) new ArrayCodec(expr, elementCodec, type);
View Full Code Here

Examples of org.codehaus.preon.annotation.BoundObject

        }

    }

    private BoundObject getObjectSettings(final BoundList settings) {
        return new BoundObject() {

            public Class<?> type() {
                return settings.type();
            }
View Full Code Here

Examples of org.codehaus.preon.annotation.BoundObject

    }

    @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));
            }
            if (settings.types().length == 0) {
                return createCodec(type, context);
            }
            List<Codec<?>> codecs = new ArrayList<Codec<?>>();
            for (Class valueType : settings.types()) {
                codecs.add(codecFactory.create(null, valueType, context));
            }
            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);
        }
    }
View Full Code Here

Examples of org.codehaus.preon.annotation.BoundObject

    }

    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

Examples of org.codehaus.preon.annotation.BoundObject

     *
     * @param settings The {@link BoundList} settings.
     * @return A {@link BoundObject} annotation with settings copied from the {@link BoundList} annotation passed in.
     */
    private BoundObject getObjectSettings(final BoundList settings) {
        return new BoundObject() {

            public Class<?> type() {
                return settings.type();
            }

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.