Home | History | Annotate | Download | only in model
      1 /*
      2  * Copyright (C) 2009 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package signature.model;
     18 
     19 import java.util.Set;
     20 
     21 /**
     22  * {@class Modifier} models a modifer.
     23  */
     24 public enum Modifier {
     25     PUBLIC("public"), PRIVATE("private"), PROTECTED("protected"), STATIC(
     26             "static"), FINAL("final"), SYNCHRONIZED("synchronized"), VOLATILE(
     27             "volatile"), TRANSIENT("transient"), NATIVE("native"), ABSTRACT(
     28             "abstract"), STRICT("strict");
     29 
     30     private final String printableName;
     31 
     32     private Modifier(String printableName) {
     33         this.printableName = printableName;
     34     }
     35 
     36     @Override
     37     public String toString() {
     38         return printableName;
     39     }
     40 
     41     public static String toString(Set<Modifier> modifiers) {
     42         StringBuilder s = new StringBuilder();
     43 
     44         for (Modifier modifier : values()) {
     45             if (modifiers.contains(modifier)) {
     46                 s.append(modifier.printableName);
     47                 s.append(" ");
     48             }
     49         }
     50 
     51         return s.toString();
     52     }
     53 }
     54