1 package annotations.el; 2 3 import java.util.LinkedHashMap; 4 5 import annotations.util.coll.VivifyingMap; 6 7 /*>>> 8 import org.checkerframework.checker.nullness.qual.Nullable; 9 */ 10 11 public class AField extends ADeclaration { 12 static <K extends Object> VivifyingMap<K, AField> 13 newVivifyingLHMap_AF() { 14 return new VivifyingMap<K, AField>( 15 new LinkedHashMap<K, AField>()) { 16 @Override 17 public AField createValueFor(K k) { 18 return new AField("" + k); 19 } 20 21 @Override 22 public boolean subPrune(AField v) { 23 return v.prune(); 24 } 25 }; 26 } 27 28 public AExpression init; 29 private final String fieldName; 30 31 AField(String fieldName) { 32 super(fieldName); 33 this.fieldName = fieldName; 34 } 35 36 AField(AField field) { 37 super(field.fieldName, field); 38 fieldName = field.fieldName; 39 init = field.init == null ? null : field.init.clone(); 40 } 41 42 @Override 43 public AField clone() { 44 return new AField(this); 45 } 46 47 @Override 48 public boolean equals(Object o) { 49 return o instanceof AField 50 && ((AField) o).equalsField(this); 51 } 52 53 final boolean equalsField(AField o) { 54 return super.equals(o); 55 } 56 57 @Override // TODO: remove? 58 public String toString() { 59 StringBuilder sb = new StringBuilder(); 60 sb.append("AField "); 61 sb.append(fieldName); 62 sb.append(super.toString()); 63 return sb.toString(); 64 } 65 66 @Override 67 public <R, T> R accept(ElementVisitor<R, T> v, T t) { 68 return v.visitField(this, t); 69 } 70 } 71