20 package net.sf.gridarta.model.filter;
22 import org.jetbrains.annotations.NotNull;
23 import org.jetbrains.annotations.Nullable;
35 private final StringBuilder
sb =
new StringBuilder();
47 filterConfig.getFilter().resetConfig(filterConfig);
50 filterConfig.setEnabled(enabled);
51 boolean first = !enabled;
53 final boolean inverted;
62 filterConfig.setInverted(inverted);
65 if (sb.length() == 0 || sb.charAt(0) ==
')') {
77 if (subFilterConfig == null) {
78 throw new NumberFormatException(
"filter has no key '" + key +
"'");
81 throw new NumberFormatException(
"syntax error");
92 filterConfig.setEnabled(enabled);
93 boolean first = !enabled;
96 if (sb.length() == 0 || sb.charAt(0) ==
')') {
103 throw new NumberFormatException(
"syntax error");
108 throw new NumberFormatException(
"syntax error");
125 filterConfig.setEnabled(
false);
126 filterConfig.setInverted(
false);
127 filterConfig.getFilter().resetConfig(filterConfig);
128 filterConfig.getEntries().values().forEach(entry -> entry.accept(resetToDefaultsVisitor));
133 filterConfig.setEnabled(
false);
134 filterConfig.removeAllProperties();
158 }
catch (
final IndexOutOfBoundsException | NumberFormatException ignored) {
161 return sb.length() == 0;
172 filterConfig.
accept(resetToDefaultsVisitor);
176 filterConfig.
accept(visitor);
178 throw new NumberFormatException(
"syntax error");
181 this.filterConfig = prevFilterConfig;
191 final int length =
string.length();
192 if (length > sb.length() || !sb.substring(0, length).equals(
string)) {
196 sb.delete(0, length);
final FilterConfigVisitor visitor
The FilterConfigVisitor for updating filterConfig from the string representation in sb...
final StringBuilder sb
The string being decoded.
FilterConfig<?, ?> filterConfig
The FilterConfig instance being updated.
boolean decode(@NotNull final String string, @NotNull final FilterConfig<?, ?> filterConfig)
Import the filter configuration settings.
Utility class for codec related functions.
boolean removePrefix(@NotNull final String string)
Tries to remove a prefix from sb.
void accept(@NotNull FilterConfigVisitor visitor)
Visits the appropriate.
static String decodeString(@NotNull final StringBuilder sb)
Decodes a string from a string builder.
Interface for visitors of filter configs.
void decodeInternal(@NotNull final FilterConfig<?, ?> filterConfig)
Updates a file configuration from sb.
Filter configuration of NamedGameObjectMatcherFilter instances.
Converts a string into a FilterConfig.
final FilterConfigVisitor resetToDefaultsVisitor
The FilterConfigVisitor which resets a filterConfig instance to default settings. ...
A FilterConfig that has a name.