Package org.apache.tapestry5.ioc.services

Examples of org.apache.tapestry5.ioc.services.PropertyAdapter


     * TAPESTRY-2448
     */
    @Test
    public void get_annotation_will_read_inherited_field()
    {
        PropertyAdapter pa = access.getAdapter(BeanSubclass.class).getPropertyAdapter("value");

        DataType dt = pa.getAnnotation(DataType.class);

        assertNotNull(dt);
        assertEquals(dt.value(), "fred");

    }
View Full Code Here


    }

    @Test
    public void field_annotation_overridden_by_getter_annotation()
    {
        PropertyAdapter pa = access.getAdapter(Bean.class).getPropertyAdapter("value");

        assertEquals(pa.getAnnotation(Validate.class).value(), "getter-value-overrides");
    }
View Full Code Here

    @Test
    public void using_generics()
    {
        ClassPropertyAdapter cpa1 = access.getAdapter(StringLongPair.class);

        PropertyAdapter pa1 = cpa1.getPropertyAdapter("key");
        assertSame(pa1.getType(), String.class);
        assertTrue(pa1.isCastRequired());

        PropertyAdapter pa2 = cpa1.getPropertyAdapter("value");
        assertSame(pa2.getType(), Long.class);
        assertTrue(pa2.isCastRequired());

        // On the base class, which defines the generic parameter type variables,
        // the properties just look like Object.

        ClassPropertyAdapter cpa2 = access.getAdapter(Pair.class);

        pa1 = cpa2.getPropertyAdapter("key");
        assertSame(pa1.getType(), Object.class);
        assertFalse(pa1.isCastRequired());

        pa2 = cpa2.getPropertyAdapter("value");
        assertSame(pa2.getType(), Object.class);
        assertFalse(pa2.isCastRequired());

    }
View Full Code Here

    }

    @Test
    public void annotation_absent()
    {
        PropertyAdapter adapter = mockPropertyAdapter();

        train_getAnnotation(adapter, DataType.class, null);

        replay();
View Full Code Here

    @Test
    public void value_from_annotation()
    {
        String value = "password";
        PropertyAdapter adapter = mockPropertyAdapter();

        train_getAnnotation(adapter, DataType.class, mockDataType(value));

        replay();
View Full Code Here

        ComponentResources resources = mockComponentResources();
        Component container = mockComponent();
        PropertyAccess access = mockPropertyAccess();
        ClassPropertyAdapter classPropertyAdapter = mockClassPropertyAdapter();
        PropertyAdapter propertyAdapter = mockPropertyAdapter();
        BindingSource bindingSource = mockBindingSource();
        Binding binding = mockBinding();
        ComponentResources containerResources = mockComponentResources();

        train_getId(resources, id);
View Full Code Here

            Method readMethod = pd.getReadMethod();

            Class propertyType = readMethod == null ? pd.getPropertyType() : GenericsUtils.extractGenericReturnType(
                    beanType, readMethod);

            PropertyAdapter pa = new PropertyAdapterImpl(this, pd.getName(), propertyType, readMethod,
                                                         pd.getWriteMethod());

            adapters.put(pa.getName(), pa);
        }
    }
View Full Code Here

        adaptorFor(propertyName).set(instance, value);
    }

    private PropertyAdapter adaptorFor(String name)
    {
        PropertyAdapter pa = adapters.get(name);

        if (pa == null) throw new IllegalArgumentException(ServiceMessages.noSuchProperty(beanType, name));

        return pa;
    }
View Full Code Here

        public void implementPropertyAccessors(Type activeType, Tree identifierNode)
        {
            String propertyName = identifierNode.getText();

            PropertyAdapter adapter = findPropertyAdapter(activeType, propertyName);

            conduitPropertyType = adapter.getType();
            conduitPropertyName = propertyName;
            annotationProvider = adapter;

            implementGetter(adapter);
            implementSetter(adapter);
View Full Code Here

        private Term buildPropertyAccessTerm(Type activeType, Tree termNode)
        {
            String propertyName = termNode.getText();

            PropertyAdapter adapter = findPropertyAdapter(activeType, propertyName);

            // Prefer the accessor over the field

            if (adapter.getReadMethod() != null)
            {
                return buildGetterMethodAccessTerm(activeType, propertyName,
                        adapter.getReadMethod());
            }

            if (adapter.getField() != null)
            {
                return buildPublicFieldAccessTerm(activeType, propertyName,
                        adapter.getField());
            }

            throw new RuntimeException(String.format(
                    "Property '%s' of class %s is not readable (it has no read accessor method).", adapter.getName(),
                    adapter.getBeanType().getName()));
        }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.ioc.services.PropertyAdapter

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.