-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Extra annotation for primitive types and String
- Loading branch information
1 parent
c9fe61b
commit 4542f4a
Showing
45 changed files
with
1,832 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
onactivityresult-annotations/src/main/java/onactivityresult/ExtraBoolean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package onactivityresult; | ||
|
||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.RetentionPolicy.CLASS; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* parameters of a {@link OnActivityResult} annotated method can be annotated to get a boolean extra of the intent<br> | ||
* Example:<br> | ||
* <p> | ||
* <code> | ||
* @OnActivityResult(requestCode = 1) | ||
* void onResult(@ExtraBoolean final boolean extraBoolean) { | ||
* // Do something | ||
* } | ||
* </code> | ||
* </p> | ||
* <br> | ||
* defaultValue: false<br> | ||
* extra name: same as parameter <br> | ||
* NOTE: In this case it would be extraBoolean<br> | ||
* | ||
* @since 0.3.0 | ||
*/ | ||
@Retention(CLASS) | ||
@Target(PARAMETER) | ||
public @interface ExtraBoolean {} |
29 changes: 29 additions & 0 deletions
29
onactivityresult-annotations/src/main/java/onactivityresult/ExtraByte.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package onactivityresult; | ||
|
||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.RetentionPolicy.CLASS; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* parameters of a {@link OnActivityResult} annotated method can be annotated to get a byte extra of the intent<br> | ||
* Example:<br> | ||
* <p> | ||
* <code> | ||
* @OnActivityResult(requestCode = 1) | ||
* void onResult(@ExtraByte final byte extraByte) { | ||
* // Do something | ||
* } | ||
* </code> | ||
* </p> | ||
* <br> | ||
* defaultValue: 0<br> | ||
* extra name: same as parameter <br> | ||
* NOTE: In this case it would be extraByte<br> | ||
* | ||
* @since 0.3.0 | ||
*/ | ||
@Retention(CLASS) | ||
@Target(PARAMETER) | ||
public @interface ExtraByte {} |
29 changes: 29 additions & 0 deletions
29
onactivityresult-annotations/src/main/java/onactivityresult/ExtraChar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package onactivityresult; | ||
|
||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.RetentionPolicy.CLASS; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* parameters of a {@link OnActivityResult} annotated method can be annotated to get a char extra of the intent<br> | ||
* Example:<br> | ||
* <p> | ||
* <code> | ||
* @OnActivityResult(requestCode = 1) | ||
* void onResult(@ExtraChar final char extraChar) { | ||
* // Do something | ||
* } | ||
* </code> | ||
* </p> | ||
* <br> | ||
* defaultValue: 0<br> | ||
* extra name: same as parameter <br> | ||
* NOTE: In this case it would be extraChar<br> | ||
* | ||
* @since 0.3.0 | ||
*/ | ||
@Retention(CLASS) | ||
@Target(PARAMETER) | ||
public @interface ExtraChar {} |
29 changes: 29 additions & 0 deletions
29
onactivityresult-annotations/src/main/java/onactivityresult/ExtraDouble.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package onactivityresult; | ||
|
||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.RetentionPolicy.CLASS; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* parameters of a {@link OnActivityResult} annotated method can be annotated to get a double extra of the intent<br> | ||
* Example:<br> | ||
* <p> | ||
* <code> | ||
* @OnActivityResult(requestCode = 1) | ||
* void onResult(@ExtraDouble final double extraDouble) { | ||
* // Do something | ||
* } | ||
* </code> | ||
* </p> | ||
* <br> | ||
* defaultValue: 0d<br> | ||
* extra name: same as parameter <br> | ||
* NOTE: In this case it would be extraDouble<br> | ||
* | ||
* @since 0.3.0 | ||
*/ | ||
@Retention(CLASS) | ||
@Target(PARAMETER) | ||
public @interface ExtraDouble {} |
29 changes: 29 additions & 0 deletions
29
onactivityresult-annotations/src/main/java/onactivityresult/ExtraFloat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package onactivityresult; | ||
|
||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.RetentionPolicy.CLASS; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* parameters of a {@link OnActivityResult} annotated method can be annotated to get a float extra of the intent<br> | ||
* Example:<br> | ||
* <p> | ||
* <code> | ||
* @OnActivityResult(requestCode = 1) | ||
* void onResult(@ExtraFloat final float extraFloat) { | ||
* // Do something | ||
* } | ||
* </code> | ||
* </p> | ||
* <br> | ||
* defaultValue: 0.f<br> | ||
* extra name: same as parameter <br> | ||
* NOTE: In this case it would be extraFloat<br> | ||
* | ||
* @since 0.3.0 | ||
*/ | ||
@Retention(CLASS) | ||
@Target(PARAMETER) | ||
public @interface ExtraFloat {} |
29 changes: 29 additions & 0 deletions
29
onactivityresult-annotations/src/main/java/onactivityresult/ExtraInt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package onactivityresult; | ||
|
||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.RetentionPolicy.CLASS; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* parameters of a {@link OnActivityResult} annotated method can be annotated to get an int extra of the intent<br> | ||
* Example:<br> | ||
* <p> | ||
* <code> | ||
* @OnActivityResult(requestCode = 1) | ||
* void onResult(@ExtraInt final int extraInt) { | ||
* // Do something | ||
* } | ||
* </code> | ||
* </p> | ||
* <br> | ||
* defaultValue: 0<br> | ||
* extra name: same as parameter <br> | ||
* NOTE: In this case it would be extraInt<br> | ||
* | ||
* @since 0.3.0 | ||
*/ | ||
@Retention(CLASS) | ||
@Target(PARAMETER) | ||
public @interface ExtraInt {} |
29 changes: 29 additions & 0 deletions
29
onactivityresult-annotations/src/main/java/onactivityresult/ExtraLong.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package onactivityresult; | ||
|
||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.RetentionPolicy.CLASS; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* parameters of a {@link OnActivityResult} annotated method can be annotated to get a long extra of the intent<br> | ||
* Example:<br> | ||
* <p> | ||
* <code> | ||
* @OnActivityResult(requestCode = 1) | ||
* void onResult(@ExtraLong final long extraLong) { | ||
* // Do something | ||
* } | ||
* </code> | ||
* </p> | ||
* <br> | ||
* defaultValue: 0L<br> | ||
* extra name: same as parameter <br> | ||
* NOTE: In this case it would be extraLong<br> | ||
* | ||
* @since 0.3.0 | ||
*/ | ||
@Retention(CLASS) | ||
@Target(PARAMETER) | ||
public @interface ExtraLong {} |
29 changes: 29 additions & 0 deletions
29
onactivityresult-annotations/src/main/java/onactivityresult/ExtraShort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package onactivityresult; | ||
|
||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.RetentionPolicy.CLASS; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* parameters of a {@link OnActivityResult} annotated method can be annotated to get a short extra of the intent<br> | ||
* Example:<br> | ||
* <p> | ||
* <code> | ||
* @OnActivityResult(requestCode = 1) | ||
* void onResult(@ExtraShort final short extraShort) { | ||
* // Do something | ||
* } | ||
* </code> | ||
* </p> | ||
* <br> | ||
* defaultValue: 0<br> | ||
* extra name: same as parameter <br> | ||
* NOTE: In this case it would be extraShort<br> | ||
* | ||
* @since 0.3.0 | ||
*/ | ||
@Retention(CLASS) | ||
@Target(PARAMETER) | ||
public @interface ExtraShort {} |
29 changes: 29 additions & 0 deletions
29
onactivityresult-annotations/src/main/java/onactivityresult/ExtraString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package onactivityresult; | ||
|
||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.RetentionPolicy.CLASS; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* parameters of a {@link OnActivityResult} annotated method can be annotated to get a String extra of the intent<br> | ||
* Example:<br> | ||
* <p> | ||
* <code> | ||
* @OnActivityResult(requestCode = 1) | ||
* void onResult(@ExtraString final String extraString) { | ||
* // Do something | ||
* } | ||
* </code> | ||
* </p> | ||
* <br> | ||
* defaultValue: null<br> | ||
* extra name: same as parameter <br> | ||
* NOTE: In this case it would be extraString<br> | ||
* | ||
* @since 0.3.0 | ||
*/ | ||
@Retention(CLASS) | ||
@Target(PARAMETER) | ||
public @interface ExtraString {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
onactivityresult-annotations/src/test/java/onactivityresult/ExtraBooleanTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package onactivityresult; | ||
|
||
import static org.junit.Assert.assertArrayEquals; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import org.junit.Test; | ||
|
||
public class ExtraBooleanTest { | ||
@Test | ||
public void testAnnotationRetention() { | ||
final Retention retention = ExtraBoolean.class.getAnnotation(Retention.class); | ||
assertEquals(RetentionPolicy.CLASS, retention.value()); | ||
} | ||
|
||
@Test | ||
public void testAnnotationTarget() { | ||
final Target retention = ExtraBoolean.class.getAnnotation(Target.class); | ||
final ElementType[] elementTypes = retention.value(); | ||
assertArrayEquals(new ElementType[] { ElementType.PARAMETER }, elementTypes); | ||
} | ||
} |
Oops, something went wrong.