File tree Expand file tree Collapse file tree
src/main/java/org/mangorage/mangobotcore/api/command/v1/argument/types Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org .mangorage .mangobotcore .api .command .v1 .argument .types ;
2+
3+ import org .mangorage .mangobotcore .api .command .v1 .argument .ArgumentParseException ;
4+ import org .mangorage .mangobotcore .api .command .v1 .argument .ArgumentType ;
5+
6+ public final class EnumArgumentType <E extends Enum <E >> extends ArgumentType <E > {
7+ public static <E extends Enum <E >> EnumArgumentType <E > of (Class <E > enumClass ) {
8+ return new EnumArgumentType <>(enumClass );
9+ }
10+
11+ private final Class <E > enumClass ;
12+
13+ private EnumArgumentType (Class <E > enumClass ) {
14+ this .enumClass = enumClass ;
15+ }
16+
17+ @ Override
18+ public E parse (String [] input , int startIndex ) throws ArgumentParseException {
19+ return Enum .valueOf (enumClass , input [startIndex ]);
20+ }
21+
22+ @ Override
23+ public String getString () {
24+ return "" ;
25+ }
26+ }
Original file line number Diff line number Diff line change 44import org .mangorage .mangobotcore .api .command .v1 .argument .ArgumentType ;
55
66public final class IntegerArgumentType extends ArgumentType <Integer > {
7- public static final ArgumentType <Integer > INSTANCE = new IntegerArgumentType ();
8-
97 IntegerArgumentType () {}
108
119 @ Override
You can’t perform that action at this time.
0 commit comments