### Question:
OverwritablePojo { @NonNull @SuppressWarnings("unchecked") public T overwrite(@NonNull final T other) { checkNotNull(other, "Can't overwrite with null value"); if (equals(other)) { return (T) this; } for (Field field : getTypeParameterClass().getDeclaredFields()) { final int modifiers = field.getModifiers(); if (hasIllegalAccessModifiers(modifiers)) { continue; } if (!Modifier.isPublic(modifiers) || Modifier.isFinal(modifiers)) { field.setAccessible(true); } try { if (!isEmpty(field, other)) { field.set(this, field.get(other)); } } catch (IllegalAccessException e) { Log.e(TAG, "Failed set at " + field.getName(), e); } } return (T) this; }  @NonNull @SuppressWarnings("unchecked") T overwrite(@NonNull final T other); @Override boolean equals(Object o);  }### Answer:
@Test public void testOverwriteWithAnother() { TestPojo pojo1 = new TestPojo(100, "foo"); TestPojo pojo2 = new TestPojo(200, "bar"); pojo1.overwrite(pojo2); assertEquals(pojo1, pojo2); assertEquals(200, pojo1.id); assertEquals("bar", pojo1.value); }
@Test public void testOverwriteWithItself() { TestPojo pojo1 = new TestPojo(100, "foo"); pojo1.overwrite(pojo1); assertEquals(100, pojo1.id); assertEquals("foo", pojo1.value); }