@Override
  public void validate() {
    // Make sure more than one 'position' isn't picked.
    int positions = 0;

    if (before != null) positions++;
    if (after != null) positions++;
    if (index > -1) positions++;
    if (!position.equals(Position.OTHER_THAN_FIRST_OR_LAST)) positions++;

    switch (positions) {
      case 0:
        throw log.missingCustomInterceptorPosition(interceptor.getClass().getName());
      case 1:
        break;
      default:
        throw log.multipleCustomInterceptorPositions(interceptor.getClass().getName());
    }
    if (interceptor == null) {
      throw log.customInterceptorMissingClass();
    }
    if (!(interceptor instanceof BaseCustomInterceptor)) {
      log.suggestCustomInterceptorInheritance(interceptor.getClass().getName());
    }
  }
  @Override
  public void validate() {
    Attribute<Class> interceptorClassAttribute = attributes.attribute(INTERCEPTOR_CLASS);
    Attribute<CommandInterceptor> interceptorAttribute = attributes.attribute(INTERCEPTOR);

    if (!interceptorClassAttribute.isNull() && !interceptorAttribute.isNull()) {
      throw log.interceptorClassAndInstanceDefined(
          interceptorClassAttribute.get().getName(), interceptorAttribute.get().toString());
    } else if (interceptorClassAttribute.isNull() && interceptorAttribute.isNull()) {
      throw log.customInterceptorMissingClass();
    }
    Class<? extends CommandInterceptor> interceptorClass = interceptorClassAttribute.get();
    if (interceptorClass == null) {
      interceptorClass = interceptorAttribute.get().getClass();
    }

    if (!BaseCustomInterceptor.class.isAssignableFrom(interceptorClass)) {
      final String className = interceptorClass.getName();
      // Suppress noisy warnings if the interceptor is one of our own (like one of those from
      // Query):
      if (!className.startsWith("org.infinispan.")) {
        log.suggestCustomInterceptorInheritance(className);
      }
    }

    // Make sure more than one 'position' isn't picked.
    int positions = 0;

    if (!attributes.attribute(BEFORE).isNull()) positions++;
    if (!attributes.attribute(AFTER).isNull()) positions++;
    if (attributes.attribute(INDEX).get() > -1) positions++;
    if (attributes.attribute(POSITION).isModified()) positions++;

    switch (positions) {
      case 0:
        throw log.missingCustomInterceptorPosition(interceptorClass.getName());
      case 1:
        break;
      default:
        throw log.multipleCustomInterceptorPositions(interceptorClass.getName());
    }
  }