Skip to content

Commit e15ee57

Browse files
committed
Added Enum ArgumentType
1 parent 1104fa3 commit e15ee57

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
}

src/main/java/org/mangorage/mangobotcore/api/command/v1/argument/types/IntegerArgumentType.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import org.mangorage.mangobotcore.api.command.v1.argument.ArgumentType;
55

66
public final class IntegerArgumentType extends ArgumentType<Integer> {
7-
public static final ArgumentType<Integer> INSTANCE = new IntegerArgumentType();
8-
97
IntegerArgumentType() {}
108

119
@Override

0 commit comments

Comments
 (0)