if (!adaptedType.equals(adapterType.getAdaptedType())) { throw new ValidationException(referer.getPosition(), "Adapter " + adapterTypeMirror.getDeclaration().getQualifiedName() + " does not adapt " + adaptedType);
/** * Whether this adapter can adapt the specified type. * * @param type The type. * @return Whether this adapter can adapt the specified type. */ public boolean canAdapt(ReferenceType type) { DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(type); ReferenceType adaptedType = getAdaptedType(); if (adaptedType instanceof DeclaredType) { return ((DeclaredType)adaptedType).getDeclaration() != null && decorated.isInstanceOf(((DeclaredType)adaptedType).getDeclaration().getQualifiedName()); } else if (adaptedType instanceof ArrayType) { if (decorated instanceof ArrayType) { TypeMirror adaptedComponentType = ((ArrayType) adaptedType).getComponentType(); while (adaptedComponentType instanceof DecoratedTypeMirror) { adaptedComponentType = ((DecoratedTypeMirror) adaptedComponentType).getDelegate(); } TypeMirror componentType = ((ArrayType) decorated).getComponentType(); while (componentType instanceof DecoratedTypeMirror) { componentType = ((DecoratedTypeMirror) componentType).getDelegate(); } Types typeUtils = Context.getCurrentEnvironment().getTypeUtils(); return typeUtils.isAssignable(componentType, adaptedComponentType); } } return false; }