|
| 1 | +/* This file is part of KeY - https://key-project.org |
| 2 | + * KeY is licensed under the GNU General Public License Version 2 |
| 3 | + * SPDX-License-Identifier: GPL-2.0-only */ |
| 4 | +package de.uka.ilkd.key.java.ast.declaration; |
| 5 | + |
| 6 | +/** |
| 7 | + * |
| 8 | + * @author Alexander Weigl |
| 9 | + * @version 1 (12.05.26) |
| 10 | + */ |
| 11 | +public enum ModifierKind { |
| 12 | + DEFAULT("default"), |
| 13 | + PUBLIC("public"), |
| 14 | + PROTECTED("protected"), |
| 15 | + PRIVATE("private"), |
| 16 | + ABSTRACT("abstract"), |
| 17 | + STATIC("static"), |
| 18 | + FINAL("final"), |
| 19 | + TRANSIENT("transient"), |
| 20 | + VOLATILE("volatile"), |
| 21 | + SYNCHRONIZED("synchronized"), |
| 22 | + NATIVE("native"), |
| 23 | + STRICTFP("strictfp"), |
| 24 | + TRANSITIVE("transitive"), |
| 25 | + SEALED("sealed"), |
| 26 | + NON_SEALED("non-sealed"), |
| 27 | + // KEY |
| 28 | + JML_PACKAGE("package"), |
| 29 | + JML_PURE("pure"), |
| 30 | + JML_STRICTLY_PURE("strictly_pure"), |
| 31 | + JML_HELPER("helper"), |
| 32 | + JML_INSTANCE("instance"), |
| 33 | + JML_NULLABLE_BY_DEFAULT("nullable_by_default"), |
| 34 | + JML_NON_NULL("non_null"), |
| 35 | + JML_NULLABLE("nullable"), |
| 36 | + JML_GHOST("ghost"), |
| 37 | + JML_MODEL("model"), |
| 38 | + JML_SPEC_PUBLIC("spec_public"), |
| 39 | + JML_SPEC_PACKAGE("spec_package"), |
| 40 | + JML_SPEC_PROTECTED("spec_protected"), |
| 41 | + JML_SPEC_PRIVATE("spec_private"), |
| 42 | + JML_NO_STATE("no_state"), |
| 43 | + JML_TWO_STATE("two_state"), |
| 44 | + JML_NON_NULL_BY_DEFAULT("non_null_by_default"), |
| 45 | + JML_NON_NULL_ELEMENTS("nonnullelements"), |
| 46 | + JML_UNPARSABLE_MODIFIERS("<unparsable>"), |
| 47 | + JML_CODE_BIGINT_MATH("code_bigint_math"), |
| 48 | + JML_CODE_JAVA_MATH("code_java_math"), |
| 49 | + JML_CODE_SAFE_MATH("code_safe_math"), |
| 50 | + JML_SPEC_BIGINT_MATH("spec_bigint_math"), |
| 51 | + JML_SPEC_JAVA_MATH("spec_java_math"), |
| 52 | + JML_SPEC_SAFE_MATH("spec_safe_math"), |
| 53 | + JML_CODE("code"), |
| 54 | + JML_OT_PEER("peer"), |
| 55 | + JML_OT_REP("rep"), |
| 56 | + JML_OT_READ_ONLY("read_only"); |
| 57 | + |
| 58 | + private final String codeRepresentation; |
| 59 | + |
| 60 | + ModifierKind(String codeRepresentation) { |
| 61 | + this.codeRepresentation = codeRepresentation; |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * @return the Java keyword represented by this enum constant. |
| 66 | + */ |
| 67 | + public String asString() { |
| 68 | + if (name().startsWith("JML_")) { |
| 69 | + return "/*@" + codeRepresentation + "*/"; |
| 70 | + } |
| 71 | + return codeRepresentation; |
| 72 | + } |
| 73 | + |
| 74 | + public boolean isVisibility() { |
| 75 | + return switch (this) { |
| 76 | + case PUBLIC, PRIVATE, PROTECTED, JML_PACKAGE -> true; |
| 77 | + default -> false; |
| 78 | + }; |
| 79 | + } |
| 80 | + |
| 81 | + public boolean allowsInheritance() { |
| 82 | + return this == PUBLIC || this == PROTECTED || this == JML_PACKAGE; |
| 83 | + } |
| 84 | +} |
0 commit comments