With JDK17 we can properly restrict the class hierarchy of these
interfaces. Also hide MutationBehaviour, as it should not leak.
Change-Id: I0681ef7a0c82abe7aa9dd7adddae69940e57011f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
* @author Robert Varga
* @author Tony Tkacik
*/
* @author Robert Varga
* @author Tony Tkacik
*/
-public interface Immutable extends MutationBehaviour<Immutable> {
-
+public non-sealed interface Immutable extends MutationBehaviour<Immutable> {
+ // Marker interface only
* @param <T> Item order type
*/
@Beta
* @param <T> Item order type
*/
@Beta
-public interface ItemOrder<T extends ItemOrder<T>> {
+public sealed interface ItemOrder<T extends ItemOrder<T>> {
/**
* Items are ordered and their order is significant. A {@link List} is an example of a collection which conforms to
* this contract.
*/
/**
* Items are ordered and their order is significant. A {@link List} is an example of a collection which conforms to
* this contract.
*/
- interface Ordered extends ItemOrder<Ordered> {
+ non-sealed interface Ordered extends ItemOrder<Ordered> {
@Override
default Class<Ordered> itemOrder() {
return Ordered.class;
@Override
default Class<Ordered> itemOrder() {
return Ordered.class;
* Items are unordered and their order is insignificant. A {@link Set} is an example of a collection which conforms
* to this contract.
*/
* Items are unordered and their order is insignificant. A {@link Set} is an example of a collection which conforms
* to this contract.
*/
- interface Unordered extends ItemOrder<Unordered> {
+ non-sealed interface Unordered extends ItemOrder<Unordered> {
@Override
default Class<Unordered> itemOrder() {
return Unordered.class;
@Override
default Class<Unordered> itemOrder() {
return Unordered.class;
*
* @author Tony Tkacik
*/
*
* @author Tony Tkacik
*/
-public interface Mutable extends MutationBehaviour<Mutable> {
-
+public non-sealed interface Mutable extends MutationBehaviour<Mutable> {
+ // Marker interface only
*
* @param <T> Mutation Type
*/
*
* @param <T> Mutation Type
*/
-// FIXME: sealed to allow Mutable and Immutable only when we have JDK17+
-// FIXME: consider hiding this interface afterwards
-public interface MutationBehaviour<T extends MutationBehaviour<T>> {
+sealed interface MutationBehaviour<T extends MutationBehaviour<T>> permits Immutable, Mutable {
// Marker interface only
}
// Marker interface only
}