@Test public void testEqualsTrue() throws Exception { DynamicType.Loaded<?> loaded = new ByteBuddy() .subclass(Object.class) .defineField(FOO, type, Visibility.PUBLIC) .method(isToString()) .intercept(ToStringMethod.prefixedBy(FOO)) .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 instance = loaded.getLoaded().getDeclaredConstructor().newInstance(); instance.getClass().getDeclaredField(FOO).set(instance, value); assertThat(instance.toString(), is(FOO + "{" + FOO + "=" + string + "}")); }
public static ToStringMethod prefixedBy(String prefix) { if (prefix == null) { throw new IllegalArgumentException("Prefix cannot be null"); } return prefixedBy(new PrefixResolver.ForFixedValue(prefix)); }
ToStringMethod implements Implementation { public static ToStringMethod prefixedBy(String prefix) { if (prefix == null) { throw new IllegalArgumentException("Prefix cannot be null"); } return prefixedBy(new PrefixResolver.ForFixedValue(prefix)); } }
ToStringMethod implements Implementation { public static ToStringMethod prefixedBy(String prefix) { if (prefix == null) { throw new IllegalArgumentException("Prefix cannot be null"); } return prefixedBy(new PrefixResolver.ForFixedValue(prefix)); } protected  ToStringMethod(PrefixResolver prefixResolver); private  ToStringMethod(PrefixResolver prefixResolver,
                           String start,
                           String end,
                           String separator,
                           String definer,
                           ElementMatcher.Junction<? super FieldDescription.InDefinedShape> ignored); }
ToStringMethod implements Implementation { public static ToStringMethod prefixedBy(String prefix) { if (prefix == null) { throw new IllegalArgumentException("Prefix cannot be null"); } return prefixedBy(new PrefixResolver.ForFixedValue(prefix)); } protected  ToStringMethod(PrefixResolver prefixResolver); private  ToStringMethod(PrefixResolver prefixResolver,
                           String start,
                           String end,
                           String separator,
                           String definer,
                           ElementMatcher.Junction<? super FieldDescription.InDefinedShape> ignored); static ToStringMethod prefixedByFullyQualifiedClassName(); static ToStringMethod prefixedByCanonicalClassName(); static ToStringMethod prefixedBySimpleClassName(); static ToStringMethod prefixedBy(String prefix); static ToStringMethod prefixedBy(PrefixResolver prefixResolver); ToStringMethod withIgnoredFields(ElementMatcher<? super FieldDescription.InDefinedShape> ignored); Implementation withTokens(String start, String end, String separator, String definer); InstrumentedType prepare(InstrumentedType instrumentedType); Appender appender(Target implementationTarget); }
ToStringMethod implements Implementation { public static ToStringMethod prefixedBy(String prefix) { if (prefix == null) { throw new IllegalArgumentException("Prefix cannot be null"); } return prefixedBy(new PrefixResolver.ForFixedValue(prefix)); } protected  ToStringMethod(PrefixResolver prefixResolver); private  ToStringMethod(PrefixResolver prefixResolver,
                           String start,
                           String end,
                           String separator,
                           String definer,
                           ElementMatcher.Junction<? super FieldDescription.InDefinedShape> ignored); static ToStringMethod prefixedByFullyQualifiedClassName(); static ToStringMethod prefixedByCanonicalClassName(); static ToStringMethod prefixedBySimpleClassName(); static ToStringMethod prefixedBy(String prefix); static ToStringMethod prefixedBy(PrefixResolver prefixResolver); ToStringMethod withIgnoredFields(ElementMatcher<? super FieldDescription.InDefinedShape> ignored); Implementation withTokens(String start, String end, String separator, String definer); InstrumentedType prepare(InstrumentedType instrumentedType); Appender appender(Target implementationTarget);  }