-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more options for parameter injection (#38)
* feat: Add much more options for providing parameters * test: Refactor and add tests * feat: Split Params into multi injection and map injection * test: Update tests * fix: Remove debug prints * fix: Incorrect notnull order * feat: Make error more precise * feat: Remove default value option from Params.java * feat: Remove unneeded access check * fix: Rename variable * cleanup: Remove unused imports * docs: Describe new behavior in readme * docs: Add special cases * docs: Add comment to isMapWithTypes methods * feat: Use different (un)wrapping method * feat: Clear map before putting values when final
- Loading branch information
Showing
33 changed files
with
567 additions
and
152 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
16 changes: 13 additions & 3 deletions
16
framework/src/main/java/org/fulib/fx/annotation/param/Param.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
18 changes: 13 additions & 5 deletions
18
framework/src/main/java/org/fulib/fx/annotation/param/Params.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 |
---|---|---|
@@ -1,17 +1,25 @@ | ||
package org.fulib.fx.annotation.param; | ||
|
||
import org.fulib.fx.controller.Router; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import java.util.Map; | ||
|
||
/** | ||
* Annotation used to mark controller parameters in which the {@link Router} should inject the parameter map. | ||
* Used by the {@link Router} to inject parameters into controllers. | ||
* Methods annotated with this annotation will be called with the values of the specified parameters when using the {@link org.fulib.fx.FulibFxApp#show(String, Map)} method. | ||
* <p> | ||
* Order is important, the order of the parameters in the annotation has to match the order of the parameters in the method. | ||
*/ | ||
@Target({ElementType.PARAMETER, ElementType.FIELD}) | ||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Params { | ||
|
||
/** | ||
* The names of the parameter which should be injected. | ||
* | ||
* @return The name of the parameter. | ||
*/ | ||
String[] value(); | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
framework/src/main/java/org/fulib/fx/annotation/param/ParamsMap.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,25 @@ | ||
package org.fulib.fx.annotation.param; | ||
|
||
import org.fulib.fx.annotation.event.onInit; | ||
import org.fulib.fx.annotation.event.onRender; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import java.util.Map; | ||
|
||
/** | ||
* Fields, parameters and methods annotated with this annotation will be injected with a map of all parameters when using the {@link org.fulib.fx.FulibFxApp#show(String, Map)} method. | ||
* <p> | ||
* If the annotation is used on a field, the field will be injected with the parameter map. | ||
* <p> | ||
* If the annotation is used on a method, the method will be called with the parameter map as an argument. | ||
* <p> | ||
* If the annotation is used on a method argument, the argument will be injected with the parameter map (method has to be annotated with {@link onRender} or {@link onInit}). | ||
*/ | ||
@Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface ParamsMap { | ||
|
||
} |
Oops, something went wrong.