m._ref(ObjectInspector[].class), "argOIs", JExpr.newArray(m._ref(ObjectInspector.class), argTypes.length)); sub.assign(workspaceJVars[2], JExpr.newArray(m._ref(DrillDeferredObject.class), argTypes.length)); sub.assign(workspaceJVars[3], JExpr.newArray(m._ref(DrillDeferredObject.class), argTypes.length));
void start(JExpression $valueSize) { // [RESULT] // T[] x = new T[values.size()]; $array = var(arrayT, JExpr.newArray(componentT, $valueSize)); $index = var(int.class,JExpr.lit(0)); }
public static JArray newArray(JType type) { return newArray(type,null); }
public static JArray newArray(JType type) { return newArray(type,null); }
public static JArray newArray(JType type) { return newArray(type,null); }
public static JArray newArray(JType type) { return newArray(type,null); }
public static JArray newArray(JType type) { return newArray(type,null); }
/** * Generates {@code new T[size]}. * * @param type * The type of the array component. 'T' or {@code new T[size]}. */ public static JArray newArray(JType type, int size) { return newArray(type,lit(size)); }
/** * Generates {@code new T[size]}. * * @param type * The type of the array component. 'T' or {@code new T[size]}. */ public static JArray newArray(JType type, int size) { return newArray(type,lit(size)); }
/** * Generates {@code new T[size]}. * * @param type * The type of the array component. 'T' or {@code new T[size]}. */ public static JArray newArray(JType type, int size) { return newArray(type,lit(size)); }
/** * Generates {@code new T[size]}. * * @param type * The type of the array component. 'T' or {@code new T[size]}. */ public static JArray newArray(JType type, int size) { return newArray(type,lit(size)); }
/** * Generates {@code new T[size]}. * * @param type * The type of the array component. 'T' or {@code new T[size]}. */ public static JArray newArray(JType type, int size) { return newArray(type,lit(size)); }
private JExpression buildArgsArray(Iterable<? extends JExpression> parameters) { JArray argArray = JExpr.newArray(generationUtil.ref(Object.class)); for (JExpression parameter : parameters) { argArray.add(parameter); } return argArray; }
public JExpression create(final DatabindableDatatype datatype, final JCodeModel codeModel, final Object object) { final JArray array = JExpr.newArray(codeModel.BYTE); final byte[] bytes = (byte[]) object; for (int index = 0; index < bytes.length; index++) { array.add(JExpr.lit(bytes[index])); } return array; } }
void start(JExpression $valueSize) { // [RESULT] // T[] x = new T[values.size()]; $array = var(arrayT, JExpr.newArray(componentT, $valueSize)); $index = var(int.class,JExpr.lit(0)); }
private void add(final JDefinedClass bean, final JVar classParameter, final JTryBlock tryBlock) { final JBlock tryBody = tryBlock.body(); final JClass invokerClass = _classByNames( Constructor.class.getName(), MessageFormat.format("? extends {0}", bean.name())); final JVar invoker = tryBody.decl( invokerClass, "constructor", //$NON-NLS-1$ classParameter.invoke("getDeclaredConstructor").arg(JExpr.newArray(_classByNames(Class.class.getName()), 0))); tryBody._return(invoker.invoke("newInstance")); addRuntimeExceptionThrowingCatchTo(tryBlock, _classByNames(InstantiationException.class.getName())); addRuntimeExceptionThrowingCatchTo(tryBlock, _classByNames(NoSuchMethodException.class.getName())); addRuntimeExceptionThrowingCatchTo(tryBlock, _classByNames(InvocationTargetException.class.getName())); addRuntimeExceptionThrowingCatchTo(tryBlock, _classByNames(IllegalAccessException.class.getName())); addRuntimeExceptionThrowingCatchTo(tryBlock, _classByNames(IllegalArgumentException.class.getName())); }
public Object onComplexSingleField(FieldItem fieldItem) { final ClassItem fieldClassItem = (ClassItem) TypeUtils.getCommonBaseTypeItem( classContext, fieldItem); final JBlock block = JBlock.dummyInstance.block(); final JArray nodes = JExpr.newArray(codeModel.ref(Node.class)); nodes.add(JExpr.invoke(AccessorUtils.get(classContext, fieldItem)).invoke("createNode").arg( JExpr.lit(fieldItem.name))); final JConditional ifSet = block ._if(JExpr.invoke(AccessorUtils.isSet(classContext, fieldItem))); ifSet._then()._return(nodes); ifSet._else()._return(JExpr.newArray(codeModel.ref(Node.class))); return block; }
public JMethod generate(ClassContext classContext, FieldItem fieldItem, JDefinedClass theClass) { final JCodeModel codeModel = getCodeModel(classContext); final JClass nodeClass = codeModel.ref(Node.class); final JType nodeArrayType = nodeClass.array(); final String methodName = "create" + fieldItem.name + "Nodes"; final JMethod createNode = theClass.method(JMod.PUBLIC, nodeArrayType, methodName); final JStatement statement = (JStatement) fieldItem.visit(new CreateFieldNodeVisitor(classContext)); if (statement != null) { createNode.body().add(statement); } else { createNode.body()._return(JExpr.newArray(nodeClass, 0)); } return createNode; } }
@Override public JExpression buildConstructorCall(ASTConstructor constructor, ASTType type, List<? extends JExpression> parameters) { //InjectionUtil.setConstructor(Class<T> targetClass, Class[] argClasses,Object[] args) JInvocation constructorInvocation = generationUtil.ref(InjectionUtil.class).staticInvoke(InjectionUtil.CALL_CONSTRUCTOR_METHOD) .arg(buildTargetType(type)); //add classes JArray classArray = JExpr.newArray(generationUtil.ref(Class.class)); for (ASTParameter parameterType : constructor.getParameters()) { classArray.add(generationUtil.ref(parameterType.getASTType()).dotclass()); } constructorInvocation.arg(classArray); //add args constructorInvocation.arg(buildArgsArray(parameters)); return constructorInvocation; }
@Override public JInvocation buildMethodCall(boolean cast, ASTMethod method, List<? extends JExpression> parameters, TypedExpression expression) { JClass targetType = generationUtil.ref(expression.getType()); //InjectionUtil.getInstance().setMethod(Class targetClass, Object target, String method, Class[] argClasses,Object[] args) JInvocation methodInvocation = generationUtil.ref(InjectionUtil.class).staticInvoke(InjectionUtil.CALL_METHOD_METHOD) .arg(buildTargetType(method.getReturnType())) .arg(targetType.dotclass()) .arg(expression.getExpression()) .arg(method.getName()); //add classes JArray classArray = JExpr.newArray(generationUtil.ref(Class.class)); for (ASTParameter parameter : method.getParameters()) { classArray.add(generationUtil.ref(parameter.getASTType()).dotclass()); } methodInvocation.arg(classArray); //add args methodInvocation.arg(buildArgsArray(parameters)); return methodInvocation; }