@@ -85,8 +85,8 @@ public List<EntryData<?>> getEntryData() {
85
85
while (iterator .hasNext ()) {
86
86
EntryData <?> data = iterator .next ();
87
87
if (data .canCreateWith (node )) { // Determine if it's a match
88
- if (data instanceof EntryValidatorBuilder subValidator ) {
89
- if (!subValidator .validate ((SectionNode ) node )) {
88
+ if (data instanceof SubContainerEntryData subContainer ) {
89
+ if (!subContainer .validate ((SectionNode ) node )) {
90
90
ok = false ;
91
91
continue ;
92
92
}
@@ -124,20 +124,14 @@ public List<EntryData<?>> getEntryData() {
124
124
* A utility builder for creating an entry validator that can be used to parse and validate a {@link SectionNode}.
125
125
* @see EntryValidator#builder()
126
126
*/
127
- public static class EntryValidatorBuilder extends EntryData < EntryContainer > {
127
+ public static class EntryValidatorBuilder {
128
128
129
129
/**
130
130
* The default separator used for all {@link KeyValueEntryData}.
131
131
*/
132
132
public static final String DEFAULT_ENTRY_SEPARATOR = ": " ;
133
133
134
- private EntryValidatorBuilder () {
135
- super ("" , null , false );
136
- }
137
-
138
- public EntryValidatorBuilder (String key , boolean optional ) {
139
- super (key , null , optional );
140
- }
134
+ private EntryValidatorBuilder () { }
141
135
142
136
private final List <EntryData <?>> entryData = new ArrayList <>();
143
137
private String entrySeparator = DEFAULT_ENTRY_SEPARATOR ;
@@ -235,8 +229,6 @@ public EntryValidatorBuilder addSection(String key, boolean optional) {
235
229
* @return The builder instance.
236
230
*/
237
231
public EntryValidatorBuilder addEntryData (EntryData <?> entryData ) {
238
- if (entryData == this )
239
- throw new IllegalArgumentException ("Cannot add EntryValidatorBuilder to itself." );
240
232
this .entryData .add (entryData );
241
233
return this ;
242
234
}
@@ -250,31 +242,12 @@ public EntryValidator build() {
250
242
);
251
243
}
252
244
253
- private EntryContainer entryContainer = null ;
254
-
255
- private boolean validate (SectionNode sectionNode ) {
256
- EntryValidator validator = new EntryValidator (
257
- entryData , unexpectedNodeTester , unexpectedEntryMessage , missingRequiredEntryMessage
258
- );
259
- EntryContainer container = validator .validate (sectionNode );
260
- entryContainer = container ;
261
- return container != null ;
262
- }
245
+ }
263
246
264
- @ Override
265
- public @ Nullable EntryContainer getValue (Node node ) {
266
- return entryContainer ;
267
- }
247
+ public static class SubContainerBuilder extends EntryValidatorBuilder {
268
248
269
- @ Override
270
- public boolean canCreateWith (Node node ) {
271
- if (!(node instanceof SectionNode ))
272
- return false ;
273
- String key = node .getKey ();
274
- if (key == null )
275
- return false ;
276
- key = ScriptLoader .replaceOptions (key );
277
- return getKey ().equalsIgnoreCase (key );
249
+ public SubContainerBuilder () {
250
+ super ();
278
251
}
279
252
280
253
}
0 commit comments