Exemple #1
0
 public boolean equals(Object obj) {
   if (!(obj instanceof Entity)) {
     return false;
   }
   Entity entity = (Entity) obj;
   if (!getRandomKey().equals(entity.getRandomKey())) {
     return false;
   }
   return getId() == null || entity.getId() == null || getId().equals(entity.getId());
 }
Exemple #2
0
 protected String migrateToText(Entity entity, String fieldname) {
   try {
     Class<?> c = entity.getClass();
     Field oldField = c.getDeclaredField(fieldname + "Old");
     Field newField = c.getDeclaredField(fieldname);
     String oldVal = (String) oldField.get(entity);
     String newVal = (String) newField.get(entity);
     if ((newVal == null || newVal.isEmpty()) && oldVal != null && !oldVal.isEmpty()) {
       newField.set(entity, oldVal);
       oldField.set(entity, "");
     }
     return (String) newField.get(entity);
   } catch (Exception ex) {
     throw new RuntimeException("migrateToText failed", ex);
   }
 }