com.alibaba.citrus.util.Assert.assertNotNull()方法的使用及代码示例

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

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

Assert.assertNotNull介绍

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

代码示例

代码示例来源:origin: webx/citrus

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

代码示例来源:origin: webx/citrus

@Override
protected void init() throws Exception {
  assertNotNull(condition, "no condition");
  assertNotNull(block, "no if-block");
}

代码示例来源:origin: webx/citrus

/** 创建一个<code>ByteArrayResource</code>。 */
public ByteArrayResource(byte[] bytes, int offset, int length) {
  this.bytes = assertNotNull(bytes, "bytes");
  if (offset < 0 || offset + length > bytes.length || length < 0) {
    throw new IndexOutOfBoundsException();
  }
  this.offset = offset;
  this.length = length;
}

代码示例来源:origin: webx/citrus

AbstractDataBindingAdapter(Object moduleObject) {
    this.log = LoggerFactory.getLogger(moduleObject.getClass());
    this.moduleObject = assertNotNull(moduleObject, "moduleObject");
  }
}

代码示例来源:origin: webx/citrus

public ServletRequestContext(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) {
  super(getServletBaseURL(request), getServletResourcePath(request));
  this.request = assertNotNull(request, "request is null");
  this.response = assertNotNull(response, "response is null");
  this.servletContext = assertNotNull(servletContext, "servletContext is null");
}

代码示例来源:origin: webx/citrus

/** 取得忽略大小写的名称。 */
  protected String caseInsensitiveName(String name) {
    assertNotNull(name, "name");
    return StringUtil.toLowerCase(name);
  }
}

代码示例来源:origin: webx/citrus

@Override
protected void init() throws Exception {
  super.init();
  assertNotNull(condition, "no condition");
}

代码示例来源:origin: webx/citrus

@Override
protected void init() throws Exception {
  super.init();
  assertNotNull(condition, "no condition");
}

代码示例来源:origin: webx/citrus

/** 取得指定名称的组件。 */
public <PC extends PageComponent> PC getComponent(String componentPath, Class<PC> componentClass) {
  componentPath = PageComponent.normalizeComponentPath(componentPath);
  PageComponent component = assertNotNull(components.get(componentPath), "Component not found: %s", componentPath);
  if (componentClass != null) {
    return componentClass.cast(component);
  } else {
    @SuppressWarnings("unchecked")
    PC pc = (PC) component;
    return pc;
  }
}

代码示例来源:origin: webx/citrus

/** 规格化模板名。 */
private String normalizeTemplateName(String templateName) {
  templateName = assertNotNull(trimToNull(templateName), "templateName");
  if (templateName.startsWith("/")) {
    templateName = templateName.substring(1);
  }
  return templateName;
}

代码示例来源:origin: webx/citrus

/** 编译表达式。 */
public void compile() {
  assertNotNull(message, "message");
  try {
    messageExpression = EXPRESSION_FACTORY.createExpression(message);
  } catch (ExpressionParseException e) {
    throw new IllegalArgumentException("Invalid message for validator " + getClass().getSimpleName()
                      + ": \"" + StringEscapeUtil.escapeJava(message) + "\"");
  }
}

代码示例来源:origin: webx/citrus

/** 检查配置参数的合法性。 */
@Override
protected void init() throws Exception {
  super.init();
  String regexp = patternString;
  if (regexp != null && regexp.startsWith("!")) {
    regexp = trimToNull(regexp.substring(1));
  }
  assertNotNull(regexp, "missing regexp pattern");
  pattern = Pattern.compile(regexp);
}

代码示例来源:origin: webx/citrus

public TypeInfo getPrimitiveWrapperType() {
  if (isPrimitive()) {
    String name = getRawType().getName();
    TypeInfo wrapperType = PRIMITIVE_WRAPPERS.get(name);
    return assertNotNull(wrapperType, "Unknown primitive type: %s", name);
  }
  return this;
}

代码示例来源:origin: webx/citrus

/** 从request中取得当前请求的form或创建新的form。 */
public Form getForm(boolean forcePostOnly) {
  Object form = assertNotNull(request, "Could not getForm: request is null").getAttribute(requestKey);
  if (form == null) {
    form = new FormImpl(formConfig, FORM_KEY_PREFIX, forcePostOnly);
    ((Form) form).init(request);
    request.setAttribute(requestKey, form);
  }
  return (Form) form;
}

代码示例来源:origin: webx/citrus

/** 过滤出指定namespace下的elements,或不存在namespace的elements(unqualified)。 */
public static ElementSelector sameNs(Element element) {
  String namespaceURI = assertNotNull(element, "element").getNamespaceURI();
  return or(ns(namespaceURI), ns(null));
}

代码示例来源:origin: webx/citrus

/** 取得指定名称的mail builder。 */
public MailBuilder getMailBuilder(String id) throws MailNotFoundException {
  id = assertNotNull(trimToNull(id), "no mail id");
  MailBuilder builder = mails.get(id);
  if (builder == null) {
    throw new MailNotFoundException("Could not find mail builder: " + id);
  }
  // 返回mail builder的复本
  return builder.clone();
}

代码示例来源:origin: webx/citrus

@Override
  protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    Map<Object, Object> names = createManagedMap(element, parserContext);
    ElementSelector toolSelector = and(sameNs(element), name("tool"));
    for (Element subElement : subElements(element, toolSelector)) {
      String toolName = assertNotNull(trimToNull(subElement.getAttribute("id")), "no tool id");
      String beanName = trimToNull(subElement.getAttribute("beanName"));
      names.put(toolName, beanName);
    }
    builder.addPropertyValue("beanNames", names);
  }
}

代码示例来源:origin: webx/citrus

/** 创建一个新field。 */
public FieldImpl(FieldConfig fieldConfig, Group group) {
  super( //
      assertNotNull(group, "group").getForm().getTypeConverter(), // converter
      fieldConfig.getGroupConfig().getFormConfig().isConverterQuiet() // converter quiet
  );
  this.fieldConfig = assertNotNull(fieldConfig, "fieldConfig");
  this.group = group;
  this.fieldKey = group.getKey() + FIELD_KEY_SEPARATOR + fieldConfig.getKey();
  this.messageContext = MessageContextFactory.newInstance(this);
}

代码示例来源:origin: webx/citrus

/** 渲染模板,并将渲染的结果送到字符输出流中。 */
public void writeTo(String templateName, TemplateContext context, Writer writer) throws TemplateException,
                                            IOException {
  TemplateMatchResult result = findTemplate(templateName);
  TemplateEngine engine = assertNotNull(result.getEngine(), "templateEngine");
  engine.writeTo(result.getTemplateName(), context, writer);
}

代码示例来源:origin: webx/citrus

/** 验证一个字段。 */
@Override
protected boolean validate(Context context, String value) {
  Field fieldToCompare = assertNotNull(context.getField(fieldName), "field not found");
  NumberSupport thisValue = new NumberSupport(getNumberType(), value);
  NumberSupport otherValue = new NumberSupport(getNumberType(), fieldToCompare.getStringValue());
  try {
    return getOp().accept(thisValue.compareTo(otherValue));
  } catch (IllegalArgumentException e) {
    return false; // 包括NumberFormatException。如果getValue失败,验证失败。
  }
}

相关文章