Class StringToStringJsonParser
java.lang.Object
org.woftnw.eof.io.parse.common.string.StringJsonParser<String>
org.woftnw.eof.io.parse.common.string.StringToStringJsonParser
- All Implemented Interfaces:
JsonParser<String>
- Direct Known Subclasses:
HexCodeJsonParser, NaturalCaseJsonParser, SnakeCaseJsonParser
Parses a JSON string in some way.
-
Field Summary
Fields inherited from class StringJsonParser
ALL_OF_PATTERNS, ANY_OF_PATTERNS, DEFAULT_MAX_LENGTH, DEFAULT_MIN_LENGTH, MAX_LENGTH, MIN_LENGTH -
Constructor Summary
ConstructorsConstructorDescriptionStringToStringJsonParser(int minLength, int maxLength, String pattern) Create a StringToStringJsonParser with the default minimum and maximum lengths.StringToStringJsonParser(int minLength, int maxLength, String[] anyOfPatterns, String[] allOfPatterns) Create a StringToStringJsonParser.StringToStringJsonParser(String pattern) Create a StringJsonParser with the default minimum and maximum lengths.StringToStringJsonParser(String[] anyOfPatterns, String[] allOfPatterns) Create a StringToStringJsonParser with the default minimum and maximum lengths. -
Method Summary
Modifier and TypeMethodDescriptionparse(@NonNull com.google.gson.JsonElement element, ElytrasOfFire plugin) Parse a JSON string.
-
Constructor Details
-
StringToStringJsonParser
public StringToStringJsonParser(int minLength, int maxLength, String[] anyOfPatterns, String[] allOfPatterns) Create a StringToStringJsonParser.- Parameters:
minLength- The minimum string length.maxLength- The maximum string length.anyOfPatterns- The patterns that a given string must match one of. If this is an empty array, none will be needed.allOfPatterns- The patterns that a given string must match all of.
-
StringToStringJsonParser
Create a StringToStringJsonParser with the default minimum and maximum lengths.- Parameters:
minLength- The minimum string length.maxLength- The maximum string length.pattern- The pattern that a given string must match.
-
StringToStringJsonParser
Create a StringJsonParser with the default minimum and maximum lengths.- Parameters:
pattern- The pattern that a given string must match.
-
StringToStringJsonParser
Create a StringToStringJsonParser with the default minimum and maximum lengths.- Parameters:
anyOfPatterns- The patterns that a given string must match one of. If this is an empty array, none will be needed.allOfPatterns- The patterns that a given string must match all of.
-
-
Method Details
-
parse
public String parse(@NonNull com.google.gson.JsonElement element, ElytrasOfFire plugin) throws EoFJsonParseException Parse a JSON string.- Parameters:
element- The element to parse and validate.plugin- The Elytras of Fire plugin instance.- Returns:
- The resulting string.
- Throws:
EoFStringLengthJsonParseException- Thrown if the string is empty.EoFStringPatternJsonParseException- Thrown if the string is not natural-case.EoFJsonParseException- If something goes wrong while parsing or validating.
-