-
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.
Merge pull request #4 from networkers-studio/typereference
feat: use java Type and drop guava dependency + create MatchingMap
- Loading branch information
Showing
50 changed files
with
959 additions
and
764 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
extensions/rimor-params/src/main/java/st/networkers/rimor/params/InstructionParam.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,39 @@ | ||
package st.networkers.rimor.params; | ||
|
||
import st.networkers.rimor.params.parse.InstructionParamParser; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Method parameters with this annotation are injected with the corresponding command parameter. | ||
* | ||
* <p>If the index of the command parameter is not manually specified in this annotation, it is automatically | ||
* detected by the position of this parameter relative to all the method's {@code @Param}-annotated parameters. | ||
* | ||
* <p>The injected object will be {@code null} if the index is greater than the command parameter size. | ||
* | ||
* <p>If the type of the method parameter matches the type of the command parameter, it is directly injected. Also, | ||
* the object can be parsed and injected into, for example, a Boolean or Enum parameter, following the registered {@link InstructionParamParser}s. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.PARAMETER) | ||
public @interface InstructionParam { | ||
|
||
/** | ||
* The name of the parameter. | ||
*/ | ||
String value() default ""; | ||
|
||
/** | ||
* The description of the parameter. | ||
*/ | ||
String description() default ""; | ||
|
||
/** | ||
* The index of this parameter, or -1 to automatically detect by the method's parameter order. | ||
*/ | ||
int index() default -1; | ||
} |
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
40 changes: 0 additions & 40 deletions
40
extensions/rimor-params/src/main/java/st/networkers/rimor/params/Param.java
This file was deleted.
Oops, something went wrong.
16 changes: 8 additions & 8 deletions
16
extensions/rimor-params/src/main/java/st/networkers/rimor/params/ParamsExtension.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
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
25 changes: 25 additions & 0 deletions
25
...s/rimor-params/src/main/java/st/networkers/rimor/params/parse/InstructionParamParser.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 st.networkers.rimor.params.parse; | ||
|
||
import st.networkers.rimor.context.ExecutionContext; | ||
import st.networkers.rimor.inject.Token; | ||
import st.networkers.rimor.params.InstructionParams; | ||
import st.networkers.rimor.params.parse.builtin.BooleanInstructionParamParser; | ||
import st.networkers.rimor.params.parse.builtin.DefaultInstructionParamParser; | ||
import st.networkers.rimor.params.parse.builtin.EnumInstructionParamParser; | ||
import st.networkers.rimor.params.parse.builtin.StringInstructionParamParser; | ||
import st.networkers.rimor.provide.RimorProvider; | ||
|
||
/** | ||
* Abstract class for providers that just parse an element from the {@link InstructionParams}-annotated lists. | ||
* | ||
* @see AbstractInstructionParamParser | ||
* @see BooleanInstructionParamParser | ||
* @see DefaultInstructionParamParser | ||
* @see EnumInstructionParamParser | ||
* @see StringInstructionParamParser | ||
*/ | ||
public interface InstructionParamParser<T> extends RimorProvider<T> { | ||
|
||
T parse(Object parameter, Token<T> token, ExecutionContext context); | ||
|
||
} |
23 changes: 0 additions & 23 deletions
23
extensions/rimor-params/src/main/java/st/networkers/rimor/params/parse/ParamParser.java
This file was deleted.
Oops, something went wrong.
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
20 changes: 20 additions & 0 deletions
20
...src/main/java/st/networkers/rimor/params/parse/builtin/DefaultInstructionParamParser.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,20 @@ | ||
package st.networkers.rimor.params.parse.builtin; | ||
|
||
import st.networkers.rimor.context.ExecutionContext; | ||
import st.networkers.rimor.inject.Token; | ||
import st.networkers.rimor.params.parse.AbstractInstructionParamParser; | ||
|
||
/** | ||
* Built-in basic param parser. | ||
*/ | ||
public class DefaultInstructionParamParser extends AbstractInstructionParamParser<Object> { | ||
|
||
public DefaultInstructionParamParser() { | ||
super(Object.class); | ||
} | ||
|
||
@Override | ||
public Object parse(Object parameter, Token<Object> token, ExecutionContext context) { | ||
return parameter; | ||
} | ||
} |
30 changes: 0 additions & 30 deletions
30
...mor-params/src/main/java/st/networkers/rimor/params/parse/builtin/DefaultParamParser.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.