1 8 9 package net.sourceforge.chaperon.model.grammar; 10 11 import java.io.Serializable ; 12 13 19 public class Associativity implements Serializable 20 { 21 22 public static final Associativity LEFT = new Associativity("left"); 23 24 25 public static final Associativity RIGHT = new Associativity("right"); 26 27 28 public static final Associativity NONASSOC = new Associativity("nonassoc"); 29 private String value = null; 30 31 36 public Associativity(String value) 37 { 38 if ((value.equals("left")) || (value.equals("right")) || (value.equals("nonassoc"))) 39 this.value = value; 40 else 41 throw new IllegalArgumentException ("Type not recognized"); 42 } 43 44 51 public boolean equals(Object o) 52 { 53 if (o==this) 54 return true; 55 56 if (o instanceof Associativity) 57 { 58 Associativity assoc = (Associativity)o; 59 60 return (assoc.value.equals(value)); 61 } 62 63 return false; 64 } 65 66 71 public String toString() 72 { 73 return value; 74 } 75 } 76 | Popular Tags |