11package dev .manere .inscript ;
22
33import com .google .errorprone .annotations .CanIgnoreReturnValue ;
4- import dev .manere .inscript .node .InscriptNode ;
4+ import dev .manere .inscript .node .ConfigNode ;
55import dev .manere .inscript .node .RootSectionNode ;
66import dev .manere .inscript .node .ScalarNode ;
77import dev .manere .inscript .node .SectionNode ;
1212import java .util .*;
1313import java .util .function .Consumer ;
1414
15- public interface InscriptEditor {
15+ public interface ConfigSection {
1616 @ NotNull
1717 @ Unmodifiable
18- default Set <InscriptNode > getChildren () {
18+ default Set <ConfigNode > getChildren () {
1919 return Set .copyOf (getSection ().getChildren ());
2020 }
2121
@@ -24,7 +24,7 @@ default Set<InscriptNode> getChildren() {
2424 default Set <String > getKeys () {
2525 final Set <String > keys = new HashSet <>();
2626
27- for (final InscriptNode node : getChildren ()) {
27+ for (final ConfigNode node : getChildren ()) {
2828 keys .add (node .getKey ());
2929 }
3030
@@ -36,8 +36,8 @@ default boolean isRoot() {
3636 }
3737
3838 @ NotNull
39- default Optional <InscriptNode > getNode (final @ NotNull String key ) {
40- for (final InscriptNode node : getChildren ()) if (node .getKey ().equals (key )) return Optional .of (node );
39+ default Optional <ConfigNode > getNode (final @ NotNull String key ) {
40+ for (final ConfigNode node : getChildren ()) if (node .getKey ().equals (key )) return Optional .of (node );
4141 return Optional .empty ();
4242 }
4343
@@ -53,14 +53,14 @@ default boolean isScalar(final @NotNull String key) {
5353 SectionNode getSection ();
5454
5555 @ NotNull
56- Optional <InscriptEditor > getSection (final @ NotNull String key );
56+ Optional <ConfigSection > getSection (final @ NotNull String key );
5757
5858 @ NotNull
59- InscriptEditor createSection (final @ NotNull String key );
59+ ConfigSection createSection (final @ NotNull String key );
6060
6161 @ NotNull
6262 @ CanIgnoreReturnValue
63- default InscriptEditor section (final @ NotNull String key , final @ NotNull Consumer <InscriptEditor > handler ) {
63+ default ConfigSection section (final @ NotNull String key , final @ NotNull Consumer <ConfigSection > handler ) {
6464 handler .accept (getSection (key ).orElse (createSection (key )));
6565 return this ;
6666 }
@@ -73,7 +73,7 @@ default InscriptEditor section(final @NotNull String key, final @NotNull Consume
7373
7474 @ NotNull
7575 @ CanIgnoreReturnValue
76- <T > InscriptEditor set (final @ NotNull String key , final @ Nullable T value );
76+ <T > ConfigSection set (final @ NotNull String key , final @ Nullable T value );
7777
7878 default boolean has (final @ NotNull String key ) {
7979 return contains (key );
@@ -85,22 +85,22 @@ default boolean contains(final @NotNull String key) {
8585
8686 @ NotNull
8787 @ CanIgnoreReturnValue
88- default InscriptEditor unset (final @ NotNull String key ) {
88+ default ConfigSection unset (final @ NotNull String key ) {
8989 getNode (key ).ifPresent (node -> getSection ().getChildren ().remove (node ));
9090 return this ;
9191 }
9292
9393 @ NotNull
9494 @ CanIgnoreReturnValue
95- default InscriptEditor reset () {
95+ default ConfigSection reset () {
9696 getSection ().getChildren ().clear ();
9797 return this ;
9898 }
9999
100100 @ NotNull
101101 @ CanIgnoreReturnValue
102- default InscriptEditor forEachSection (final @ NotNull Consumer <InscriptEditor > sectionConsumer ) {
103- for (final InscriptNode node : getSection ().getChildren ()) {
102+ default ConfigSection forEachSection (final @ NotNull Consumer <ConfigSection > sectionConsumer ) {
103+ for (final ConfigNode node : getSection ().getChildren ()) {
104104 getSection (node .getKey ()).ifPresent (sectionConsumer );
105105 }
106106
@@ -109,8 +109,8 @@ default InscriptEditor forEachSection(final @NotNull Consumer<InscriptEditor> se
109109
110110 @ NotNull
111111 @ CanIgnoreReturnValue
112- default InscriptEditor forEachScalar (final @ NotNull Consumer <ScalarNode <?>> scalarConsumer ) {
113- for (final InscriptNode node : getSection ().getChildren ()) {
112+ default ConfigSection forEachScalar (final @ NotNull Consumer <ScalarNode <?>> scalarConsumer ) {
113+ for (final ConfigNode node : getSection ().getChildren ()) {
114114 if (node instanceof ScalarNode <?> scalar ) scalarConsumer .accept (scalar );
115115 }
116116
@@ -119,12 +119,12 @@ default InscriptEditor forEachScalar(final @NotNull Consumer<ScalarNode<?>> scal
119119
120120 @ NotNull
121121 @ CanIgnoreReturnValue
122- default InscriptEditor forEach (final @ NotNull Consumer <ScalarNode <?>> scalarConsumer , final @ NotNull Consumer <InscriptEditor > sectionConsumer ) {
123- for (final InscriptNode node : getSection ().getChildren ()) {
122+ default ConfigSection forEach (final @ NotNull Consumer <ScalarNode <?>> scalarConsumer , final @ NotNull Consumer <ConfigSection > sectionConsumer ) {
123+ for (final ConfigNode node : getSection ().getChildren ()) {
124124 if (node instanceof ScalarNode <?> scalar ) {
125125 scalarConsumer .accept (scalar );
126126 } else if (node instanceof SectionNode section ) {
127- sectionConsumer .accept (new SimpleInscriptEditor (section ));
127+ sectionConsumer .accept (new SimpleConfigSection (section ));
128128 }
129129 }
130130
@@ -133,7 +133,7 @@ default InscriptEditor forEach(final @NotNull Consumer<ScalarNode<?>> scalarCons
133133
134134 @ NotNull
135135 @ CanIgnoreReturnValue
136- default InscriptEditor setComments (final @ NotNull String key , final @ NotNull Collection <? extends String > comments ) {
136+ default ConfigSection comment (final @ NotNull String key , final @ NotNull Collection <? extends String > comments ) {
137137 getNode (key ).ifPresent (node -> {
138138 node .getComments ().clear ();
139139 node .getComments ().addAll (comments );
@@ -144,15 +144,15 @@ default InscriptEditor setComments(final @NotNull String key, final @NotNull Col
144144
145145 @ NotNull
146146 default Collection <String > getComments (final @ NotNull String key ) {
147- final InscriptNode node = getNode (key ).orElse (null );
147+ final ConfigNode node = getNode (key ).orElse (null );
148148 if (node == null ) return Set .of ();
149149
150150 return Set .copyOf (node .getComments ());
151151 }
152152
153153 @ NotNull
154154 @ CanIgnoreReturnValue
155- default InscriptEditor setComments (final @ NotNull String key , final @ NotNull String @ NotNull ... comments ) {
156- return setComments (key , Arrays .asList (comments ));
155+ default ConfigSection comment (final @ NotNull String key , final @ NotNull String @ NotNull ... comments ) {
156+ return comment (key , Arrays .asList (comments ));
157157 }
158158}
0 commit comments