TomlReadFeature.java
package tools.jackson.dataformat.toml;
import tools.jackson.core.FormatFeature;
/**
* Enumeration that defines all togglable features for TOML parsers.
*/
public enum TomlReadFeature
implements FormatFeature
{
/**
* TOML has special syntax for time types corresponding to {@link java.time.LocalDate}, {@link java.time.LocalTime},
* {@link java.time.LocalDateTime} and {@link java.time.OffsetDateTime}. By default, the TOML parser just returns
* them as strings.
* <p>
* When this option is set, these time types will be parsed to their proper {@code java.time} counterparts and
* appear as {@link tools.jackson.core.JsonToken#VALUE_EMBEDDED_OBJECT} tokens.
*<p>
* Feature is disabled by default.
*/
PARSE_JAVA_TIME(false),
/**
* Whether TOML date/time values should be validated when they are returned as strings.
* <p>
* {@link #PARSE_JAVA_TIME} always validates date/time values while constructing {@code java.time}
* values. This feature only affects the default string representation mode.
* <p>
* Feature is disabled by default.
*
* @since 3.2
*/
VALIDATE_DATE_TIME(false);
private final boolean _defaultState;
private final int _mask;
// Method that calculates bit set (flags) of all features that
// are enabled by default.
public static int collectDefaults()
{
int flags = 0;
for (TomlReadFeature f : values()) {
if (f.enabledByDefault()) {
flags |= f.getMask();
}
}
return flags;
}
private TomlReadFeature(boolean defaultState) {
_defaultState = defaultState;
_mask = (1 << ordinal());
}
@Override
public boolean enabledByDefault() { return _defaultState; }
@Override
public boolean enabledIn(int flags) { return (flags & _mask) != 0; }
@Override
public int getMask() { return _mask; }
}