private static void processMethodCollectionForSerializableSupport(Iterator<JMethod> methods, DataOutputStream dataOutputStream) throws IOException { TreeMap<String, JMethod> sortedMethods = new TreeMap<>(); while (methods.hasNext()) { JMethod method = methods.next(); //Collect non-private methods if ((method.mods().getValue() & JMod.PRIVATE) != JMod.PRIVATE) { sortedMethods.put(method.name(), method); } } for (JMethod method : sortedMethods.values()) { dataOutputStream.writeUTF(method.name()); dataOutputStream.writeInt(method.mods().getValue()); if (method.type() != null) { dataOutputStream.writeUTF(method.type().fullName()); } for (JVar param : method.params()) { dataOutputStream.writeUTF(param.type().fullName()); } } }
private void addOverrideBuilder(JDefinedClass thisJDefinedClass, JMethod parentBuilder, JVar parentParam) { if (thisJDefinedClass.getMethod(parentBuilder.name(), new JType[] {parentParam.type()}) == null) { JMethod builder = thisJDefinedClass.method(parentBuilder.mods().getValue(), thisJDefinedClass, parentBuilder.name()); builder.annotate(Override.class); JVar param = builder.param(parentParam.type(), parentParam.name()); JBlock body = builder.body(); body.invoke(JExpr._super(), parentBuilder).arg(param); body._return(JExpr._this()); } } }
/** * Returns the Java language modifiers for this <code>JavaMethod</code>, encoded in an integer. * * @return the <code>int</code> representing the modifiers for this method. * * @see java.lang.reflect.Modifier */ public int getModifiers() { return xjcMethod.mods().getValue(); }
/** * Returns the Java language modifiers for this <code>JavaConstructor</code>, encoded in an integer. * * @return the <code>int</code> representing the modifiers for this constructor. * * @see java.lang.reflect.Modifier */ public int getModifiers() { return xjcConstructor.mods().getValue(); }
private void removePrivateStaticCopyMethods(ClassOutline classOutline) { JDefinedClass impl = classOutline.implClass; Iterator<JMethod> methods = impl.methods().iterator(); while (methods.hasNext()) { JMethod method = methods.next(); if ((method.mods().getValue() & (JMod.PRIVATE | JMod.STATIC)) == 0) { continue; } if (method.name().startsWith("copy")) { methods.remove(); } } }
private static void processMethodCollectionForSerializableSupport(Iterator<JMethod> methods, DataOutputStream dataOutputStream) throws IOException { TreeMap<String, JMethod> sortedMethods = new TreeMap<>(); while (methods.hasNext()) { JMethod method = methods.next(); //Collect non-private methods if ((method.mods().getValue() & JMod.PRIVATE) != JMod.PRIVATE) { sortedMethods.put(method.name(), method); } } for (JMethod method : sortedMethods.values()) { dataOutputStream.writeUTF(method.name()); dataOutputStream.writeInt(method.mods().getValue()); if (method.type() != null) { dataOutputStream.writeUTF(method.type().fullName()); } for (JVar param : method.params()) { dataOutputStream.writeUTF(param.type().fullName()); } } }
public static JMethod recreateMethod(JMethod method, JDefinedClass definedClass, JType overrideReturnType) { Iterator<JMethod> methods = definedClass.methods().iterator(); while (methods.hasNext()) { if (method.equals(methods.next())) { methods.remove(); break; } } JMods mods = method.mods(); JType newReturnType = overrideReturnType != null ? overrideReturnType : method.type(); JMethod newMethod = definedClass.method(mods.getValue(), newReturnType, method.name()); JVar[] params = method.listParams(); if (params != null) { for (JVar param : params) { newMethod.param(param.type(), param.name()); } } return newMethod; }
int mods = jmethod.mods().getValue();
int mods = jmethod.mods().getValue();
int mods = jmethod.mods().getValue();
int mods = jmethod.mods().getValue();
String name = listGetterMethod.name(); int mods = JMod.PUBLIC | listGetterMethod.mods().getValue() & JMod.FINAL; JMethod fluentMethod = implClass.method(mods, implClass, FLUENT_SETTER_METHOD_PREFIX + name.substring(GETTER_METHOD_PREFIX_LEN));
String name = listGetterMethod.name(); int mods = JMod.PUBLIC | listGetterMethod.mods().getValue() & JMod.FINAL; JMethod fluentMethod = implClass.method(mods, implClass, FLUENT_SETTER_METHOD_PREFIX + name.substring(GETTER_METHOD_PREFIX_LEN));
String name = listGetterMethod.name(); int mods = JMod.PUBLIC | listGetterMethod.mods().getValue() & JMod.FINAL; JMethod fluentMethod = implClass.method(mods, implClass, FLUENT_SETTER_METHOD_PREFIX + name.substring(GETTER_METHOD_PREFIX_LEN));
int mods = method.mods().getValue(); JType mtype = method.type(); if (remapRet) {
int mods = method.mods().getValue(); mtype = mtype.unboxify(); method = dc.method(mods, method.type(), setterName);
private void addOverrideBuilder(JDefinedClass thisJDefinedClass, JMethod parentBuilder, JVar parentParam) { if (thisJDefinedClass.getMethod(parentBuilder.name(), new JType[] {parentParam.type()}) == null) { JMethod builder = thisJDefinedClass.method(parentBuilder.mods().getValue(), thisJDefinedClass, parentBuilder.name()); builder.annotate(Override.class); JVar param = builder.param(parentParam.type(), parentParam.name()); JBlock body = builder.body(); body.invoke(JExpr._super(), parentBuilder).arg(param); body._return(JExpr._this()); } } }
String name = setterMethod.name(); int mods = JMod.PUBLIC | setterMethod.mods().getValue() & JMod.FINAL; JMethod fluentMethod = implClass.method(mods, implClass, FLUENT_SETTER_METHOD_PREFIX + name.substring(SETTER_METHOD_PREFIX_LEN));
String name = setterMethod.name(); int mods = JMod.PUBLIC | setterMethod.mods().getValue() & JMod.FINAL; JMethod fluentMethod = implClass.method(mods, implClass, FLUENT_SETTER_METHOD_PREFIX + name.substring(SETTER_METHOD_PREFIX_LEN));
private void replaceCollectionGetter(FieldOutline field, final JMethod getter) { JDefinedClass clazz = field.parent().implClass; // remove the old getter clazz.methods().remove(getter); // and create a new one JMethod newGetter = field.parent().implClass.method(getter.mods().getValue(), getter.type(), getter.name()); JBlock block = newGetter.body(); JVar ret = block.decl(getJavaType(field), "ret"); JCodeModel codeModel = field.parent().implClass.owner(); JVar param = generateMethodParameter(getter, field); JConditional conditional = block._if(param.eq(JExpr._null())); conditional._then().assign(ret, getEmptyCollectionExpression(codeModel, param)); conditional._else().assign(ret, getUnmodifiableWrappedExpression(codeModel, param)); block._return(ret); getter.javadoc().append("Returns unmodifiable collection."); }