/** * {@inheritDoc} */ public Builder<S> withHashCodeEquals() { return method(isHashCode()) .intercept(HashCodeMethod.usingDefaultOffset().withIgnoredFields(isSynthetic())) .method(isEquals()) .intercept(EqualsMethod.isolated().withIgnoredFields(isSynthetic())); }
.method(isHashCode()) .intercept(hashCode) .method(isEquals()) .intercept(equals) .serialVersionUid(42L)
mockTransformer = new AsmVisitorWrapper.ForDeclaredMethods() .method(isVirtual() .and(not(isBridge().or(isHashCode()).or(isEquals()).or(isDefaultFinalizer()))) .and(not(isDeclaredBy(nameStartsWith("java.")).<MethodDescription>and(isPackagePrivate()))), Advice.withCustomMapping() .bind(MockMethodAdvice.Identifier.class, identifier) .to(MockMethodAdvice.ForHashCode.class)) .method(isEquals(), Advice.withCustomMapping() .bind(MockMethodAdvice.Identifier.class, identifier)
.withNonNullableFields(nonNullable(new ValueMatcher(ValueHandling.Sort.REVERSE_NULLABILITY)))); if (typeDescription.getDeclaredMethods().filter(isEquals()).isEmpty()) { EqualsMethod equalsMethod = enhance.invokeSuper() .equalsMethod(typeDescription) .withStringTypedFieldsFirst(); builder = builder.method(isEquals()).intercept(enhance.permitSubclassEquality() ? equalsMethod.withSubclassEquality() : equalsMethod);
static Object create(final Object bean, DecoratorExecutor executor) { try { Object proxy = new ByteBuddy() .subclass(bean.getClass()) .implement(EnhancedProxy.class) .defineField("bean", bean.getClass(), Modifier.PRIVATE) .defineField("executor", DecoratorExecutor.class, Modifier.PRIVATE) .method(isEquals()) .intercept(to(EqualsInterceptor.class)) .method(isAnnotatedWith(nameStartsWith("cucumber.api"))) .intercept(to(CucumberInterceptor.class)) .method(not(isEquals().or(isClone()).or(isAnnotatedWith(nameStartsWith("cucumber.api"))))) .intercept(toField("bean")) .make() .load(bean.getClass().getClassLoader(), ClassLoadingStrategy.Default.INJECTION) .getLoaded() .newInstance(); ReflectionUtils.injectValue(proxy, "bean", bean); ReflectionUtils.injectValue(proxy, "executor", executor); return proxy; } catch (Exception e) { throw new JpaUnitException("Failed to create proxy for " + bean, e); } } }