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

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

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

Assert.assertTrue介绍

[英]确保表达式为真,否则抛出IllegalArgumentException
[中]确保表达式为真,否则抛出IllegalArgumentException

代码示例

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

/** 确保表达式为真,否则抛出<code>IllegalArgumentException</code>。 */
public static void assertTrue(boolean expression) {
  assertTrue(expression, null, null, (Object[]) null);
}

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

/** 确保表达式为真,否则抛出<code>IllegalArgumentException</code>。 */
public static void assertTrue(boolean expression, String message, Object... args) {
  assertTrue(expression, null, message, args);
}

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

/**
 * Compare the signatures of the bridge method and the method which it bridges. If
 * the parameter and return types are the same, it is a 'visibility' bridge method
 * introduced in Java 6 to fix http://bugs.sun.com/view_bug.do?bug_id=6342411.
 * See also http://stas-blogspot.blogspot.com/2010/03/java-bridge-methods-explained.html
 * @return whether signatures match as described
 */
public static boolean isVisibilityBridgeMethodPair(Method bridgeMethod, Method bridgedMethod) {
  Assert.assertTrue(bridgeMethod != null);
  Assert.assertTrue(bridgedMethod != null);
  if (bridgeMethod == bridgedMethod) {
    return true;
  }
  return Arrays.equals(bridgeMethod.getParameterTypes(), bridgedMethod.getParameterTypes()) &&
      bridgeMethod.getReturnType().equals(bridgedMethod.getReturnType());
}

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

/** 设置新匹配。 */
public void setMatchResults(MatchResult... results) {
  assertTrue(!isEmptyArray(results), "results");
  if (this.results.length != results.length) {
    throw new IllegalArgumentException("expected " + this.results.length + " MatchResults");
  }
  for (int i = 0; i < results.length; i++) {
    this.results[i] = results[i];
  }
}

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

private static MatchResult createEmptyMatchResult() {
  Matcher matcher = Pattern.compile("^$").matcher("");
  assertTrue(matcher.find());
  return matcher.toMatchResult();
}

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

public void initAttributeNames(String[] attrNames) {
  this.attrNames = attrNames;
  assertTrue(attrNames.length <= 1, "Session store %s supports only 1 mapping to attribute name", getName());
}

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

public void initAttributeNames(String[] attrNames) {
  this.attrNames = attrNames;
  assertTrue(attrNames.length <= 1, "Session store %s supports only 1 mapping to attribute name", getName());
}

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

protected void formatValueArray(Object[] array, List<Object> params) {
  Assert.assertTrue(array.length==2,"betweenAnd比较符的值长度为2");
  super.formatValueArray(array, params);
}

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

protected void formatValueArray(Object[] array, List<Object> params) {
  Assert.assertTrue(array.length==2,"betweenAnd比较符的值长度为2");
  super.formatValueArray(array, params);
}

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

protected void formatValueArray(Object[] array, List<Object> params) {
  Assert.assertTrue(array.length==2,"betweenAnd比较符的值长度为2");
  super.formatValueArray(array, params);
}

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

protected void formatValueArray(Object[] array, List<Object> params) {
  Assert.assertTrue(array.length==2,"betweenAnd比较符的值长度为2");
  super.formatValueArray(array, params);
}

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

/** 检查flags,如果存在,则返回<code>true</code>。 */
protected boolean hasFlags(String... names) {
  assertTrue(!isEmptyArray(names), "names");
  for (String flag : flags) {
    for (String name : names) {
      if (flag.startsWith(name)) {
        // flag或F=*
        if (flag.length() == name.length() || flag.charAt(name.length()) == '=') {
          return true;
        }
      }
    }
  }
  return false;
}

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

/**
 * 检查flags,如果存在,则返回<code>true</code>。
 */
protected boolean hasFlags(String... names) {
  assertTrue(!isEmptyArray(names), "names");
  for (String flag : flags) {
    for (String name : names) {
      if (flag.startsWith(name)) {
        // flag或F=*
        if (flag.length() == name.length() || flag.charAt(name.length()) == '=') {
          return true;
        }
      }
    }
  }
  return false;
}

代码示例来源: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/org.tinygroup.weblayerbase

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/weblayer

/** 如果flag不存在,则返回<code>null</code>。如果flag无值,则返回空字符串。否则返回值。 */
protected String getFlagValue(String... names) {
  assertTrue(!isEmptyArray(names), "names");
  for (String flag : flags) {
    for (String name : names) {
      if (flag.startsWith(name)) {
        if (flag.length() == name.length()) {
          return "";
        } else if (flag.charAt(name.length()) == '=') {
          return trimToEmpty(flag.substring(name.length() + 1));
        }
      }
    }
  }
  return null;
}

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

private static long parse(String humanReadbleSize, String... nas) {
  humanReadbleSize = assertNotNull(trimToNull(humanReadbleSize), "human readble size");
  if (nas != null) {
    for (String na : nas) {
      if (na != null && na.equalsIgnoreCase(humanReadbleSize)) {
        return -1;
      }
    }
  }
  Matcher matcher = REGEXP.matcher(humanReadbleSize);
  assertTrue(matcher.matches(), "wrong format: %s", humanReadbleSize);
  double size = Double.parseDouble(matcher.group(1));
  String unit = trimToNull(matcher.group(3));
  if (unit != null) {
    size *= UNIT_NAMES.get(unit.toUpperCase());
  }
  return (long) size;
}

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

public void config(XmlNode applicationConfig, XmlNode componentConfig) {
  this.applicationConfig = applicationConfig;
  if (applicationConfig != null) {
    maxContentLength = Integer.parseInt(StringUtil.defaultIfBlank(applicationConfig.getAttribute("max-content-length"), "0"));
    Assert.assertTrue(maxContentLength >= 0, "文件长度值必须是大于0的正整数");
    XmlNode excludeNode = applicationConfig.getSubNode("exclude-content-type");
    if (excludeNode != null) {
      String value = excludeNode.getContent();
      if (value != null) {
        String[] types = value.split(";");
        for (String type : types) {
          excludeContentTypes.add(type);
        }
      }
    }
  }
}

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

protected String encodeValue(Object value) throws Exception {
  assertTrue(value instanceof Map, "wrong session attribute type: " + value.getClass());
  Map<?, ?> map = (Map<?, ?>) value;
  Map<String, String> encodedMap = createLinkedHashMap();
  TypeConverter converter = getTypeConverter();
  for (Map.Entry<?, ?> entry : map.entrySet()) {
    String key = String.valueOf(entry.getKey());
    String encodedValue = convertToString(valueType, entry.getValue(), converter);
    encodedMap.put(key, encodedValue);
  }
  return new QueryStringParser(getCharset()).setEqualSign(getEqualSign()).append(encodedMap).toQueryString();
}

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

protected String encodeValue(Object value) throws Exception {
  assertTrue(value instanceof Map, "wrong session attribute type: " + value.getClass());
  Map<?, ?> map = (Map<?, ?>) value;
  Map<String, String> encodedMap = createLinkedHashMap();
  TypeConverter converter = getTypeConverter();
  for (Map.Entry<?, ?> entry : map.entrySet()) {
    String key = String.valueOf(entry.getKey());
    String encodedValue = convertToString(valueType, entry.getValue(), converter);
    encodedMap.put(key, encodedValue);
  }
  return new QueryStringParser(getCharset()).setEqualSign(getEqualSign()).append(encodedMap).toQueryString();
}

相关文章