30 lines
602 B
Java
30 lines
602 B
Java
|
package pm.j4.petroleum.modules.base.option;
|
||
|
|
||
|
import pm.j4.petroleum.modules.base.StringWritable;
|
||
|
|
||
|
/**
|
||
|
* The type Option type matcher.
|
||
|
*/
|
||
|
public class OptionTypeMatcher {
|
||
|
/**
|
||
|
* Match string writable.
|
||
|
*
|
||
|
* @param type the type
|
||
|
* @param value the value
|
||
|
* @return the string writable
|
||
|
*/
|
||
|
public static StringWritable match(String type, String value) {
|
||
|
if (type == null || type.isEmpty()) {
|
||
|
return new DummyValue();
|
||
|
}
|
||
|
switch (type) {
|
||
|
case "I":
|
||
|
return new IntegerValue(value);
|
||
|
case "B":
|
||
|
return new BooleanValue(value);
|
||
|
default:
|
||
|
return new DummyValue();
|
||
|
}
|
||
|
}
|
||
|
}
|