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.impl; 18 19 import signature.model.IField; 20 import signature.model.ITypeReference; 21 import signature.model.Modifier; 22 23 import java.io.Serializable; 24 import java.util.Collections; 25 import java.util.Set; 26 27 @SuppressWarnings("serial") 28 public class SigField extends SigAnnotatableElement implements IField, 29 Serializable { 30 31 private String name; 32 private ITypeReference type = Uninitialized.unset(); 33 private Set<Modifier> modifiers = Uninitialized.unset(); 34 SigField(String name)35 public SigField(String name) { 36 this.name = name; 37 modifiers = Collections.emptySet(); 38 } 39 getName()40 public String getName() { 41 return name; 42 } 43 getModifiers()44 public Set<Modifier> getModifiers() { 45 return modifiers; 46 } 47 setModifiers(Set<Modifier> modifiers)48 public void setModifiers(Set<Modifier> modifiers) { 49 this.modifiers = modifiers; 50 } 51 getType()52 public ITypeReference getType() { 53 return type; 54 } 55 setType(ITypeReference type)56 public void setType(ITypeReference type) { 57 this.type = type; 58 } 59 60 61 @Override toString()62 public String toString() { 63 StringBuilder builder = new StringBuilder(); 64 if (getAnnotations() != null && !getAnnotations().isEmpty()) { 65 builder.append(super.toString()); 66 builder.append("\n"); 67 } 68 builder.append(Modifier.toString(getModifiers())); 69 builder.append(getType().toString()); 70 builder.append(" "); 71 builder.append(getName()); 72 return builder.toString(); 73 } 74 } 75