1 4 package com.puppycrawl.tools.checkstyle.bcel.classfile; 5 6 import java.util.HashSet ; 7 import java.util.Set ; 8 9 import org.apache.bcel.classfile.Field; 10 11 import com.puppycrawl.tools.checkstyle.bcel.generic.FieldReference; 12 import com.puppycrawl.tools.checkstyle.bcel.generic.PUTFIELDReference; 13 import com.puppycrawl.tools.checkstyle.bcel.generic.PUTSTATICReference; 14 15 19 public class FieldDefinition 20 extends FieldOrMethodDefinition 21 { 22 23 private final Set mGetReferences = new HashSet (); 24 25 26 private final Set mPutReferences = new HashSet (); 27 28 32 public FieldDefinition(Field aField) 33 { 34 super(aField); 35 } 36 37 41 public Field getField() 42 { 43 return (Field) getFieldOrMethod(); 44 } 45 46 50 public int getReadReferenceCount() 51 { 52 return mGetReferences.size(); 53 } 54 55 59 public int getWriteReferenceCount() 60 { 61 return mPutReferences.size(); 62 } 63 64 68 public int getReferenceCount() 69 { 70 return getReadReferenceCount() + getWriteReferenceCount(); 71 } 72 73 77 public void addReference(FieldReference aFieldRef) 78 { 79 if ((aFieldRef instanceof PUTFIELDReference) 81 || (aFieldRef instanceof PUTSTATICReference)) 82 { 83 mPutReferences.add(aFieldRef); 84 } 85 else { 86 mGetReferences.add(aFieldRef); 87 } 88 } 89 } 90 | Popular Tags |