Java Code Examples for com.sun.codemodel.JMod.FINAL

The following are Jave code examples for showing how to use FINAL of the com.sun.codemodel.JMod class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: drill   File: ClassGenerator.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked")
ClassGenerator(CodeGenerator<T> codeGenerator, MappingSet mappingSet, SignatureHolder signature,
               EvaluationVisitor eval, JDefinedClass clazz, JCodeModel model,
               OptionSet optionManager) throws JClassAlreadyExistsException {
  this.codeGenerator = codeGenerator;
  this.clazz = clazz;
  this.mappings = mappingSet;
  this.sig = signature;
  this.evaluationVisitor = eval;
  this.model = model;
  this.optionManager = optionManager;

  blocks = (LinkedList<SizedJBlock>[]) new LinkedList[sig.size()];
  for (int i =0; i < sig.size(); i++) {
    blocks[i] = Lists.newLinkedList();
  }
  rotateBlock();

  for (SignatureHolder child : signature.getChildHolders()) {
    Class<?> innerClass = child.getSignatureClass();
    String innerClassName = innerClass.getSimpleName();

    // Create the inner class as private final. If the template (super) class
    // is static, then make the subclass static as well. Note the conversion
    // from the JDK Modifier values to the JCodeModel JMod values: the
    // values are different.

    int mods = JMod.PRIVATE + JMod.FINAL;
    if ((innerClass.getModifiers() & Modifier.STATIC) != 0) {
      mods += JMod.STATIC;
    }
    JDefinedClass innerClazz = clazz._class(mods, innerClassName);
    innerClasses.put(innerClassName, new ClassGenerator<>(codeGenerator, mappingSet, child, eval, innerClazz, model, optionManager));
  }
  long maxExprsNumber = optionManager != null ? optionManager.getOption(ExecConstants.CODE_GEN_EXP_IN_METHOD_SIZE_VALIDATOR) : 50;
  maxIndex = Math.round((0xFFFF / (1 + 3. / (3 * sig.size() + maxExprsNumber)) - 1000) / 3);
}