Path: blob/master/src/java.compiler/share/classes/javax/lang/model/element/Modifier.java
41161 views
/*1* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.lang.model.element;262728/**29* Represents a modifier on a program element such30* as a class, method, or field.31*32* <p>Not all modifiers are applicable to all kinds of elements.33* When two or more modifiers appear in the source code of an element34* then it is customary, though not required, that they appear in the same35* order as the constants listed in the detail section below.36*37* <p>Note that it is possible additional modifiers will be added in38* future versions of the platform.39*40* @jls 8.1.1 Class Modifiers41* @jls 8.3.1 Field Modifiers42* @jls 8.4.3 Method Modifiers43* @jls 8.8.3 Constructor Modifiers44* @jls 9.1.1 Interface Modifiers45*46* @author Joseph D. Darcy47* @author Scott Seligman48* @author Peter von der Ahé49* @since 1.650*/5152public enum Modifier {5354// Note java.lang.reflect.Modifier includes INTERFACE, but that's a VMism.5556/** The modifier {@code public} */ PUBLIC,57/** The modifier {@code protected} */ PROTECTED,58/** The modifier {@code private} */ PRIVATE,59/** The modifier {@code abstract} */ ABSTRACT,60/**61* The modifier {@code default}62* @since 1.863*/64DEFAULT,65/** The modifier {@code static} */ STATIC,6667/**68* The modifier {@code sealed}69* @since 1770*/71SEALED,7273/**74* The modifier {@code non-sealed}75* @since 1776*/77NON_SEALED {78public String toString() {79return "non-sealed";80}81},82/** The modifier {@code final} */ FINAL,83/** The modifier {@code transient} */ TRANSIENT,84/** The modifier {@code volatile} */ VOLATILE,85/** The modifier {@code synchronized} */ SYNCHRONIZED,86/** The modifier {@code native} */ NATIVE,87/** The modifier {@code strictfp} */ STRICTFP;8889/**90* Returns this modifier's name as defined in <cite>The91* Java Language Specification</cite>.92* The modifier name is the {@linkplain #name() name of the enum93* constant} in lowercase and with any underscores ("{@code _}")94* replaced with hyphens ("{@code -}").95* @return the modifier's name96*/97@Override98public String toString() {99return name().toLowerCase(java.util.Locale.US);100}101}102103104