### Question:
EqualsMethod implements Implementation { public static EqualsMethod isolated() { return new EqualsMethod(SuperClassCheck.DISABLED); } protected  EqualsMethod(SuperClassCheck superClassCheck); private  EqualsMethod(SuperClassCheck superClassCheck,
                         TypeCompatibilityCheck typeCompatibilityCheck,
                         ElementMatcher.Junction<? super FieldDescription.InDefinedShape> ignored,
                         ElementMatcher.Junction<? super FieldDescription.InDefinedShape> nonNullable,
                         Comparator<? super FieldDescription.InDefinedShape> comparator); static EqualsMethod requiringSuperClassEquality(); static EqualsMethod isolated(); EqualsMethod withIgnoredFields(ElementMatcher<? super FieldDescription.InDefinedShape> ignored); EqualsMethod withNonNullableFields(ElementMatcher<? super FieldDescription.InDefinedShape> nonNullable); EqualsMethod withPrimitiveTypedFieldsFirst(); EqualsMethod withEnumerationTypedFieldsFirst(); EqualsMethod withPrimitiveWrapperTypedFieldsFirst(); EqualsMethod withStringTypedFieldsFirst(); @SuppressWarnings("unchecked") // In absence of @SafeVarargs EqualsMethod withFieldOrder(Comparator<? super FieldDescription.InDefinedShape> comparator); Implementation withSubclassEquality(); InstrumentedType prepare(InstrumentedType instrumentedType); ByteCodeAppender appender(Target implementationTarget);  }### Answer:
@Test public void testEqualsTrue() throws Exception { DynamicType.Loaded<?> loaded = new ByteBuddy() .subclass(Object.class) .defineField(FOO, type, Visibility.PUBLIC) .method(isEquals()) .intercept(EqualsMethod.isolated()) .make() .load(ClassLoadingStrategy.BOOTSTRAP_LOADER, ClassLoadingStrategy.Default.WRAPPER); assertThat(loaded.getLoadedAuxiliaryTypes().size(), is(0)); assertThat(loaded.getLoaded().getDeclaredMethods().length, is(1)); assertThat(loaded.getLoaded().getDeclaredFields().length, is(1)); Object left = loaded.getLoaded().getDeclaredConstructor().newInstance(), right = loaded.getLoaded().getDeclaredConstructor().newInstance(); left.getClass().getDeclaredField(FOO).set(left, value); right.getClass().getDeclaredField(FOO).set(right, value); assertThat(left, is(right)); }
@Test public void testEqualsFalse() throws Exception { DynamicType.Loaded<?> loaded = new ByteBuddy() .subclass(Object.class) .defineField(FOO, type, Visibility.PUBLIC) .method(isEquals()) .intercept(EqualsMethod.isolated()) .make() .load(ClassLoadingStrategy.BOOTSTRAP_LOADER, ClassLoadingStrategy.Default.WRAPPER); assertThat(loaded.getLoadedAuxiliaryTypes().size(), is(0)); assertThat(loaded.getLoaded().getDeclaredMethods().length, is(1)); assertThat(loaded.getLoaded().getDeclaredFields().length, is(1)); Object first = loaded.getLoaded().getDeclaredConstructor().newInstance(); Object second = loaded.getLoaded().getDeclaredConstructor().newInstance(); first.getClass().getDeclaredField(FOO).set(first, value); second.getClass().getDeclaredField(FOO).set(second, alternative); assertThat(first, not(second)); }