1 11 package org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets; 12 13 import java.util.Iterator ; 14 15 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType; 16 17 public class TypeSetUnion extends TypeSet { 18 private TypeSet fLHS; 19 private TypeSet fRHS; 20 21 public TypeSetUnion(TypeSet lhs, TypeSet rhs) { 22 super(lhs.getTypeSetEnvironment()); 23 fLHS= lhs; 24 fRHS= rhs; 25 } 26 27 30 public boolean isUniverse() { 31 if (fLHS.isUniverse() || fRHS.isUniverse()) 32 return true; 33 if (fLHS.isSingleton() && fRHS.isSingleton()) 34 return false; 35 throw new IllegalStateException ("unimplemented"); } 37 38 41 public TypeSet makeClone() { 42 return new TypeSetUnion(fLHS.makeClone(), fRHS.makeClone()); 43 } 44 45 48 public boolean isEmpty() { 49 return fLHS.isEmpty() && fRHS.isEmpty(); 50 } 51 52 55 public boolean contains(TType t) { 56 return fLHS.contains(t) || fRHS.contains(t); 57 } 58 59 62 public boolean containsAll(TypeSet s) { 63 return fLHS.containsAll(s) || fRHS.containsAll(s); 64 } 65 66 69 public TType anyMember() { 70 return fLHS.anyMember(); 71 } 72 73 76 public boolean equals(Object o) { 77 if (o instanceof TypeSetUnion) { 78 TypeSetUnion other= (TypeSetUnion) o; 79 return other.fLHS.equals(fLHS) && other.fRHS.equals(fRHS); 80 } else 81 return false; 82 } 83 84 87 public TypeSet upperBound() { 88 throw new IllegalStateException ("unimplemented"); } 90 91 94 public TypeSet lowerBound() { 95 throw new IllegalStateException ("unimplemented"); } 97 98 101 public Iterator iterator() { 102 throw new IllegalStateException ("unimplemented"); } 104 107 public boolean isSingleton() { 108 return fLHS.isSingleton() && fRHS.isSingleton() && fLHS.anyMember().equals(fRHS.anyMember()); 109 } 110 111 114 public boolean hasUniqueLowerBound() { 115 return false; 116 } 117 118 121 public boolean hasUniqueUpperBound() { 122 return false; 123 } 124 125 128 public TType uniqueLowerBound() { 129 return null; 130 } 131 132 135 public TType uniqueUpperBound() { 136 return null; 137 } 138 139 142 public EnumeratedTypeSet enumerate() { 143 EnumeratedTypeSet result= fLHS.enumerate(); 144 145 result.addAll(fRHS.enumerate()); 146 return result; 147 } 148 149 public String toString() { 150 return "<" + fID + ": union(" + fLHS + "," + fRHS + ")>"; } 152 } 153 | Popular Tags |