Seal IfFeatureExpr 94/101194/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 17 May 2022 20:55:44 +0000 (22:55 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 17 May 2022 21:34:33 +0000 (23:34 +0200)
IfFeatureExpr is not final due to implementation subclasses. Make sure
it cannot be mocked or subclassed by sealing it.

Change-Id: I9146094c9e139c4ee1a5f7fc6a59e6058356a969
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/IfFeatureExpr.java

index 37c1d737e3bbf243850098bfa868e087a1547fdc..da16c843b8793174c52a9698bb1bc97900893b13 100644 (file)
@@ -36,8 +36,8 @@ import org.opendaylight.yangtools.yang.common.QName;
  * @author Robert Varga
  */
 @Beta
-public abstract class IfFeatureExpr implements Immutable, Predicate<Set<QName>> {
-    private abstract static class Single extends IfFeatureExpr {
+public abstract sealed class IfFeatureExpr implements Immutable, Predicate<Set<QName>> {
+    private abstract static sealed class Single extends IfFeatureExpr {
         final QName qname;
 
         Single(final QName qname) {
@@ -68,7 +68,7 @@ public abstract class IfFeatureExpr implements Immutable, Predicate<Set<QName>>
     // We are using arrays to hold our components to save a wee bit of space. The arrays originate from Sets retaining
     // insertion order of Lists, each component is guaranteed to be unique, in definition order, not appearing multiple
     // times
-    private abstract static class AbstractArray<T> extends IfFeatureExpr {
+    private abstract static sealed class AbstractArray<T> extends IfFeatureExpr {
         final T[] array;
 
         AbstractArray(final T[] array) {
@@ -90,7 +90,7 @@ public abstract class IfFeatureExpr implements Immutable, Predicate<Set<QName>>
         abstract String infix();
     }
 
-    private abstract static class Complex extends AbstractArray<IfFeatureExpr> {
+    private abstract static sealed class Complex extends AbstractArray<IfFeatureExpr> {
         Complex(final IfFeatureExpr[] array) {
             super(array);
         }
@@ -129,7 +129,7 @@ public abstract class IfFeatureExpr implements Immutable, Predicate<Set<QName>>
         }
     }
 
-    private abstract static class Compound extends AbstractArray<QName> {
+    private abstract static sealed class Compound extends AbstractArray<QName> {
         Compound(final QName[] qnames) {
             super(qnames);
         }
@@ -256,7 +256,7 @@ public abstract class IfFeatureExpr implements Immutable, Predicate<Set<QName>>
         }
     }
 
-    private abstract static class AbstractAll extends Compound {
+    private abstract static sealed class AbstractAll extends Compound {
         AbstractAll(final QName[] qnames) {
             super(qnames);
         }
@@ -310,7 +310,7 @@ public abstract class IfFeatureExpr implements Immutable, Predicate<Set<QName>>
         }
     }
 
-    private abstract static class AbstractAny extends Compound {
+    private abstract static sealed class AbstractAny extends Compound {
         AbstractAny(final QName[] qnames) {
             super(qnames);
         }