@AutoFunctional public boolean hasReturnTypeInfo(SimpleTypeInfo typeInfo) { return returnTypeInfo().equals(typeInfo); }
@Override public final boolean equals(final Object obj) { if (obj == this) { return true; } if (obj instanceof EnumConstantInfo) { final EnumConstantInfo that = (EnumConstantInfo) obj; return enumType().equals(that.enumType()) && value().equals(that.value()); } else { return false; } }
private static Optional<InvalidateMethod> of1(TypeInfo typeInfo, MethodInfo method, AnnotationInfo annotation) { String annotationName = annotation.simpleName(); if (method.hasModifierInfo(ModifierInfo.FINAL)) { method.compilationError("@%s method cannot be final", annotationName); return Optional.empty(); } if (method.hasAccessInfo(AccessInfo.PRIVATE)) { method.compilationError("@%s method cannot be private", annotationName); return Optional.empty(); } SimpleTypeInfo returnTypeInfo = method.returnTypeInfo(); boolean self = returnTypeInfo.equals(typeInfo.toSimpleTypeInfo()); if (!returnTypeInfo.equals(SimpleTypePrimitives.VOID) && !self) { method.compilationError("@%s method must return void or self", annotationName); return Optional.empty(); } InvalidateMethod invalidateMethod = new InvalidateMethod(method, annotation, self); return Optional.of(invalidateMethod); }
@Override public MustacheObject toMustache() { return Mustaches.toMustacheHelper() .add("inherited", !typeInfo.equals(testableOf)) .add("testableOf", testableOf) .toMustache(); }
public static PojoTestable wrap(Pojo pojo) { ClassInfo classInfo = pojo.classInfo; Optional<InterfaceInfo> maybeTestable = classInfo.getInterface(Testable.class); if (!maybeTestable.isPresent()) { return NotTestable.INSTANCE; } Optional<MethodInfo> isEqual = classInfo.getMethodInfoIterable() .filter(MethodInfoHasName.get("isEqual")) .filter(MethodInfoHasModifierInfo.not(ModifierInfo.ABSTRACT)) .first(); if (isEqual.isPresent()) { return NotTestable.INSTANCE; } SimpleTypeInfo typeInfo = classInfo.toSimpleTypeInfo(); InterfaceInfo testable = maybeTestable.get(); SimpleTypeInfo testableOf = testable.getTypeParameterInfoIterable() .transform(TypeParameterInfoToSimpleTypeInfo.get()) .first() .get(); return typeInfo.equals(testableOf) ? new DefaultTestable(pojo, testableOf) : new InheritedTestable(pojo, testableOf); }