@Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   ClusteredEntityWithObjectValue other = (ClusteredEntityWithObjectValue) obj;
   if (id == null) {
     if (other.id != null) return false;
   } else if (!id.equals(other.id)) return false;
   if (value == null) {
     if (other.value != null) return false;
   } else if (!value.equals(other.value)) return false;
   return true;
 }
Exemplo n.º 2
0
 public static void main(String[] args) {
   Holder<Apple> Apple = new Holder<Apple>(new Apple());
   Apple d = Apple.get();
   Apple.set(d);
   Holder<? extends Fruit> fruit = Apple;
   Fruit p = fruit.get();
   d = (Apple) fruit.get();
   try {
     Orange c = (Orange) fruit.get();
   } catch (Exception e) {
     System.out.println(e);
   }
   System.out.println(fruit.equals(d));
 }