use of org.robobinding.codegen.apt.element.SetterElement in project RoboBinding by RoboBinding.
the class ViewBindingInfoBuilder method extractSimpleOneWayPropertyInfoList.
private List<SimpleOneWayPropertyInfo> extractSimpleOneWayPropertyInfoList(WrappedTypeElement viewType) {
ViewBindingAnnotationMirror annotation = new ViewBindingAnnotationMirror(typeElement.getAnnotation(ViewBinding.class));
List<String> simpleOneWayProperties = annotation.getSimpleOneWayProperties();
SetterElements setters = new SetterElements(viewType.looseSetters(new SimpleOneWayPropertySetterFilter(simpleOneWayProperties)));
if (setters.hasAmbiguousSetters()) {
throw OneWayBindingPropertyGenerationException.setterWithDifferentParameterTypes(viewType, setters.getPropertiesWithAmbiguousSetters());
}
if (!setters.containsAll(simpleOneWayProperties)) {
throw OneWayBindingPropertyGenerationException.noSettersFound(viewType, setters.findMissingProperties(simpleOneWayProperties));
}
List<SimpleOneWayPropertyInfo> result = Lists.newArrayList();
for (SetterElement setter : setters) {
result.add(new SimpleOneWayPropertyInfo(setter));
}
return result;
}
use of org.robobinding.codegen.apt.element.SetterElement in project RoboBinding by RoboBinding.
the class SimpleOneWayPropertyInfoTest method givenPrimitivePropertyType_thenReturnBoxedType.
@Test
public void givenPrimitivePropertyType_thenReturnBoxedType() {
final SetterElement setter = context.mock(SetterElement.class);
final WrappedPrimitiveType primitiveType = context.mock(WrappedPrimitiveType.class);
context.checking(new Expectations() {
{
oneOf(setter).parameterType();
will(returnValue(primitiveType));
oneOf(primitiveType).isPrimitive();
will(returnValue(true));
oneOf(primitiveType).boxedClassName();
will(returnValue(Integer.class.getName()));
}
});
SimpleOneWayPropertyInfo info = new SimpleOneWayPropertyInfo(setter);
assertThat(info.propertyType(), equalTo(Integer.class.getName()));
}
use of org.robobinding.codegen.apt.element.SetterElement in project RoboBinding by RoboBinding.
the class SimpleOneWayPropertyInfoTest method givenObjectPropertyType_thenReturnSameType.
@Test
public void givenObjectPropertyType_thenReturnSameType() {
final SetterElement setter = context.mock(SetterElement.class);
final WrappedDeclaredType declaredType = context.mock(WrappedDeclaredType.class);
context.checking(new Expectations() {
{
oneOf(setter).parameterType();
will(returnValue(declaredType));
oneOf(declaredType).isPrimitive();
will(returnValue(false));
oneOf(declaredType).className();
will(returnValue(Object.class.getName()));
}
});
SimpleOneWayPropertyInfo info = new SimpleOneWayPropertyInfo(setter);
assertThat(info.propertyType(), equalTo(Object.class.getName()));
}
use of org.robobinding.codegen.apt.element.SetterElement in project RoboBinding by RoboBinding.
the class SimpleOneWayPropertyInfoTest method shouldGetCorrectAttributeTypeName.
@Test
public void shouldGetCorrectAttributeTypeName() {
final SetterElement setter = context.mock(SetterElement.class);
context.checking(new Expectations() {
{
oneOf(setter).propertyName();
will(returnValue("prop1"));
}
});
SimpleOneWayPropertyInfo info = new SimpleOneWayPropertyInfo(setter);
assertThat(info.bindingTypeName(), equalTo("Prop1Attribute"));
}
Aggregations