Search in sources :

Example 1 with AnnotationDataTypeAnalyzer

use of org.apache.tapestry5.commons.internal.services.AnnotationDataTypeAnalyzer in project tapestry-5 by apache.

the class BasicDataTypeAnalyzers method contributeDataTypeAnalyzer.

public static void contributeDataTypeAnalyzer(OrderedConfiguration<DataTypeAnalyzer> configuration, DataTypeAnalyzer defaultDataTypeAnalyzer) {
    configuration.add("Annotation", new AnnotationDataTypeAnalyzer());
    if (defaultDataTypeAnalyzer == null) {
        defaultDataTypeAnalyzer = createDefaultDataTypeAnalyzer();
    }
    configuration.add("Default", defaultDataTypeAnalyzer, "after:*");
}
Also used : AnnotationDataTypeAnalyzer(org.apache.tapestry5.commons.internal.services.AnnotationDataTypeAnalyzer)

Example 2 with AnnotationDataTypeAnalyzer

use of org.apache.tapestry5.commons.internal.services.AnnotationDataTypeAnalyzer in project tapestry-5 by apache.

the class BasicDataTypeAnalyzers method createDefaultDataTypeAnalyzer.

public static DataTypeAnalyzer createDefaultDataTypeAnalyzer() {
    DefaultDataTypeAnalyzerMappedConfiguration mappedConfiguration = new DefaultDataTypeAnalyzerMappedConfiguration();
    provideDefaultDataTypeAnalyzers(mappedConfiguration);
    return new CombinedDataTypeAnalyzer(new AnnotationDataTypeAnalyzer(), new DefaultDataTypeAnalyzer(mappedConfiguration.getMap()));
}
Also used : DefaultDataTypeAnalyzer(org.apache.tapestry5.commons.internal.services.DefaultDataTypeAnalyzer) AnnotationDataTypeAnalyzer(org.apache.tapestry5.commons.internal.services.AnnotationDataTypeAnalyzer)

Example 3 with AnnotationDataTypeAnalyzer

use of org.apache.tapestry5.commons.internal.services.AnnotationDataTypeAnalyzer in project tapestry-5 by apache.

the class TapestryModule method contributeDataTypeAnalyzer.

/**
 * <dl>
 * <dt>Annotation</dt>
 * <dd>Checks for {@link org.apache.tapestry5.beaneditor.DataType} annotation</dd>
 * <dt>Default (ordered last)</dt>
 * <dd>
 * {@link org.apache.tapestry5.commons.internal.services.DefaultDataTypeAnalyzer} service (
 * {@link #contributeDefaultDataTypeAnalyzer(org.apache.tapestry5.commons.MappedConfiguration)} )</dd>
 * </dl>
 */
public static void contributeDataTypeAnalyzer(OrderedConfiguration<DataTypeAnalyzer> configuration, @InjectService("DefaultDataTypeAnalyzer") DataTypeAnalyzer defaultDataTypeAnalyzer) {
    configuration.add("Annotation", new AnnotationDataTypeAnalyzer());
    configuration.add("Default", defaultDataTypeAnalyzer, "after:*");
}
Also used : AnnotationDataTypeAnalyzer(org.apache.tapestry5.commons.internal.services.AnnotationDataTypeAnalyzer)

Example 4 with AnnotationDataTypeAnalyzer

use of org.apache.tapestry5.commons.internal.services.AnnotationDataTypeAnalyzer in project tapestry-5 by apache.

the class AnnotationDataTypeAnalyzerTest method value_from_annotation.

@Test
public void value_from_annotation() {
    String value = "password";
    PropertyAdapter adapter = mockPropertyAdapter();
    train_getAnnotation(adapter, DataType.class, mockDataType(value));
    replay();
    DataTypeAnalyzer analyzer = new AnnotationDataTypeAnalyzer();
    assertEquals(analyzer.identifyDataType(adapter), value);
    verify();
}
Also used : PropertyAdapter(org.apache.tapestry5.commons.services.PropertyAdapter) AnnotationDataTypeAnalyzer(org.apache.tapestry5.commons.internal.services.AnnotationDataTypeAnalyzer) DataTypeAnalyzer(org.apache.tapestry5.commons.services.DataTypeAnalyzer) AnnotationDataTypeAnalyzer(org.apache.tapestry5.commons.internal.services.AnnotationDataTypeAnalyzer) Test(org.testng.annotations.Test)

Example 5 with AnnotationDataTypeAnalyzer

use of org.apache.tapestry5.commons.internal.services.AnnotationDataTypeAnalyzer in project tapestry-5 by apache.

the class AnnotationDataTypeAnalyzerTest method annotation_absent.

@Test
public void annotation_absent() {
    PropertyAdapter adapter = mockPropertyAdapter();
    train_getAnnotation(adapter, DataType.class, null);
    replay();
    DataTypeAnalyzer analyzer = new AnnotationDataTypeAnalyzer();
    assertNull(analyzer.identifyDataType(adapter));
    verify();
}
Also used : PropertyAdapter(org.apache.tapestry5.commons.services.PropertyAdapter) AnnotationDataTypeAnalyzer(org.apache.tapestry5.commons.internal.services.AnnotationDataTypeAnalyzer) DataTypeAnalyzer(org.apache.tapestry5.commons.services.DataTypeAnalyzer) AnnotationDataTypeAnalyzer(org.apache.tapestry5.commons.internal.services.AnnotationDataTypeAnalyzer) Test(org.testng.annotations.Test)

Aggregations

AnnotationDataTypeAnalyzer (org.apache.tapestry5.commons.internal.services.AnnotationDataTypeAnalyzer)5 DataTypeAnalyzer (org.apache.tapestry5.commons.services.DataTypeAnalyzer)2 PropertyAdapter (org.apache.tapestry5.commons.services.PropertyAdapter)2 Test (org.testng.annotations.Test)2 DefaultDataTypeAnalyzer (org.apache.tapestry5.commons.internal.services.DefaultDataTypeAnalyzer)1