Skip to content

Commit

Permalink
Merge pull request #1 from numesmat/fix
Browse files Browse the repository at this point in the history
Fix handling methods with annotated parameters and test suite
  • Loading branch information
racc committed Nov 9, 2015
2 parents 5f68ddc + 074cba8 commit 8b9a0d1
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected void configure() {
bindParameters(params);
}

Set<Method> annotatedMethods = reflections.getMethodsAnnotatedWith(TypesafeConfig.class);
Set<Method> annotatedMethods = reflections.getMethodsWithAnyParamAnnotated(TypesafeConfig.class);
for (Method m : annotatedMethods) {
Parameter[] params = m.getParameters();
bindParameters(params);
Expand Down
42 changes: 21 additions & 21 deletions src/test/java/com/github/racc/tscg/TypesafeConfigModuleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,27 @@ protected void configure() {
@Provides
@Singleton
ProvidedPojo providePojo(
@TypesafeConfig("test.boolean") boolean testBoolean,
@TypesafeConfig("test.yesBoolean") boolean testYesBoolean,
@TypesafeConfig("test.long") long testLong,
@TypesafeConfig("test.byte") byte testByte,
@TypesafeConfig("test.int") int testInt,
@TypesafeConfig("test.double") double testDouble,
@TypesafeConfig("test.float") float testFloat,
@TypesafeConfig("test.string") String testString,
@TypesafeConfig("test.list.boolean") List<Boolean> testListOfBoolean,
@TypesafeConfig("test.list.integer") List<Integer> testListOfInteger,
@TypesafeConfig("test.list.double") List<Double> testListOfDouble,
@TypesafeConfig("test.list.long") List<Long> testListOfLong,
@TypesafeConfig("test.list.string") List<String> testListOfString,
@TypesafeConfig("test.list.duration") List<Duration> testListOfDuration,
@TypesafeConfig("test.list.size") List<ConfigMemorySize> testListOfSize,
@TypesafeConfig("test.list.nested") List<NestedPojo> testListOfNested,
@TypesafeConfig("test.duration") Duration testDuration,
@TypesafeConfig("test.size") ConfigMemorySize testSize,
@TypesafeConfig("test.map") Map<String, Integer> testMap,
@TypesafeConfig("test.map.intkey") Map<Integer, String> testMapIntkey,
@TypesafeConfig("test.nested") NestedPojo testNestedPojo
@TypesafeConfig("provided.boolean") boolean testBoolean,
@TypesafeConfig("provided.yesBoolean") boolean testYesBoolean,
@TypesafeConfig("provided.long") long testLong,
@TypesafeConfig("provided.byte") byte testByte,
@TypesafeConfig("provided.int") int testInt,
@TypesafeConfig("provided.double") double testDouble,
@TypesafeConfig("provided.float") float testFloat,
@TypesafeConfig("provided.string") String testString,
@TypesafeConfig("provided.list.boolean") List<Boolean> testListOfBoolean,
@TypesafeConfig("provided.list.integer") List<Integer> testListOfInteger,
@TypesafeConfig("provided.list.double") List<Double> testListOfDouble,
@TypesafeConfig("provided.list.long") List<Long> testListOfLong,
@TypesafeConfig("provided.list.string") List<String> testListOfString,
@TypesafeConfig("provided.list.duration") List<Duration> testListOfDuration,
@TypesafeConfig("provided.list.size") List<ConfigMemorySize> testListOfSize,
@TypesafeConfig("provided.list.nested") List<NestedPojo> testListOfNested,
@TypesafeConfig("provided.duration") Duration testDuration,
@TypesafeConfig("provided.size") ConfigMemorySize testSize,
@TypesafeConfig("provided.map") Map<String, Integer> testMap,
@TypesafeConfig("provided.map.intkey") Map<Integer, String> testMapIntkey,
@TypesafeConfig("provided.nested") NestedPojo testNestedPojo
) {
return new ProvidedPojo(testBoolean, testYesBoolean, testLong, testByte, testInt, testDouble, testFloat, testString, testListOfBoolean, testListOfInteger, testListOfDouble, testListOfLong, testListOfString, testListOfDuration, testListOfSize, testListOfNested, testDuration, testSize, testMap, testMapIntkey, testNestedPojo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,28 @@ public class ConstructorInjectedPojo implements TestPojo {

@Inject
public ConstructorInjectedPojo(
@TypesafeConfig("test.boolean") boolean testBoolean,
@TypesafeConfig("test.boolean") boolean testBooleanAgain,
@TypesafeConfig("test.yesBoolean") boolean testYesBoolean,
@TypesafeConfig("test.long") long testLong,
@TypesafeConfig("test.byte") byte testByte,
@TypesafeConfig("test.int") int testInt,
@TypesafeConfig("test.double") double testDouble,
@TypesafeConfig("test.float") float testFloat,
@TypesafeConfig("test.string") String testString,
@TypesafeConfig("test.list.boolean") List<Boolean> testListOfBoolean,
@TypesafeConfig("test.list.integer") List<Integer> testListOfInteger,
@TypesafeConfig("test.list.double") List<Double> testListOfDouble,
@TypesafeConfig("test.list.long") List<Long> testListOfLong,
@TypesafeConfig("test.list.string") List<String> testListOfString,
@TypesafeConfig("test.list.duration") List<Duration> testListOfDuration,
@TypesafeConfig("test.list.size") List<ConfigMemorySize> testListOfSize,
@TypesafeConfig("test.list.nested") List<NestedPojo> testListOfNested,
@TypesafeConfig("test.duration") Duration testDuration,
@TypesafeConfig("test.size") ConfigMemorySize testSize,
@TypesafeConfig("test.map") Map<String, Integer> testMap,
@TypesafeConfig("test.map.intkey") Map<Integer, String> testMapIntkey,
@TypesafeConfig("test.nested") NestedPojo testNestedPojo
@TypesafeConfig("constructor.boolean") boolean testBoolean,
@TypesafeConfig("constructor.boolean") boolean testBooleanAgain,
@TypesafeConfig("constructor.yesBoolean") boolean testYesBoolean,
@TypesafeConfig("constructor.long") long testLong,
@TypesafeConfig("constructor.byte") byte testByte,
@TypesafeConfig("constructor.int") int testInt,
@TypesafeConfig("constructor.double") double testDouble,
@TypesafeConfig("constructor.float") float testFloat,
@TypesafeConfig("constructor.string") String testString,
@TypesafeConfig("constructor.list.boolean") List<Boolean> testListOfBoolean,
@TypesafeConfig("constructor.list.integer") List<Integer> testListOfInteger,
@TypesafeConfig("constructor.list.double") List<Double> testListOfDouble,
@TypesafeConfig("constructor.list.long") List<Long> testListOfLong,
@TypesafeConfig("constructor.list.string") List<String> testListOfString,
@TypesafeConfig("constructor.list.duration") List<Duration> testListOfDuration,
@TypesafeConfig("constructor.list.size") List<ConfigMemorySize> testListOfSize,
@TypesafeConfig("constructor.list.nested") List<NestedPojo> testListOfNested,
@TypesafeConfig("constructor.duration") Duration testDuration,
@TypesafeConfig("constructor.size") ConfigMemorySize testSize,
@TypesafeConfig("constructor.map") Map<String, Integer> testMap,
@TypesafeConfig("constructor.map.intkey") Map<Integer, String> testMapIntkey,
@TypesafeConfig("constructor.nested") NestedPojo testNestedPojo
) {
this.testBoolean = testBoolean;
this.testYesBoolean = testYesBoolean;
Expand Down
42 changes: 21 additions & 21 deletions src/test/java/com/github/racc/tscg/test/FieldInjectedPojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@
@Singleton
public class FieldInjectedPojo implements TestPojo {

@Inject @TypesafeConfig("test.boolean") boolean testBoolean;
@Inject @TypesafeConfig("test.yesBoolean") boolean testYesBoolean;
@Inject @TypesafeConfig("test.long") long testLong;
@Inject @TypesafeConfig("test.byte") byte testByte;
@Inject @TypesafeConfig("test.int") int testInt;
@Inject @TypesafeConfig("test.double") double testDouble;
@Inject @TypesafeConfig("test.float") float testFloat;
@Inject @TypesafeConfig("test.string") String testString;
@Inject @TypesafeConfig("test.list.boolean") List<Boolean> testListOfBoolean;
@Inject @TypesafeConfig("test.list.integer") List<Integer> testListOfInteger;
@Inject @TypesafeConfig("test.list.double") List<Double> testListOfDouble;
@Inject @TypesafeConfig("test.list.long") List<Long> testListOfLong;
@Inject @TypesafeConfig("test.list.string") List<String> testListOfString;
@Inject @TypesafeConfig("test.list.duration") List<Duration> testListOfDuration;
@Inject @TypesafeConfig("test.list.size") List<ConfigMemorySize> testListOfSize;
@Inject @TypesafeConfig("test.list.nested") List<NestedPojo> testListOfNested;
@Inject @TypesafeConfig("test.duration") Duration testDuration;
@Inject @TypesafeConfig("test.size") ConfigMemorySize testSize;
@Inject @TypesafeConfig("test.map") Map<String, Integer> testMap;
@Inject @TypesafeConfig("test.map.intkey") Map<Integer, String> testMapIntkey;
@Inject @TypesafeConfig("test.nested") NestedPojo testNestedPojo;
@Inject @TypesafeConfig("field.boolean") boolean testBoolean;
@Inject @TypesafeConfig("field.yesBoolean") boolean testYesBoolean;
@Inject @TypesafeConfig("field.long") long testLong;
@Inject @TypesafeConfig("field.byte") byte testByte;
@Inject @TypesafeConfig("field.int") int testInt;
@Inject @TypesafeConfig("field.double") double testDouble;
@Inject @TypesafeConfig("field.float") float testFloat;
@Inject @TypesafeConfig("field.string") String testString;
@Inject @TypesafeConfig("field.list.boolean") List<Boolean> testListOfBoolean;
@Inject @TypesafeConfig("field.list.integer") List<Integer> testListOfInteger;
@Inject @TypesafeConfig("field.list.double") List<Double> testListOfDouble;
@Inject @TypesafeConfig("field.list.long") List<Long> testListOfLong;
@Inject @TypesafeConfig("field.list.string") List<String> testListOfString;
@Inject @TypesafeConfig("field.list.duration") List<Duration> testListOfDuration;
@Inject @TypesafeConfig("field.list.size") List<ConfigMemorySize> testListOfSize;
@Inject @TypesafeConfig("field.list.nested") List<NestedPojo> testListOfNested;
@Inject @TypesafeConfig("field.duration") Duration testDuration;
@Inject @TypesafeConfig("field.size") ConfigMemorySize testSize;
@Inject @TypesafeConfig("field.map") Map<String, Integer> testMap;
@Inject @TypesafeConfig("field.map.intkey") Map<Integer, String> testMapIntkey;
@Inject @TypesafeConfig("field.nested") NestedPojo testNestedPojo;

public void setTestBoolean(boolean testBoolean) {
this.testBoolean = testBoolean;
Expand Down
42 changes: 21 additions & 21 deletions src/test/java/com/github/racc/tscg/test/MethodInjectedPojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,107 +35,107 @@ public class MethodInjectedPojo implements TestPojo {
private NestedPojo testNestedPojo;

@Inject
public void setTestYesBoolean(@TypesafeConfig("test.boolean") boolean testYesBoolean) {
public void setTestYesBoolean(@TypesafeConfig("method.boolean") boolean testYesBoolean) {
this.testYesBoolean = testYesBoolean;
}

@Inject
public void setTestLong(@TypesafeConfig("test.long") long testLong) {
public void setTestLong(@TypesafeConfig("method.long") long testLong) {
this.testLong = testLong;
}

@Inject
public void setTestByte(@TypesafeConfig("test.byte") byte testByte) {
public void setTestByte(@TypesafeConfig("method.byte") byte testByte) {
this.testByte = testByte;
}

@Inject
public void setTestInt(@TypesafeConfig("test.int") int testInt) {
public void setTestInt(@TypesafeConfig("method.int") int testInt) {
this.testInt = testInt;
}

@Inject
public void setTestDouble(@TypesafeConfig("test.double") double testDouble) {
public void setTestDouble(@TypesafeConfig("method.double") double testDouble) {
this.testDouble = testDouble;
}

@Inject
public void setTestFloat(@TypesafeConfig("test.float") float testFloat) {
public void setTestFloat(@TypesafeConfig("method.float") float testFloat) {
this.testFloat = testFloat;
}

@Inject
public void setTestString(@TypesafeConfig("test.string") String testString) {
public void setTestString(@TypesafeConfig("method.string") String testString) {
this.testString = testString;
}

@Inject
public void setTestListOfBoolean(@TypesafeConfig("test.list.boolean") List<Boolean> testListOfBoolean) {
public void setTestListOfBoolean(@TypesafeConfig("method.list.boolean") List<Boolean> testListOfBoolean) {
this.testListOfBoolean = testListOfBoolean;
}

@Inject
public void setTestListOfInteger(@TypesafeConfig("test.list.integer") List<Integer> testListOfInteger) {
public void setTestListOfInteger(@TypesafeConfig("method.list.integer") List<Integer> testListOfInteger) {
this.testListOfInteger = testListOfInteger;
}

@Inject
public void setTestListOfDouble(@TypesafeConfig("test.list.double") List<Double> testListOfDouble) {
public void setTestListOfDouble(@TypesafeConfig("method.list.double") List<Double> testListOfDouble) {
this.testListOfDouble = testListOfDouble;
}

@Inject
public void setTestListOfLong(@TypesafeConfig("test.list.long") List<Long> testListOfLong) {
public void setTestListOfLong(@TypesafeConfig("method.list.long") List<Long> testListOfLong) {
this.testListOfLong = testListOfLong;
}

@Inject
public void setTestListOfString(@TypesafeConfig("test.list.string") List<String> testListOfString) {
public void setTestListOfString(@TypesafeConfig("method.list.string") List<String> testListOfString) {
this.testListOfString = testListOfString;
}

@Inject
public void setTestListOfDuration(@TypesafeConfig("test.list.duration") List<Duration> testListOfDuration) {
public void setTestListOfDuration(@TypesafeConfig("method.list.duration") List<Duration> testListOfDuration) {
this.testListOfDuration = testListOfDuration;
}

@Inject
public void setTestListOfSize(@TypesafeConfig("test.list.size") List<ConfigMemorySize> testListOfSize) {
public void setTestListOfSize(@TypesafeConfig("method.list.size") List<ConfigMemorySize> testListOfSize) {
this.testListOfSize = testListOfSize;
}

@Inject
public void setTestListOfNested(@TypesafeConfig("test.list.nested") List<NestedPojo> testListOfNested) {
public void setTestListOfNested(@TypesafeConfig("method.list.nested") List<NestedPojo> testListOfNested) {
this.testListOfNested = testListOfNested;
}

@Inject
public void setTestDuration(@TypesafeConfig("test.duration") Duration testDuration) {
public void setTestDuration(@TypesafeConfig("method.duration") Duration testDuration) {
this.testDuration = testDuration;
}

@Inject
public void setTestSize(@TypesafeConfig("test.size") ConfigMemorySize testSize) {
public void setTestSize(@TypesafeConfig("method.size") ConfigMemorySize testSize) {
this.testSize = testSize;
}

@Inject
public void setTestMap(@TypesafeConfig("test.map") Map<String, Integer> testMap) {
public void setTestMap(@TypesafeConfig("method.map") Map<String, Integer> testMap) {
this.testMap = testMap;
}

@Inject
public void setTestMapIntkey(@TypesafeConfig("test.map.intkey") Map<Integer, String> testMapIntkey) {
public void setTestMapIntkey(@TypesafeConfig("method.map.intkey") Map<Integer, String> testMapIntkey) {
this.testMapIntkey = testMapIntkey;
}

@Inject
public void setTestNestedPojo(@TypesafeConfig("test.nested") NestedPojo testNestedPojo) {
public void setTestNestedPojo(@TypesafeConfig("method.nested") NestedPojo testNestedPojo) {
this.testNestedPojo = testNestedPojo;
}

@Inject
public void setTestBoolean(@TypesafeConfig("test.yesBoolean") boolean testBoolean) {
public void setTestBoolean(@TypesafeConfig("method.yesBoolean") boolean testBoolean) {
this.testBoolean = testBoolean;
}

Expand Down
7 changes: 6 additions & 1 deletion src/test/resources/conf/test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@ test.list.nested = [
nestDouble = 6
nestString = "seven"
}
]
]

provided = ${test}
constructor = ${test}
field = ${test}
method = ${test}

0 comments on commit 8b9a0d1

Please sign in to comment.