00001 package plp.orientadaObjetos1.util; 00002 00003 import plp.orientadaObjetos1.excecao.declaracao.ClasseNaoDeclaradaException; 00004 import plp.orientadaObjetos1.expressao.leftExpression.Id; 00005 import plp.orientadaObjetos1.memoria.AmbienteCompilacao; 00006 00007 public class TipoGeneric implements Tipo { 00008 00012 private Id tipoGeneric; 00013 00014 00015 public TipoGeneric(Id tipoGeneric) { 00016 this.tipoGeneric = tipoGeneric; 00017 } 00018 00019 00020 public Id getTipo() { 00021 return this.tipoGeneric; 00022 } 00023 00024 00025 public boolean eValido(AmbienteCompilacao ambiente) throws ClasseNaoDeclaradaException { 00026 boolean resposta = true; 00027 resposta = ambiente.getGeneric(this.tipoGeneric) != null; 00028 return resposta; 00029 } 00030 00037 public boolean equals(Object obj) { 00038 boolean respota = false; 00039 if ( obj instanceof TipoGeneric) { 00040 00041 TipoGeneric tg = (TipoGeneric)obj; 00042 respota = tg.tipoGeneric.equals(this.tipoGeneric); 00043 } 00044 return respota; 00045 } 00046 00051 public String toString() { 00052 return "<" + this.tipoGeneric + ">"; 00053 } 00054 00055 public int hashCode() { 00056 return this.tipoGeneric.hashCode(); 00057 } 00058 }