Skip to content

Commit 3df8bb6

Browse files
committed
just for fun, use 'sealed' in AttributeNodeImpl :)
there's no actual good reason to do this, except, perhaps to make the code more self-documenting
1 parent 0e94ca1 commit 3df8bb6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

hibernate-core/src/main/java/org/hibernate/graph/internal/AttributeNodeImpl.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@
3434
* @author Steve Ebersole
3535
* @author Gavin King
3636
*/
37-
public abstract class AttributeNodeImpl<J, E, K>
37+
public abstract sealed class AttributeNodeImpl<J, E, K>
3838
extends AbstractGraphNode<J>
39-
implements AttributeNodeImplementor<J, E, K> {
39+
implements AttributeNodeImplementor<J, E, K>
40+
permits AttributeNodeImpl.SingularAttributeNodeImpl,
41+
AttributeNodeImpl.PluralAttributeNodeImpl,
42+
AttributeNodeImpl.MapAttributeNodeImpl {
4043

4144
protected final PersistentAttribute<?, J> attribute;
4245
protected final DomainType<E> valueGraphType;
@@ -100,7 +103,7 @@ private AttributeNodeImpl(AttributeNodeImpl<J, E, K> that, boolean mutable) {
100103
keySubgraph = that.keySubgraph == null ? null : that.keySubgraph.makeCopy( mutable );
101104
}
102105

103-
private static class SingularAttributeNodeImpl<J> extends AttributeNodeImpl<J, J, Void> {
106+
static final class SingularAttributeNodeImpl<J> extends AttributeNodeImpl<J, J, Void> {
104107
private SingularAttributeNodeImpl(
105108
SingularPersistentAttribute<?,J> attribute,
106109
boolean mutable,
@@ -128,7 +131,7 @@ public AttributeNodeImplementor<J, J, Void> makeCopy(boolean mutable) {
128131
}
129132
}
130133

131-
private static class PluralAttributeNodeImpl<J,E> extends AttributeNodeImpl<J, E, Void> {
134+
static final class PluralAttributeNodeImpl<J,E> extends AttributeNodeImpl<J, E, Void> {
132135
private PluralAttributeNodeImpl(
133136
PluralPersistentAttribute<?,J,E> attribute,
134137
boolean mutable,
@@ -156,7 +159,7 @@ public AttributeNodeImplementor<J, E, Void> makeCopy(boolean mutable) {
156159
}
157160
}
158161

159-
static class MapAttributeNodeImpl<J,K,V> extends AttributeNodeImpl<J, V, K> {
162+
static final class MapAttributeNodeImpl<J,K,V> extends AttributeNodeImpl<J, V, K> {
160163
private MapAttributeNodeImpl(
161164
PluralPersistentAttribute<?,J,V> pluralAttribute,
162165
@SuppressWarnings("unused") // a "witness" that this is really a Map

0 commit comments

Comments
 (0)