1 19 20 package org.netbeans.modules.javacore.parser; 21 22 import java.io.IOException ; 23 import java.io.InputStream ; 24 import java.io.OutputStream ; 25 import org.netbeans.mdr.storagemodel.StorableBaseObject; 26 import org.netbeans.mdr.util.IOUtils; 27 import org.openide.util.Utilities; 28 29 public class WildCardRef extends TypeRef { 30 public final boolean isLower; 31 public final TypeRef bound; 32 33 public static Object read(InputStream stream, StorableBaseObject storable) throws IOException { 34 return new WildCardRef(IOUtils.readBoolean(stream), (TypeRef) IOUtils.read(stream, storable)); 35 } 36 37 public void write(OutputStream outputStream, StorableBaseObject storable) throws IOException { 38 IOUtils.writeBoolean(outputStream, isLower); 39 IOUtils.write(outputStream, bound, storable); 40 } 41 42 public WildCardRef(boolean isLower, TypeRef bound) { 43 this.isLower = isLower; 44 this.bound = bound; 45 } 46 47 public boolean equals(Object typeRef) { 48 WildCardRef ref; 49 50 if (this==typeRef) 51 return true; 52 if (!(typeRef instanceof WildCardRef)) 53 return false; 54 ref=(WildCardRef)typeRef; 55 if (isLower!=ref.isLower) 56 return false; 57 return Utilities.compareObjects(bound, ref.bound); 58 } 59 60 String getName() { 61 return (isLower? "+" : "-").concat(bound == null ? "" : bound.getName()); } 63 64 public int hashCode() { 65 return bound == null ? 0 : bound.hashCode(); 66 } 67 } | Popular Tags |