File tree Expand file tree Collapse file tree
src/main/java/org/glavo/nbt/internal/schema Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222import org .glavo .nbt .validation .NBTValidationException ;
2323import org .jetbrains .annotations .Unmodifiable ;
2424
25+ import java .util .ArrayList ;
2526import java .util .List ;
27+ import java .util .Objects ;
2628
2729public record IntersectionSchema <T extends Tag >(
2830 @ Unmodifiable List <NBTSchema <? extends T >> schemas ) implements TagSchema <T > {
@@ -51,4 +53,15 @@ public void validateTag(Tag tag) throws NBTValidationException {
5153 }
5254 }
5355 }
56+
57+ @ Override
58+ public NBTSchema <T > and (NBTSchema <? extends T > other ) {
59+ Objects .requireNonNull (other , "other" );
60+
61+ var list = new ArrayList <NBTSchema <? extends T >>(schemas .size () + 1 );
62+ list .addAll (schemas );
63+ list .add (other );
64+
65+ return new IntersectionSchema <>(List .copyOf (list ));
66+ }
5467}
Original file line number Diff line number Diff line change 2222import org .glavo .nbt .validation .NBTValidationException ;
2323import org .jetbrains .annotations .Unmodifiable ;
2424
25+ import java .util .ArrayList ;
2526import java .util .List ;
27+ import java .util .Objects ;
2628
2729public record UnionSchema <T extends Tag >(@ Unmodifiable List <NBTSchema <? extends T >> schemas ) implements TagSchema <T > {
2830
@@ -57,4 +59,14 @@ public void validateTag(Tag tag) throws NBTValidationException {
5759 }
5860 throw exception ;
5961 }
62+
63+ @ Override
64+ public NBTSchema <T > or (NBTSchema <? extends T > other ) {
65+ Objects .requireNonNull (other , "other" );
66+
67+ var list = new ArrayList <NBTSchema <? extends T >>(schemas .size () + 1 );
68+ list .addAll (schemas );
69+ list .add (other );
70+ return new UnionSchema <>(List .copyOf (list ));
71+ }
6072}
You can’t perform that action at this time.
0 commit comments