001 /*
002 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package javax.lang.model.element;
027
028
029 /**
030 * Represents a modifier on a program element such
031 * as a class, method, or field.
032 *
033 * <p>Not all modifiers are applicable to all kinds of elements.
034 * When two or more modifiers appear in the source code of an element
035 * then it is customary, though not required, that they appear in the same
036 * order as the constants listed in the detail section below.
037 *
038 * <p>Note that it is possible additional modifiers will be added in
039 * future versions of the platform.
040 *
041 * @author Joseph D. Darcy
042 * @author Scott Seligman
043 * @author Peter von der Ahé
044 * @since 1.6
045 */
046
047 public enum Modifier {
048
049 // See JLS2 sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1.
050 // java.lang.reflect.Modifier includes INTERFACE, but that's a VMism.
051
052 /** The modifier {@code public} */ PUBLIC,
053 /** The modifier {@code protected} */ PROTECTED,
054 /** The modifier {@code private} */ PRIVATE,
055 /** The modifier {@code abstract} */ ABSTRACT,
056 /** The modifier {@code static} */ STATIC,
057 /** The modifier {@code final} */ FINAL,
058 /** The modifier {@code transient} */ TRANSIENT,
059 /** The modifier {@code volatile} */ VOLATILE,
060 /** The modifier {@code synchronized} */ SYNCHRONIZED,
061 /** The modifier {@code native} */ NATIVE,
062 /** The modifier {@code strictfp} */ STRICTFP,
063 /** The modifier {@code separable} */ SEPARABLE;
064
065
066 private String lowercase = null; // modifier name in lowercase
067
068 /**
069 * Returns this modifier's name in lowercase.
070 */
071 public String toString() {
072 if (lowercase == null) {
073 lowercase = name().toLowerCase(java.util.Locale.US);
074 }
075 return lowercase;
076 }
077 }