org.openide.util.Parameters.javaIdentifierOrNull()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(97)

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

Parameters.javaIdentifierOrNull介绍

[英]Asserts the parameter value is either null or a Java identifier.
[中]断言参数值为null或Java标识符。

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-util

/**
 * Asserts the parameter value is not <code>null</code> and it is
 * a Java identifier.
 *
 * @param  name the parameter name.
 * @param  value the parameter value.
 * @throws NullPointerException if the parameter value is <code>null</code>.
 * @throws IllegalArgumentException if the parameter value is not
 *         a Java identifier.
 */
public static void javaIdentifier(CharSequence name, CharSequence value) {
  notNull(name, value);
  javaIdentifierOrNull(name, value);
}

代码示例来源:origin: in.jlibs/org-openide-util

/**
 * Asserts the parameter value is not <code>null</code> and it is
 * a Java identifier.
 *
 * @param  name the parameter name.
 * @param  value the parameter value.
 * @throws NullPointerException if the parameter value is <code>null</code>.
 * @throws IllegalArgumentException if the parameter value is not
 *         a Java identifier.
 */
public static void javaIdentifier(CharSequence name, CharSequence value) {
  notNull(name, value);
  javaIdentifierOrNull(name, value);
}

代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util

/**
 * Asserts the parameter value is not <code>null</code> and it is
 * a Java identifier.
 *
 * @param  name the parameter name.
 * @param  value the parameter value.
 * @throws NullPointerException if the parameter value is <code>null</code>.
 * @throws IllegalArgumentException if the parameter value is not
 *         a Java identifier.
 */
public static void javaIdentifier(CharSequence name, CharSequence value) {
  notNull(name, value);
  javaIdentifierOrNull(name, value);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-websvc-utilities

/**
 * Creates a new annotation argument whose value is an array.
 *
 * @param argumentName the argument name; cannot be null.
 * @param argumentValues the argument values to initialize the array with; cannot be null.
 * @return the new annotation argument; never null.
 */
public ExpressionTree createAnnotationArgument(String argumentName, List<? extends ExpressionTree> argumentValues) {
  Parameters.javaIdentifierOrNull("argumentName", argumentName); // NOI18N
  Parameters.notNull("argumentValues", argumentValues); // NOI18N
  TreeMaker make = getTreeMaker();
  ExpressionTree argumentValuesTree = make.NewArray(null, Collections.<ExpressionTree>emptyList(), argumentValues);
  if (argumentName == null) {
    return argumentValuesTree;
  } else {
    return make.Assignment(make.Identifier(argumentName), argumentValuesTree);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-websvc-utilities

/**
 * Creates a new annotation argument whose value is a literal.
 *
 * @param  argumentName the argument name; cannot be null.
 * @param  argumentValue the argument value; cannot be null. The semantics
 *         of this parameter is the same as of the parameters of
 *         {@link TreeMaker#Literal(Object)}.
 * @return the new annotation argument; never null.
 */
public ExpressionTree createAnnotationArgument(String argumentName, Object argumentValue) {
  Parameters.javaIdentifierOrNull("argumentName", argumentName); // NOI18N
  Parameters.notNull("argumentValue", argumentValue); // NOI18N
  TreeMaker make = getTreeMaker();
  ExpressionTree argumentValueTree = make.Literal(argumentValue);
  if (argumentName == null) {
    return argumentValueTree;
  } else {
    return make.Assignment(make.Identifier(argumentName), argumentValueTree);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-websvc-utilities

/**
 * Creates a new annotation argument whose value is a member of a type. For
 * example it can be used to generate <code>@Target(ElementType.CONSTRUCTOR)</code>.
 *
 * @param  argumentName the argument name; cannot be null.
 * @param  argumentType the fully-qualified name of the type whose member is to be invoked
 *         (e.g. <code>java.lang.annotations.ElementType</code> in the previous
 *         example); cannot be null.
 * @param  argumentTypeField a field of <code>argumentType</code>
 *         (e.g. <code>CONSTRUCTOR</code> in the previous example);
 *         cannot be null.
 * @return the new annotation argument; never null.
 */
public ExpressionTree createAnnotationArgument(String argumentName, String argumentType, String argumentTypeField) {
  Parameters.javaIdentifierOrNull("argumentName", argumentName); // NOI18N
  Parameters.notNull("argumentType", argumentType); // NOI18N
  Parameters.javaIdentifier("argumentTypeField", argumentTypeField); // NOI18N
  TreeMaker make = getTreeMaker();
  MemberSelectTree argumentValueTree = make.MemberSelect(createQualIdent(argumentType), argumentTypeField);
  if (argumentName == null) {
    return argumentValueTree;
  } else {
    return make.Assignment(make.Identifier(argumentName), argumentValueTree);
  }
}

相关文章