fix enum index out of range error (#106)

Signed-off-by: birdstorm <samuelwyf@hotmail.com>
This commit is contained in:
birdstorm 2021-01-11 10:46:30 +08:00 committed by GitHub
parent a0229f56aa
commit 07e9040130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -723,6 +723,9 @@ public class Codec {
}
public static String readEnumFromIndex(int idx, List<String> elems) {
if (idx == 0) {
return "";
}
if (idx < 0 || idx >= elems.size()) throw new TypeException("Index is out of range");
return elems.get(idx);
}