org.tinygroup.commons.tools.Assert.assertNotNull()方法的使用及代码示例

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

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

Assert.assertNotNull介绍

[英]确保对象不为空,否则抛出IllegalArgumentException
[中]确保对象不为空,否则抛出IllegalArgumentException

代码示例

代码示例来源:origin: org.tinygroup/weblayer

public void afterPropertiesSet() throws Exception {
  assertNotNull(key, "missing key attribute for parameter");
  if (values == null) {
    values = EMPTY_STRING_ARRAY;
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.weblayerbase

public void afterPropertiesSet() throws Exception {
  assertNotNull(key, "missing key attribute for parameter");
  if (values == null) {
    values = EMPTY_STRING_ARRAY;
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.weblayerbase

/**
 * 创建一个request wrapper。
 *
 * @param context request context
 * @param request request
 */
public AbstractRequestWrapper(WebContext context, HttpServletRequest request) {
  super(request);
  this.context = assertNotNull(context, "requestContext");
}

代码示例来源:origin: org.tinygroup/commons

/** 创建系统默认的locale信息。 */
public LocaleInfo() {
  this.locale = assertNotNull(Locale.getDefault(), "system locale");
  this.charset = assertNotNull(Charset.defaultCharset(), "system charset");
}

代码示例来源:origin: org.tinygroup/cache

public Object getObject() throws Exception {
  Assert.assertNotNull(cache, "cache must not null");
  Assert.assertNotNull(region, "region must not null");
  cache.init(region);
  return cache;
}

代码示例来源:origin: org.tinygroup/commons

/**
 * Return all interfaces that the given instance implements as array,
 * including ones implemented by superclasses.
 * @param instance the instance to analyze for interfaces
 * @return all interfaces that the given instance implements as array
 */
public static Class[] getAllInterfaces(Object instance) {
  Assert.assertNotNull(instance, "Instance must not be null");
  return getAllInterfacesForClass(instance.getClass());
}

代码示例来源:origin: org.tinygroup/org.tinygroup.weblayer

private CommitMonitor getCommitMonitor(WebContext webContext) {
  CommitMonitor monitor = WebContextUtil.findWebContext(webContext,
      SimpleWebContext.class);
  return Assert.assertNotNull(monitor, "no monitor");
}

代码示例来源:origin: org.tinygroup/commons

/**
 * Return all interfaces that the given instance implements as Set,
 * including ones implemented by superclasses.
 * @param instance the instance to analyze for interfaces
 * @return all interfaces that the given instance implements as Set
 */
public static Set<Class> getAllInterfacesAsSet(Object instance) {
  Assert.assertNotNull(instance, "Instance must not be null");
  return getAllInterfacesForClassAsSet(instance.getClass());
}

代码示例来源:origin: org.tinygroup/weblayer

static String normalizeLocation(String location, HttpServletRequest request) {
  location = assertNotNull(trimToNull(location), "no redirect location");
  URI locationURI = URI.create(location);
  if (!locationURI.isAbsolute()) {
    URI baseuri = URI.create(request.getRequestURL().toString());
    locationURI = baseuri.resolve(locationURI);
  }
  return locationURI.normalize().toString();
}

代码示例来源:origin: org.tinygroup/commons

/** 检查异常是否由指定类型的异常引起。 */
public static boolean causedBy(Throwable t, Class<? extends Throwable> causeType) {
  assertNotNull(causeType, "causeType");
  Set<Throwable> causes = createHashSet();
  for (; t != null && !causeType.isInstance(t) && !causes.contains(t); t = t.getCause()) {
    causes.add(t);
  }
  return t != null && causeType.isInstance(t);
}

代码示例来源:origin: org.tinygroup/org.tinygroup.weblayerbase

static String normalizeLocation(String location, HttpServletRequest request) {
  location = assertNotNull(trimToNull(location), "no redirect location");
  URI locationURI = URI.create(location);
  if (!locationURI.isAbsolute()) {
    URI baseuri = URI.create(request.getRequestURL().toString());
    locationURI = baseuri.resolve(locationURI);
  }
  return locationURI.normalize().toString();
}

代码示例来源:origin: org.tinygroup/commons

@SuppressWarnings("unchecked")
  private <T> T doGet(String attributeName, Class<T> expectedType) {
    Assert.hasText(attributeName, "attributeName must not be null or empty");
    Object value = this.get(attributeName);
    Assert.assertNotNull(value, String.format("Attribute '%s' not found", attributeName));
    Assert.isAssignable(expectedType, value.getClass(),
        String.format("Attribute '%s' is of type [%s], but [%s] was expected. Cause: ",
            attributeName, value.getClass().getSimpleName(), expectedType.getSimpleName()));
    return (T) value;
  }
}

代码示例来源:origin: org.tinygroup/weblayer

protected void init() throws Exception {
  assertNotNull(key, "no key");
  byte[] raw = key.getBytes("UTF-8");
  int keySize = getKeySize();
  int actualKeySize = raw.length * 8;
  assertTrue(keySize == actualKeySize, "Illegal key: expected size=%d, actual size is %d", keySize, actualKeySize);
  keySpec = new SecretKeySpec(raw, ALG_NAME);
}

代码示例来源:origin: org.tinygroup/ientity

public void assembleParamterValue(String name, Context context, List<Object> params) {
  Assert.assertNotNull(params, "params must not null");
  Object value=context.get(name);
  if (value != null && value.getClass().isArray()) {
    formatValueArray((Object[]) value, params);
  } else {
    Object formatValue = formaterValue(value,name,context);
    if (formatValue != null) {
      params.add(formatValue);
    }
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.ientity

public void assembleParamterValue(String name, Context context, List<Object> params) {
  Assert.assertNotNull(params, "params must not null");
  Object value=context.get(name);
  if (value != null && value.getClass().isArray()) {
    formatValueArray((Object[]) value, params);
  } else {
    Object formatValue = formaterValue(value,name,context);
    if (formatValue != null) {
      params.add(formatValue);
    }
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.pageflowbasiccomponent

public void execute(Context context) {
  Assert.assertNotNull(contextKey, "contextKey must not null");
  Assert.assertNotNull(sessionKey, "sessionKey must not null");
  Object object = context.get(contextKey);
  if (!ObjectUtil.isEmptyObject(object)) {
    WebContext webContext = (WebContext) context;
    logger.logMessage(LogLevel.INFO, "put object:[{}] to session,the key is [{}]", object, sessionKey);
    webContext.getRequest().getSession(true).setAttribute(sessionKey, object);
  } else {
    logger.logMessage(LogLevel.WARN, "not found object with key:[{}] from context", contextKey);
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.weblayerbase

public AbstractWebContextWrapper(WebContext wrappedContext) {
  assertNotNull(wrappedContext, "wrappedContext");
  this.wrappedContext = wrappedContext;
  this.request = wrappedContext.getRequest();
  this.response = wrappedContext.getResponse();
  this.servletContext = wrappedContext.getServletContext();
}

代码示例来源:origin: org.tinygroup/org.tinygroup.ientity

@SuppressWarnings("rawtypes")
public String getCamelName(String name) {
  if (nameConverter == null) {
    BeanOperatorManager manager = SpringUtil
        .getBean(BeanOperatorManager.OPERATOR_MANAGER_BEAN);
    DBOperator operator = manager.getDbOperator(this.getMainBeanType());
    Assert.assertNotNull(operator, "operator must not null");
    this.nameConverter = operator.getBeanDbNameConverter();
  }
  return nameConverter.dbFieldNameToPropertyName(name);
}

代码示例来源:origin: org.tinygroup/org.tinygroup.ientity

@SuppressWarnings("rawtypes")
public String getCamelName(String name) {
  if (nameConverter == null) {
    BeanOperatorManager manager = SpringUtil
        .getBean(BeanOperatorManager.OPERATOR_MANAGER_BEAN);
    DBOperator operator = manager.getDbOperator(this.getName());
    Assert.assertNotNull(operator, "operator must not null");
    this.nameConverter = operator.getBeanDbNameConverter();
  }
  return nameConverter.dbFieldNameToPropertyName(name);
}

代码示例来源:origin: org.tinygroup/ientity

@SuppressWarnings("rawtypes")
public String getCamelName(String name) {
  if (nameConverter == null) {
    BeanOperatorManager manager = SpringUtil
        .getBean(BeanOperatorManager.OPERATOR_MANAGER_BEAN);
    DBOperator operator = manager.getDbOperator(this.getName());
    Assert.assertNotNull(operator, "operator must not null");
    this.nameConverter = operator.getBeanDbNameConverter();
  }
  return nameConverter.dbFieldNameToPropertyName(name);
}

相关文章

微信公众号

最新文章

更多