|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: (MIT OR CECILL-C) |
| 3 | + * |
| 4 | + * Copyright (C) 2006-2019 INRIA and contributors |
| 5 | + * |
| 6 | + * Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) of the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon. |
| 7 | + */ |
| 8 | +package spoon.reflect.declaration; |
| 9 | + |
| 10 | +import spoon.reflect.annotations.PropertyGetter; |
| 11 | +import spoon.reflect.annotations.PropertySetter; |
| 12 | +import spoon.reflect.path.CtRole; |
| 13 | +import spoon.reflect.reference.CtTypeReference; |
| 14 | + |
| 15 | +import java.util.Collection; |
| 16 | +import java.util.Set; |
| 17 | + |
| 18 | +/** |
| 19 | + * This interface represents any type that can be sealed. |
| 20 | + * See JLS 8.1.1.2 |
| 21 | + */ |
| 22 | +public interface CtSealable { |
| 23 | + |
| 24 | + /** |
| 25 | + * Returns the permitted types for this type. |
| 26 | + * |
| 27 | + * @return an unmodifiable view of the permitted types. |
| 28 | + */ |
| 29 | + @PropertyGetter(role = CtRole.PERMITTED_TYPE) |
| 30 | + Set<CtTypeReference<?>> getPermittedTypes(); |
| 31 | + |
| 32 | + /** |
| 33 | + * Sets the permitted types for this type. |
| 34 | + * Calling this method does not change the state of the {@link ModifierKind#SEALED} for this type. |
| 35 | + * The previously permitted types will be removed. |
| 36 | + * |
| 37 | + * @param permittedTypes the permitted types to set. |
| 38 | + * @return this. |
| 39 | + */ |
| 40 | + @PropertySetter(role = CtRole.PERMITTED_TYPE) |
| 41 | + CtSealable setPermittedTypes(Collection<CtTypeReference<?>> permittedTypes); |
| 42 | + |
| 43 | + /** |
| 44 | + * Adds a permitted type to this type. |
| 45 | + * Calling this method does not change the state of the {@link ModifierKind#SEALED} for this type. |
| 46 | + * |
| 47 | + * @param type the type to add as permitted type. |
| 48 | + * @return this. |
| 49 | + */ |
| 50 | + @PropertySetter(role = CtRole.PERMITTED_TYPE) |
| 51 | + CtSealable addPermittedType(CtTypeReference<?> type); |
| 52 | + |
| 53 | + /** |
| 54 | + * Adds a permitted type to this type. |
| 55 | + * Calling this method does not change the state of the {@link ModifierKind#SEALED} for this type. |
| 56 | + * |
| 57 | + * @param type the type to remove from this type's permitted types. |
| 58 | + * @return this. |
| 59 | + */ |
| 60 | + @PropertySetter(role = CtRole.PERMITTED_TYPE) |
| 61 | + CtSealable removePermittedType(CtTypeReference<?> type); |
| 62 | +} |
0 commit comments