mirror of
https://github.com/plexusorg/toml4j.git
synced 2024-06-26 07:50:46 +00:00
31 lines
758 B
Java
31 lines
758 B
Java
package com.moandjiezana.toml;
|
|
|
|
import static com.moandjiezana.toml.ValueConverterUtils.INVALID;
|
|
import static com.moandjiezana.toml.ValueConverterUtils.parse;
|
|
import static com.moandjiezana.toml.ValueConverterUtils.parser;
|
|
|
|
import java.util.List;
|
|
|
|
class BooleanConverter implements ValueConverter {
|
|
|
|
static final BooleanConverter BOOLEAN_PARSER = new BooleanConverter();
|
|
|
|
@Override
|
|
public boolean canConvert(String s) {
|
|
return s.startsWith("true") || s.startsWith("false");
|
|
}
|
|
|
|
@Override
|
|
public Object convert(String s) {
|
|
List<String> resultValue = parse(parser().Boolean(), s);
|
|
|
|
if (resultValue == null) {
|
|
return INVALID;
|
|
}
|
|
|
|
return Boolean.valueOf(resultValue.get(0));
|
|
}
|
|
|
|
private BooleanConverter() {}
|
|
}
|