Ejemplo n.º 1
0
  /**
   * Builds a new {@link ArrayCreation} instance.
   *
   * @param typeBinding the type binding of the instantiated type
   * @param arrayInitializers the expressions forming the array initializer
   * @return a new array creation instance
   */
  public ArrayCreation newArray(ITypeBinding typeBinding, Expression arrayInitializers) {
    final ArrayInitializer ai = ast.newArrayInitializer();
    expressions(ai).add(arrayInitializers);

    final ArrayCreation ac = ast.newArrayCreation();
    ac.setType((ArrayType) toType(ast, typeBinding));
    ac.setInitializer(ai);
    return ac;
  }
Ejemplo n.º 2
0
 @SuppressWarnings("unchecked")
 public ArrayCreation newArrayCreation(Type type, Collection<Expression> values) {
   ArrayCreation ac = ast.newArrayCreation();
   ArrayInitializer initializer = ast.newArrayInitializer();
   for (Expression expr : values) {
     initializer.expressions().add(expr);
   }
   ac.setInitializer(initializer);
   ac.setType(ast.newArrayType(type));
   return ac;
 }