Java Code Examples for com.sun.codemodel.JMod#STATIC
The following examples show how to use
com.sun.codemodel.JMod#STATIC .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PojoBuilder.java From springmvc-raml-plugin with Apache License 2.0 | 6 votes |
private Map<String, JFieldVar> getNonTransientAndNonStaticFields() { Map<String, JFieldVar> nonStaticNonTransientFields = new LinkedHashMap<>(); if (pojo instanceof JDefinedClass) { Map<String, JFieldVar> fields = ((JDefinedClass) pojo).fields(); Iterator<Map.Entry<String, JFieldVar>> iterator = fields.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<String, JFieldVar> pair = iterator.next(); // If a field is not static or transient if ((pair.getValue().mods().getValue() & (JMod.STATIC | JMod.TRANSIENT)) == 0) { nonStaticNonTransientFields.put(pair.getKey(), pair.getValue()); } } } return nonStaticNonTransientFields; }
Example 2
Source File: ClassGenerator.java From Bats with Apache License 2.0 | 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; constantVars = new HashMap<>(); 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.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); }
Example 3
Source File: DeepCopyGenerator.java From jaxb2-rich-contract-plugin with MIT License | 5 votes |
private void generateFieldCopyExpressions(final CopyGenerator cloneGenerator, final JBlock body, final JExpression targetObject, final JExpression sourceObject) { for (final FieldOutline fieldOutline : this.classOutline.getDeclaredFields()) { final JFieldVar field = PluginUtil.getDeclaredField(fieldOutline); if (field != null) { if ((field.mods().getValue() & (JMod.FINAL | JMod.STATIC)) == 0) { generateFieldCopyExpression(cloneGenerator, body, targetObject, field, targetObject.ref(field.name()), sourceObject.ref(field.name())); } } } }
Example 4
Source File: PropertyFieldAccessorFactory.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 4 votes |
public PropertyFieldAccessor(final FieldOutline fieldOutline, JExpression targetObject) { super(); this.fieldOutline = fieldOutline; this.targetObject = targetObject; this.fieldAccessor = fieldOutline.create(targetObject); final String publicName = fieldOutline.getPropertyInfo().getName( true); final String privateName = fieldOutline.getPropertyInfo().getName( false); this.theClass = fieldOutline.parent().implClass; final String setterName = "set" + publicName; final JMethod getGetter = theClass.getMethod("get" + publicName, ABSENT); final JMethod isGetter = theClass.getMethod("is" + publicName, ABSENT); final JFieldVar field = theClass.fields().get(privateName); this.field = field != null && ((field.mods().getValue() & JMod.PROTECTED) != 0) && ((field.mods().getValue() & JMod.STATIC) == 0) && ((field.mods().getValue() & JMod.FINAL) == 0) ? field : null; this.getter = getGetter != null ? getGetter : (isGetter != null ? isGetter : null); this.type = this.getter != null ? this.getter.type() : fieldOutline .getRawType(); this.fieldType = this.field != null ? this.field.type() : this.type; final JFieldVar constantField = theClass.fields().get(publicName); this.constantField = constantField != null && ((constantField.mods().getValue() & JMod.PUBLIC) != 0) && ((constantField.mods().getValue() & JMod.STATIC) != 0) && ((constantField.mods().getValue() & JMod.FINAL) != 0) ? constantField : null; // fieldOutline.getRawType(); final JType rawType = fieldOutline.getRawType(); final JMethod boxifiedSetter = theClass.getMethod(setterName, new JType[] { rawType.boxify() }); final JMethod unboxifiedSetter = theClass.getMethod(setterName, new JType[] { rawType.unboxify() }); this.setter = boxifiedSetter != null ? boxifiedSetter : unboxifiedSetter; this.isSetter = theClass.getMethod("isSet" + publicName, ABSENT); this.unSetter = theClass.getMethod("unset" + publicName, ABSENT); }
Example 5
Source File: PluginImpl.java From immutable-xjc with MIT License | 4 votes |
public boolean isStatic(JFieldVar var) { return (var.mods().getValue() & JMod.STATIC) != 0; }