com.stormpath.sdk.lang.Assert类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(126)

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

Assert介绍

暂无

代码示例

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

public StringResource(String string, Charset charset) {
  Assert.hasText(string, "String argument cannot be null or empty.");
  Assert.notNull(charset, "Charset argument cannot be null or empty.");
  this.string = string;
  this.charset = charset;
}

代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-impl

@Override
public AttributeStatementMappingRulesBuilder addAttributeStatementMappingRule(AttributeStatementMappingRule attributeStatementMappingRule) {
  Assert.notNull(attributeStatementMappingRule, "attributeStatementMappingRule argument cannot be null or empty.");
  if (this.attributeStatementMappingRules == null){
    this.attributeStatementMappingRules = new LinkedHashSet<AttributeStatementMappingRule>(1);
  } else {
    Assert.isTrue(!attributeStatementMappingRules.contains(attributeStatementMappingRule));
  }
  attributeStatementMappingRules.add(attributeStatementMappingRule);
  return this;
}

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

@Override
public void init() throws Exception {
  Assert.hasText(this.uri, "uri cannot be null or empty.");
  Assert.notNull(this.accountModelFactory, "accountModelFactory cannot be null.");
  Assert.notNull(this.objectMapper, "objectMapper cannot be null.");
  Assert.notEmpty(this.produces, "produces cannot be null or empty");
  Assert.notNull(this.applicationResolver, "applicationResolver cannot be null.");
}

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

public Config getConfig(ServletContext servletContext) {

    Assert.notNull(servletContext, "ServletContext argument cannot be null.");

    Object value = servletContext.getAttribute(SERVLET_CONTEXT_ATTRIBUTE_NAME);

    Assert.notNull(value, NULL_ERR_MSG);

    Assert.isInstanceOf(Config.class, value, INSTANCE_ERR_MSG);

    return (Config) value;
  }
}

代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-servlet

@Override
protected void onInit() throws Exception {
  super.onInit();
  Assert.notNull(this.allowedOrigins, "allowedOrigins cannot be null.");
  Assert.notEmpty(this.allowedHttpMethods, "allowedHttpMethods cannot be empty.");
  Assert.notEmpty(this.allowedHttpHeaders, "allowedHttpHeaders cannot be empty.");
}

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

@Override
public <T extends Resource, O extends Options> T getResource(String href, Class<T> clazz, O options) {
  Assert.hasText(href, "href argument cannot be null or empty.");
  Assert.notNull(clazz, "Resource class argument cannot be null.");
  Assert.isInstanceOf(DefaultOptions.class, options, "The " + getClass().getName() + " implementation only functions with " +
      DefaultOptions.class.getName() + " instances.");
  DefaultOptions defaultOptions = (DefaultOptions) options;
  QueryString qs = queryStringFactory.createQueryString(defaultOptions);
  return (T) getResource(href, clazz, (Map) qs);
}

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

public DefaultUserInfoMappingRule(String name, Set<String> accountAttributes) {
  Assert.hasText(name, "name argument cannot be null or empty.");
  Assert.notEmpty(accountAttributes, "accountAttributes cannot be null or empty.");
  this.name = name;
  this.accountAttributes = Collections.unmodifiableSet(accountAttributes);
}

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

/**
 * @since 1.1.0
 */
@Override
public PasswordStrength setPreventReuse(int preventReuse) {
  Assert.isTrue(preventReuse >= 0, "preventReuse cannot be a negative number.");
  Assert.isTrue(preventReuse <= 25, "preventReuse cannot be larger than 25.");
  setProperty(PREVENT_REUSE, preventReuse);
  return this;
}

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

public DefaultNonce(Map<String, Object> properties) {
  Assert.notEmpty(properties);
  Assert.isTrue(properties.size() == 1 && properties.containsKey(VALUE.getName()));
  Object value = properties.get(VALUE.getName());
  Assert.isInstanceOf(String.class, value);
  this.properties = properties;
}

代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-impl

@Override
public String decryptBase64String(String base64EncryptedValue) {
  Assert.hasText(base64EncryptedValue);
  Assert.isTrue(Base64.isBase64(base64EncryptedValue.getBytes()), "encryptedValue argument must be Base64.");
  byte[] encryptedValue = Base64.decodeBase64(base64EncryptedValue);
  return new String(decrypt(encryptedValue), UTF_8);
}

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

