@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)); }
public static EqualsMethod isolated() { return new EqualsMethod(SuperClassCheck.DISABLED); }
EqualsMethod implements Implementation { public static EqualsMethod isolated() { return new EqualsMethod(SuperClassCheck.DISABLED); } }
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); }
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); }
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);  }