software.amazon.awssdk.utils.Validate.isInstanceOf()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中software.amazon.awssdk.utils.Validate.isInstanceOf()方法的一些代码示例,展示了Validate.isInstanceOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Validate.isInstanceOf()方法的具体详情如下:
包路径:software.amazon.awssdk.utils.Validate
类名称:Validate
方法名:isInstanceOf

Validate.isInstanceOf介绍

[英]Validate that the argument is an instance of the specified class; otherwise throwing an exception with the specified message. This method is useful when validating according to an arbitrary class

Validate.isInstanceOf(OkClass.class, object, "Wrong class, object is of class %s", 
object.getClass().getName());

[中]验证参数是否为指定类的实例;否则,将使用指定的消息引发异常。当根据任意类进行验证时,此方法非常有用

Validate.isInstanceOf(OkClass.class, object, "Wrong class, object is of class %s", 
object.getClass().getName());

代码示例

代码示例来源:origin: aws/aws-sdk-java-v2

@Override
  public Exception getCause() {
    return Validate.isInstanceOf(Exception.class, super.getCause(), "Unexpected cause type.");
  }
}

代码示例来源:origin: software.amazon.awssdk/test-utils

@Override
  public Exception getCause() {
    return Validate.isInstanceOf(Exception.class, super.getCause(), "Unexpected cause type.");
  }
}

代码示例来源:origin: aws/aws-sdk-java-v2

@Override
  public Error getCause() {
    return Validate.isInstanceOf(Error.class, super.getCause(), "Unexpected cause type.");
  }
}

代码示例来源:origin: software.amazon.awssdk/test-utils

@Override
  public Error getCause() {
    return Validate.isInstanceOf(Error.class, super.getCause(), "Unexpected cause type.");
  }
}

代码示例来源:origin: aws/aws-sdk-java-v2

private TypeName listElementConsumerBuilderType() {
  TypeName listElementType = listElementType();
  ClassName classType = Validate.isInstanceOf(ClassName.class, listElementType,
                        "List element type must be of type class, but was %s", listElementType);
  return classType.nestedClass("Builder");
}

代码示例来源:origin: software.amazon.awssdk/codegen

private TypeName listElementConsumerBuilderType() {
  TypeName listElementType = listElementType();
  ClassName classType = Validate.isInstanceOf(ClassName.class, listElementType,
                        "List element type must be of type class, but was %s", listElementType);
  return classType.nestedClass("Builder");
}

代码示例来源:origin: software.amazon.awssdk/sdk-core

/**
 * Validate the result of calling an interceptor method that is attempting to modify the message to make sure its result is
 * valid.
 */
private void validateInterceptorResult(Object originalMessage, Object newMessage,
                    ExecutionInterceptor interceptor, String methodName) {
  if (!Objects.equals(originalMessage, newMessage)) {
    LOG.debug(() -> "Interceptor '" + interceptor + "' modified the message with its " + methodName + " method.");
    LOG.trace(() -> "Old: " + originalMessage + "\nNew: " + newMessage);
  }
  Validate.validState(newMessage != null,
            "Request interceptor '%s' returned null from its %s interceptor.",
            interceptor, methodName);
  Validate.isInstanceOf(originalMessage.getClass(), newMessage,
             "Request interceptor '%s' returned '%s' from its %s method, but '%s' was expected.",
             interceptor, newMessage.getClass(), methodName, originalMessage.getClass());
}

相关文章