@Override
public OAuthPasswordGrantRequestAuthenticationBuilder setLogin(String login) {
  Assert.hasText(login, "username cannot be null or empty.");
  this.login = login;
  return this;
}

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

/**
 * Assert that an array has elements; that is, it must not be
 * <code>null</code> and must have at least one element.
 * <pre class="code">Assert.notEmpty(array);</pre>
 * @param array the array to check
 * @throws IllegalArgumentException if the object array is <code>null</code> or has no elements
 */
public static void notEmpty(Object[] array) {
  notEmpty(array, "[Assertion failed] - this array must not be empty: it must contain at least 1 element");
}

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

/**
 * Assert that the provided object is an instance of the provided class.
 * <pre class="code">Assert.instanceOf(Foo.class, foo);</pre>
 * @param clazz the required class
 * @param obj the object to check
 * @throws IllegalArgumentException if the object is not an instance of clazz
 * @see Class#isInstance
 */
public static void isInstanceOf(Class clazz, Object obj) {
  isInstanceOf(clazz, obj, "");
}

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

public SswsAuthenticator(ApiKeyCredentials apiKeyCredentials) {
  Assert.notNull(apiKeyCredentials, "apiKeyCredentials must be not be null.");
  this.apiKeyCredentials = apiKeyCredentials;
  ApiKey apiKey = apiKeyCredentials.getApiKey();
  Assert.notNull(apiKey, "apiKeyCredentials argument cannot have a null apiKey");
  Assert.isInstanceOf(PairedApiKey.class, apiKey, "apiKeyCredentials.getApiKey() must be a PairedApiKey instance");
  this.pairedApiKey = (PairedApiKey) apiKey;
}

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

public SpringView(Collection<ViewResolver> viewResolvers, LocaleResolver localeResolver, HandlerInterceptor templateHandlerInterceptor) {
  Assert.notEmpty(viewResolvers, "viewResolvers cannot be null or empty.");
  Assert.notNull(localeResolver, "localeResolver cannot be null.");
  Assert.notNull(templateHandlerInterceptor, "templateHandlerInterceptor cannot be null.");
  this.handlerInterceptor = templateHandlerInterceptor;
  List<ViewResolver> l = new ArrayList<>(viewResolvers);
  //it is important to keep view resolvers sorted based on priority.  Spring's DispatcherServlet does this
  //so we need to do the same:
  AnnotationAwareOrderComparator.sort(l);
  this.viewResolvers = l;
  this.localeResolver = localeResolver;
}

代码示例来源:origin: com.stormpath.sdk/stormpath-sdk-impl

public DefaultUserInfoMappingRule(String name, Set<String> accountAttributes) {
  Assert.hasText(name, "name argument cannot be null or empty.");
  Assert.notEmpty(accountAttributes, "accountAttributes cannot be null or empty.");
  this.name = name;
  this.accountAttributes = Collections.unmodifiableSet(accountAttributes);
}

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

/**
 * @param name         the name of the filter
 * @param filteryThing a Filter instance, a Filter implementation class, a Factory&lt;Filter&gt; instance or a Factory&lt;Filter&gt; implementation class.
 */
public void addFilter(String name, Object filteryThing) {
  if (filteryThing instanceof Class) {
    Assert.isTrue(!Filter.class.equals(filteryThing), "Cannot specify the Filter class directly.  Specify a class that implements the Filter interface.");
  }
  this.configuredFilters.put(name, filteryThing);
}

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

@Override
public AttributeStatementMappingRuleBuilder setNameFormat(String nameFormat) {
  Assert.hasText(nameFormat, "nameFormat argument cannot be null or empty.");
  this.nameFormat = nameFormat;
  return this;
}

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

/**
 * Assert that a collection has elements; that is, it must not be
 * <code>null</code> and must have at least one element.
 * <pre class="code">Assert.notEmpty(collection, "Collection must have elements");</pre>
 * @param collection the collection to check
 * @throws IllegalArgumentException if the collection is <code>null</code> or has no elements
 */
public static void notEmpty(Collection collection) {
  notEmpty(collection,
      "[Assertion failed] - this collection must not be empty: it must contain at least 1 element");
}

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

public ClientBuilder setClientCredentials(ClientCredentials clientCredentials) {
  Assert.isInstanceOf(ClientCredentials.class, clientCredentials);
  this.clientCredentials = clientCredentials;
  return this;
}

相关文章