/** * Check if a name string refers to a given type. * * @param name * the name of a Java type * @param owner * the current code model for type generation * @return <code>true</code> when the given name refers to a primitive Java * type (e.g. "int"), otherwise <code>false</code> */ public static boolean isPrimitive(String name, JCodeModel owner) { try { return JType.parse(owner, name) != owner.VOID; } catch (IllegalArgumentException e) { return false; } }
/** * Check if a name string refers to a given type. * * @param name * the name of a Java type * @param owner * the current code model for type generation * @return <code>true</code> when the given name refers to a primitive Java * type (e.g. "int"), otherwise <code>false</code> */ public static boolean isPrimitive(String name, JCodeModel owner) { try { return JType.parse(owner, name) != owner.VOID; } catch (IllegalArgumentException e) { return false; } }
/** * Check if a name string refers to a given type. * * @param name * the name of a Java type * @param owner * the current code model for type generation * @return <code>true</code> when the given name refers to a primitive Java * type (e.g. "int"), otherwise <code>false</code> */ public static boolean isPrimitive(String name, JCodeModel owner) { try { return JType.parse(owner, name) != owner.VOID; } catch (IllegalArgumentException e) { return false; } }
public JPrimitiveType getPrimitiveType() { Class v = boxToPrimitive.get(_class); if(v!=null) return JType.parse(JCodeModel.this,v.getName()); else return null; }
public JPrimitiveType getPrimitiveType() { Class<?> v = boxToPrimitive.get(_class); if(v!=null) return JType.parse(JCodeModel.this,v.getName()); else return null; }
public JPrimitiveType getPrimitiveType() { Class<?> v = boxToPrimitive.get(_class); if(v!=null) return JType.parse(JCodeModel.this,v.getName()); else return null; }
public JPrimitiveType getPrimitiveType() { Class<?> v = boxToPrimitive.get(_class); if(v!=null) return JType.parse(JCodeModel.this,v.getName()); else return null; }
public JPrimitiveType getPrimitiveType() { Class<?> v = boxToPrimitive.get(_class); if(v!=null) return JType.parse(JCodeModel.this,v.getName()); else return null; }
public JType _ref(Class c) { if(c.isPrimitive()) return JType.parse(this,c.getName()); else return ref(c); }
public JType _ref(Class<?> c) { if(c.isPrimitive()) return JType.parse(this,c.getName()); else return ref(c); }
/** * <p>getGeneratorType.</p> * * @param clazz a {@link java.lang.Class} object. * @return a {@link com.sun.codemodel.JType} object. */ public JType getGeneratorType(final Class<?> clazz) { return clazz.isPrimitive() ? JType.parse(codeModel, clazz.getSimpleName()) : codeModel.ref(clazz); }
public JType _ref(Class<?> c) { if(c.isPrimitive()) return JType.parse(this,c.getName()); else return ref(c); }
public JType _ref(Class<?> c) { if(c.isPrimitive()) return JType.parse(this,c.getName()); else return ref(c); }
public JType _ref(Class<?> c) { if(c.isPrimitive()) return JType.parse(this,c.getName()); else return ref(c); }
public JType getGeneratorType(final Class<?> clazz) { return clazz.isPrimitive() ? JType.parse(codeModel, clazz.getSimpleName()) : codeModel.ref(clazz); }
/** Returns true if the given type is a primitive int; false otherwise. */ private boolean isInt(JType type) { JCodeModel codeModel = type.owner(); return type.isPrimitive() && codeModel.INT.equals( JType.parse(codeModel, type.name())); } }
/** Returns true if the given type is a primitive int; false otherwise. */ private boolean isInt(JType type) { JCodeModel codeModel = type.owner(); return type.isPrimitive() && codeModel.INT.equals( JType.parse(codeModel, type.name())); } }
/** * Obtains a type object from a type name. * * <p> * This method handles primitive types, arrays, and existing {@link Class}es. * * @exception ClassNotFoundException * If the specified type is not found. */ public JType parseType(String name) throws ClassNotFoundException { // array if(name.endsWith("[]")) return parseType(name.substring(0,name.length()-2)).array(); // try primitive type try { return JType.parse(this,name); } catch (IllegalArgumentException e) { ; } // existing class return new TypeNameParser(name).parseTypeName(); }
/** * Obtains a type object from a type name. * * <p> * This method handles primitive types, arrays, and existing {@link Class}es. * * @exception ClassNotFoundException * If the specified type is not found. */ public JType parseType(String name) throws ClassNotFoundException { // array if(name.endsWith("[]")) return parseType(name.substring(0,name.length()-2)).array(); // try primitive type try { return JType.parse(this,name); } catch (IllegalArgumentException e) { ; } // existing class return new TypeNameParser(name).parseTypeName(); }
private List<Partitioner> createClassInstances(int actualPartitions) throws SchemaChangeException { // set up partitioning function final LogicalExpression expr = config.getExpr(); final ClassGenerator<Partitioner> cg = context.getClassProducer().createGenerator(Partitioner.TEMPLATE_DEFINITION).getRoot(); ClassGenerator<Partitioner> cgInner = cg.getInnerGenerator("OutgoingRecordBatch"); final LogicalExpression materializedExpr = context.getClassProducer().materialize(expr, incoming); // generate code to copy from an incoming value vector to the destination partition's outgoing value vector JExpression bucket = JExpr.direct("bucket"); // generate evaluate expression to determine the hash ClassGenerator.HoldingContainer exprHolder = cg.addExpr(materializedExpr); cg.getEvalBlock().decl(JType.parse(cg.getModel(), "int"), "bucket", exprHolder.getValue().mod(JExpr.lit(outGoingBatchCount))); cg.getEvalBlock()._return(cg.getModel().ref(Math.class).staticInvoke("abs").arg(bucket)); CopyUtil.generateCopies(cgInner, incoming, incoming.getSchema().getSelectionVectorMode() == SelectionVectorMode.FOUR_BYTE); // compile and setup generated code List<Partitioner> subPartitioners = cg.getCodeGenerator().getImplementationClass(actualPartitions); return subPartitioners; }