From bcfecc8e7c93195e8bc39bc77a0b0b09e14de1e3 Mon Sep 17 00:00:00 2001 From: Eli Hart Date: Mon, 18 Jun 2018 11:10:01 -0500 Subject: [PATCH] Fix support for wildcards in private epoxyattributes (#451) * Fix support for wildcards in private epoxyattributes * fix imports * remove old tests --- .../airbnb/epoxy/BaseModelAttributeInfo.java | 7 ++----- .../com/airbnb/epoxy/ModelProcessorTest.java | 12 ------------ ...vateFieldWithGetterWithWrongReturnType.java | 18 ------------------ ...ivateFieldWithSetterWithWrongParamType.java | 17 ----------------- 4 files changed, 2 insertions(+), 52 deletions(-) delete mode 100755 epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithGetterWithWrongReturnType.java delete mode 100755 epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithSetterWithWrongParamType.java diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/BaseModelAttributeInfo.java b/epoxy-processor/src/main/java/com/airbnb/epoxy/BaseModelAttributeInfo.java index ae4e288577..87e7ecedfa 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/BaseModelAttributeInfo.java +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/BaseModelAttributeInfo.java @@ -3,7 +3,6 @@ import com.airbnb.epoxy.EpoxyAttribute.Option; import com.squareup.javapoet.AnnotationSpec; import com.squareup.javapoet.ClassName; -import com.squareup.javapoet.TypeName; import java.lang.annotation.ElementType; import java.lang.annotation.Target; @@ -146,8 +145,7 @@ private void findGetterAndSetterForPrivateField(ErrorLogger errorLogger) { || (methodName.equals(fieldName) && startsWithIs(fieldName))) && !method.getModifiers().contains(PRIVATE) && !method.getModifiers().contains(STATIC) - && method.getParameters().isEmpty() - && TypeName.get(method.getReturnType()).equals(getTypeName())) { + && method.getParameters().isEmpty()) { getterMethodName = methodName; } // check if it is a valid setter @@ -156,8 +154,7 @@ private void findGetterAndSetterForPrivateField(ErrorLogger errorLogger) { fieldName.substring(2, fieldName.length()))))) && !method.getModifiers().contains(PRIVATE) && !method.getModifiers().contains(STATIC) - && method.getParameters().size() == 1 - && TypeName.get(method.getParameters().get(0).asType()).equals(getTypeName())) { + && method.getParameters().size() == 1) { setterMethodName = methodName; } } diff --git a/epoxy-processortest/src/test/java/com/airbnb/epoxy/ModelProcessorTest.java b/epoxy-processortest/src/test/java/com/airbnb/epoxy/ModelProcessorTest.java index 368874b918..f118e4cdc8 100755 --- a/epoxy-processortest/src/test/java/com/airbnb/epoxy/ModelProcessorTest.java +++ b/epoxy-processortest/src/test/java/com/airbnb/epoxy/ModelProcessorTest.java @@ -308,12 +308,6 @@ public void testModelWithPrivateAttributeWithGetterWithParamsFails() { "private fields without proper getter and setter"); } - @Test - public void testModelWithPrivateAttributeWithGetterWithWrongReturnTypeFails() { - assertGenerationError("ModelWithPrivateFieldWithGetterWithWrongReturnType.java", - "private fields without proper getter and setter"); - } - @Test public void testModelWithPrivateAttributeWithPrivateSetterFails() { assertGenerationError("ModelWithPrivateFieldWithPrivateSetter.java", @@ -332,12 +326,6 @@ public void testModelWithPrivateAttributeWithGetterWithoutParamsFails() { "private fields without proper getter and setter"); } - @Test - public void testModelWithPrivateAttributeWithSetterWithWrongReturnTypeFails() { - assertGenerationError("ModelWithPrivateFieldWithSetterWithWrongParamType.java", - "private fields without proper getter and setter"); - } - @Test public void testModelWithAllPrivateFieldTypes() { assertGeneration("ModelWithAllPrivateFieldTypes.java", "ModelWithAllPrivateFieldTypes_.java"); diff --git a/epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithGetterWithWrongReturnType.java b/epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithGetterWithWrongReturnType.java deleted file mode 100755 index 6ef88015c9..0000000000 --- a/epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithGetterWithWrongReturnType.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.airbnb.epoxy; - -public class ModelWithPrivateFieldWithGetterWithWrongReturnType extends EpoxyModel { - @EpoxyAttribute private int valueInt; - - @Override - protected int getDefaultLayout() { - return 0; - } - - public boolean getValueInt() { - return false; - } - - public void setValueInt(int valueInt) { - this.valueInt = valueInt; - } -} \ No newline at end of file diff --git a/epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithSetterWithWrongParamType.java b/epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithSetterWithWrongParamType.java deleted file mode 100755 index b1cf36997e..0000000000 --- a/epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithSetterWithWrongParamType.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.airbnb.epoxy; - -public class ModelWithPrivateFieldWithSetterWithWrongParamType extends EpoxyModel { - @EpoxyAttribute private int valueInt; - - @Override - protected int getDefaultLayout() { - return 0; - } - - public int getValueInt() { - return valueInt; - } - - public void setValueInt(String valueString) { - } -} \ No newline at end of file