parcelableList;
+
+ @com.hannesdorfmann.fragmentargs.annotation.Arg
+ ArrayList parcelableList, P privateParcelableGeneric, S privateSerializableGeneric, S serializable, java.util.ArrayList parcelableList, P privateParcelableGeneric, S privateSerializableGeneric, S serializable, java.util.ArrayList serializableList;
+
+ @com.hannesdorfmann.fragmentargs.annotation.Arg
+ PS generic;
+
+ @com.hannesdorfmann.fragmentargs.annotation.Arg
+ P parcelable;
+
+ @com.hannesdorfmann.fragmentargs.annotation.Arg(required = false)
+ P optionalParcelable;
+
+ @com.hannesdorfmann.fragmentargs.annotation.Arg
+ S serializable;
+
+ @com.hannesdorfmann.fragmentargs.annotation.Arg(required = false)
+ S optionalSerializable;
+
+ @com.hannesdorfmann.fragmentargs.annotation.Arg
+ private S privateSerializableGeneric;
+
+ @com.hannesdorfmann.fragmentargs.annotation.Arg
+ private P privateParcelableGeneric;
+
+ public void setPrivateSerializableGeneric(S privateSerializableGeneric) {
+ this.privateSerializableGeneric = privateSerializableGeneric;
+ }
+
+ public void setPrivateParcelableGeneric(P privateParcelableGeneric) {
+ this.privateParcelableGeneric = privateParcelableGeneric;
+ }
+
+}
\ No newline at end of file
diff --git a/processor/src/test/resources/ClassWithGenericsBuilder.java b/processor/src/test/resources/ClassWithGenericsBuilder.java
new file mode 100644
index 0000000..ae0758d
--- /dev/null
+++ b/processor/src/test/resources/ClassWithGenericsBuilder.java
@@ -0,0 +1,114 @@
+package com.hannesdorfmann.fragmentargstest.test;
+
+import android.os.Bundle;
+
+public final class ClassWithGenericsBuilder serializableList) {
+
+ mArguments.putParcelable("generic", generic);
+
+ mArguments.putParcelableArrayList("genericList", genericList);
+
+ mArguments.putParcelable("parcelable", parcelable);
+
+ mArguments.putParcelableArrayList("parcelableList", parcelableList);
+
+ mArguments.putParcelable("privateParcelableGeneric", privateParcelableGeneric);
+
+ mArguments.putSerializable("privateSerializableGeneric", privateSerializableGeneric);
+
+ mArguments.putSerializable("serializable", serializable);
+
+ mArguments.putSerializable("serializableList", serializableList);
+ }
+
+ public static serializableList) {
+ return new ClassWithGenericsBuilder(generic, genericList, parcelable, parcelableList, privateParcelableGeneric, privateSerializableGeneric, serializable, serializableList).build();
+ }
+
+ public ClassWithGenericsBuilder optionalParcelable(P optionalParcelable) {
+
+ if (optionalParcelable != null) {
+ mArguments.putParcelable("optionalParcelable", optionalParcelable);
+ }
+ return this;
+ }
+
+ public ClassWithGenericsBuilder optionalSerializable(S optionalSerializable) {
+
+ if (optionalSerializable != null) {
+ mArguments.putSerializable("optionalSerializable", optionalSerializable);
+ }
+ return this;
+ }
+
+ public Bundle buildBundle() {
+ return new Bundle(mArguments);
+ }
+
+ public static final ) args.getSerializable("serializableList");
+
+ if (args != null && args.containsKey("optionalSerializable")) {
+ fragment.optionalSerializable = (S) args.getSerializable("optionalSerializable");
+ }
+ }
+
+ public ClassWithGenerics build() {
+ ClassWithGenerics fragment = new ClassWithGenerics();
+ fragment.setArguments(mArguments);
+ return fragment;
+ }
+}
\ No newline at end of file
diff --git a/processor/src/test/resources/ClassWithInnerClassBuilder.java b/processor/src/test/resources/ClassWithInnerClass$$InnerClassBuilder.java
similarity index 61%
rename from processor/src/test/resources/ClassWithInnerClassBuilder.java
rename to processor/src/test/resources/ClassWithInnerClass$$InnerClassBuilder.java
index 5ed54d0..dc645ee 100644
--- a/processor/src/test/resources/ClassWithInnerClassBuilder.java
+++ b/processor/src/test/resources/ClassWithInnerClass$$InnerClassBuilder.java
@@ -1,25 +1,26 @@
package com.hannesdorfmann.fragmentargs.processor.test;
import android.os.Bundle;
+import com.hannesdorfmann.fragmentargs.processor.test.ClassWithInnerClass.InnerClass;
-public final class ClassWithInnerClassBuilder {
+public final class ClassWithInnerClass$$InnerClassBuilder {
private final Bundle mArguments = new Bundle();
- public ClassWithInnerClassBuilder(String arg) {
+ public ClassWithInnerClass$$InnerClassBuilder(String arg) {
mArguments.putString("arg", arg);
}
- public static ClassWithInnerClass newClassWithInnerClass(String arg) {
- return new ClassWithInnerClassBuilder(arg).build();
+ public static InnerClass newInnerClass(String arg) {
+ return new ClassWithInnerClass$$InnerClassBuilder(arg).build();
}
public Bundle buildBundle() {
return new Bundle(mArguments);
}
- public static final void injectArguments(ClassWithInnerClass fragment) {
+ public static final void injectArguments(InnerClass fragment) {
Bundle args = fragment.getArguments();
if (args == null) {
throw new IllegalStateException("No arguments set. Have you set up this Fragment with the corresponding FragmentArgs Builder? ");
@@ -31,8 +32,8 @@ public static final void injectArguments(ClassWithInnerClass fragment) {
fragment.arg = args.getString("arg");
}
- public ClassWithInnerClass build() {
- ClassWithInnerClass fragment = new ClassWithInnerClass();
+ public InnerClass build() {
+ InnerClass fragment = new InnerClass();
fragment.setArguments(mArguments);
return fragment;
}
diff --git a/processor/src/test/resources/ClassWithInnerClass.java b/processor/src/test/resources/ClassWithInnerClass.java
index 800b84c..a132b7c 100644
--- a/processor/src/test/resources/ClassWithInnerClass.java
+++ b/processor/src/test/resources/ClassWithInnerClass.java
@@ -1,11 +1,7 @@
package com.hannesdorfmann.fragmentargs.processor.test;
-@com.hannesdorfmann.fragmentargs.annotation.FragmentWithArgs
public class ClassWithInnerClass extends android.app.Fragment {
- @com.hannesdorfmann.fragmentargs.annotation.Arg
- String arg;
-
@com.hannesdorfmann.fragmentargs.annotation.FragmentWithArgs
public static class InnerClass extends android.app.Fragment {
diff --git a/processor/src/test/resources/ClassWithProtectedFieldBuilder.java b/processor/src/test/resources/ClassWithProtectedFieldBuilder.java
new file mode 100644
index 0000000..2c652a7
--- /dev/null
+++ b/processor/src/test/resources/ClassWithProtectedFieldBuilder.java
@@ -0,0 +1,39 @@
+package com.hannesdorfmann.fragmentargs.processor.test;
+
+import android.os.Bundle;
+
+public final class ClassWithProtectedFieldBuilder {
+
+ private final Bundle mArguments = new Bundle();
+
+ public ClassWithProtectedFieldBuilder(String protectedArg) {
+
+ mArguments.putString("protectedArg", protectedArg);
+ }
+
+ public static ClassWithProtectedField newClassWithProtectedField(String protectedArg) {
+ return new ClassWithProtectedFieldBuilder(protectedArg).build();
+ }
+
+ public Bundle buildBundle() {
+ return new Bundle(mArguments);
+ }
+
+ public static final void injectArguments(ClassWithProtectedField fragment) {
+ Bundle args = fragment.getArguments();
+ if (args == null) {
+ throw new IllegalStateException("No arguments set. Have you set up this Fragment with the corresponding FragmentArgs Builder? ");
+ }
+
+ if (!args.containsKey("protectedArg")) {
+ throw new IllegalStateException("required argument protectedArg is not set");
+ }
+ fragment.protectedArg = args.getString("protectedArg");
+ }
+
+ public ClassWithProtectedField build() {
+ ClassWithProtectedField fragment = new ClassWithProtectedField();
+ fragment.setArguments(mArguments);
+ return fragment;
+ }
+}
\ No newline at end of file
diff --git a/processor/src/test/resources/ClassWithProtectedSetterBuilder.java b/processor/src/test/resources/ClassWithProtectedSetterBuilder.java
new file mode 100644
index 0000000..07a0fd8
--- /dev/null
+++ b/processor/src/test/resources/ClassWithProtectedSetterBuilder.java
@@ -0,0 +1,40 @@
+package com.hannesdorfmann.fragmentargs.processor.test;
+
+import android.os.Bundle;
+
+public final class ClassWithProtectedSetterBuilder {
+
+ private final Bundle mArguments = new Bundle();
+
+ public ClassWithProtectedSetterBuilder(String privateArg) {
+
+ mArguments.putString("privateArg", privateArg);
+ }
+
+ public static ClassWithProtectedSetter newClassWithProtectedSetter(String privateArg) {
+ return new ClassWithProtectedSetterBuilder(privateArg).build();
+ }
+
+ public Bundle buildBundle() {
+ return new Bundle(mArguments);
+ }
+
+ public static final void injectArguments(ClassWithProtectedSetter fragment) {
+ Bundle args = fragment.getArguments();
+ if (args == null) {
+ throw new IllegalStateException("No arguments set. Have you set up this Fragment with the corresponding FragmentArgs Builder? ");
+ }
+
+ if (!args.containsKey("privateArg")) {
+ throw new IllegalStateException("required argument privateArg is not set");
+ }
+ java.lang.String value0 = args.getString("privateArg");
+ fragment.setPrivateArg(value0);
+ }
+
+ public ClassWithProtectedSetter build() {
+ ClassWithProtectedSetter fragment = new ClassWithProtectedSetter();
+ fragment.setArguments(mArguments);
+ return fragment;
+ }
+}
\ No newline at end of file