Package org.apache.tapestry5.ioc.services

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


    }

    @Test
    public void class_property_adapter_returns_null_for_unknown_property()
    {
        ClassPropertyAdapter cpa = access.getAdapter(Bean.class);

        assertNull(cpa.getPropertyAdapter("google"));
    }
View Full Code Here


    }

    @Test
    public void access_to_property_type()
    {
        ClassPropertyAdapter cpa = access.getAdapter(Bean.class);

        assertEquals(cpa.getPropertyAdapter("value").getType(), int.class);
        assertEquals(cpa.getPropertyAdapter("readOnly").getType(), String.class);
        assertEquals(cpa.getPropertyAdapter("writeOnly").getType(), boolean.class);
    }
View Full Code Here

    }

    @Test
    public void property_names()
    {
        ClassPropertyAdapter cpa = access.getAdapter(Bean.class);

        assertEquals(cpa.getPropertyNames(), Arrays.asList("class", "readOnly", "value", "writeOnly"));
    }
View Full Code Here

    }

    @Test
    public void super_interface_methods_inherited_by_sub_interface()
    {
        ClassPropertyAdapter cpa = access.getAdapter(SubInterface.class);

        assertEquals(cpa.getPropertyNames(), Arrays.asList("grandParentProperty", "parentProperty", "subProperty"));
    }
View Full Code Here

    }

    @Test
    public void indexed_properties_are_ignored()
    {
        ClassPropertyAdapter cpa = access.getAdapter(BeanWithIndexedProperty.class);

        assertEquals(cpa.getPropertyNames(), Arrays.asList("class", "primitiveProperty"));
    }
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());

        assertSame(pa1.getDeclaringClass(), Pair.class);

        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

    public <T> BeanModel<T> create(Class<T> beanClass, boolean filterReadOnlyProperties, Messages messages)
    {
        assert beanClass != null;
        assert messages != null;
        ClassPropertyAdapter adapter = propertyAccess.getAdapter(beanClass);

        BeanModel<T> model = new BeanModelImpl<T>(beanClass, propertyConduitSource, typeCoercer, messages, locator);

        for (final String propertyName : adapter.getPropertyNames())
        {
            PropertyAdapter pa = adapter.getPropertyAdapter(propertyName);

            if (!pa.isRead())
                continue;

            if (pa.getAnnotation(NonVisual.class) != null)
View Full Code Here

    {
        final List<OptionModel> options = CollectionFactory.newList();

        for (final Object object : objects)
        {
            final ClassPropertyAdapter classPropertyAdapter = this.propertyAccess
                    .getAdapter(object);

            final PropertyAdapter propertyAdapter = classPropertyAdapter.getPropertyAdapter(labelProperty);

            final ValueEncoder encoder = this.valueEncoderSource.getValueEncoder(propertyAdapter.getType());

            final Object label = propertyAdapter.get(object);
View Full Code Here

        return getAdapter(instance.getClass());
    }

    public ClassPropertyAdapter getAdapter(Class forClass)
    {
        ClassPropertyAdapter result = adapters.get(forClass);

        if (result == null)
        {
            result = buildAdapter(forClass);
            adapters.put(forClass, result);
View Full Code Here

    }

    @SuppressWarnings({ "unchecked", "rawtypes" })
    public String getLabel(Object object)
    {
        final ClassPropertyAdapter classPropertyAdapter = this.propertyAccess.getAdapter(object);

        final PropertyAdapter propertyAdapter = classPropertyAdapter
                .getPropertyAdapter(labelProperty);

        final ValueEncoder encoder = this.valueEncoderSource.getValueEncoder(propertyAdapter
                .getType());
View Full Code Here

TOP

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

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.