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;
  }
  private WrappedTypeElement extractViewType() {
    WrappedTypeElement customViewBinding =
        typeElement.findDirectSuperclassOf(CustomViewBinding.class);
    if (customViewBinding == null) {
      throw new RuntimeException(
          MessageFormat.format(
              "{0} has to be direct SubClass of {1}",
              typeElement.qName(), CustomViewBinding.class.getName()));
    }

    return customViewBinding.firstTypeArgument();
  }
 public ViewBindingInfo build() {
   WrappedTypeElement viewType = extractViewType();
   List<SimpleOneWayPropertyInfo> simpleOneWayPropertyInfoList =
       extractSimpleOneWayPropertyInfoList(viewType);
   return new ViewBindingInfo(
       typeElement.qName(), viewBindingObjectTypeName, viewType, simpleOneWayPropertyInfoList);
 }
Example #4
0
 public String viewType() {
   return viewType.qName();
 }