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 varags parameter type. * @return * If there's no vararg parameter type, null will be returned. */ public JType listVarParamType() { if (varParam != null) return varParam.type(); else return null; }
/** * Returns the varags parameter type. * @return * If there's no vararg parameter type, null will be returned. */ public JType listVarParamType() { if (varParam != null) return varParam.type(); else return null; }
/** * Returns the varags parameter type. * @return * If there's no vararg parameter type, null will be returned. */ public JType listVarParamType() { if (varParam != null) return varParam.type(); else return null; }
/** * Returns the varags parameter type. * @return * If there's no vararg parameter type, null will be returned. */ public JType listVarParamType() { if (varParam != null) return varParam.type(); else return null; }
/** * Returns all the parameter types in an array. * @return * If there's no parameter, an empty array will be returned. */ public JType[] listParamTypes() { JType[] r = new JType[params.size()]; for (int i = 0; i < r.length; i++) r[i] = params.get(i).type(); return r; }
/** * Returns all the parameter types in an array. * @return * If there's no parameter, an empty array will be returned. */ public JType[] listParamTypes() { JType[] r = new JType[params.size()]; for (int i = 0; i < r.length; i++) r[i] = params.get(i).type(); return r; }
/** * Returns all the parameter types in an array. * @return * If there's no parameter, an empty array will be returned. */ public JType[] listParamTypes() { JType[] r = new JType[params.size()]; for (int i = 0; i < r.length; i++) r[i] = params.get(i).type(); return r; }
/** * Returns all the parameter types in an array. * @return * If there's no parameter, an empty array will be returned. */ public JType[] listParamTypes() { JType[] r = new JType[params.size()]; for (int i = 0; i < r.length; i++) r[i] = params.get(i).type(); return r; }
/** * Returns true if the method has the specified signature. */ public boolean hasSignature(JType[] argTypes) { JVar[] p = listParams(); if (p.length != argTypes.length) return false; for (int i = 0; i < p.length; i++) if (!p[i].type().equals(argTypes[i])) return false; return true; }
/** * Returns true if the method has the specified signature. */ public boolean hasSignature(JType[] argTypes) { JVar[] p = listParams(); if (p.length != argTypes.length) return false; for (int i = 0; i < p.length; i++) if (!p[i].type().equals(argTypes[i])) return false; return true; }
/** * Returns true if the method has the specified signature. */ public boolean hasSignature(JType[] argTypes) { JVar[] p = listParams(); if (p.length != argTypes.length) return false; for (int i = 0; i < p.length; i++) if (!p[i].type().equals(argTypes[i])) return false; return true; }
/** * Returns true if the method has the specified signature. */ public boolean hasSignature(JType[] argTypes) { JVar[] p = listParams(); if (p.length != argTypes.length) return false; for (int i = 0; i < p.length; i++) if (!p[i].type().equals(argTypes[i])) return false; return true; }
/** * Returns true if the method has the specified signature. */ public boolean hasSignature(JType[] argTypes) { JVar[] p = listParams(); if (p.length != argTypes.length) return false; for (int i = 0; i < p.length; i++) if (!p[i].type().equals(argTypes[i])) return false; return true; }
public String getGetterName(final JVar field) { final JType type = field.type(); final boolean bool = Boolean.class.getName().equals(type.fullName()); return getGetterName(bool, field.name()); }
private void addSuperConstructorInvocation(JMethod constructor, Map<String, JVar> superParametersToAdd) { JBlock constructorBody = constructor.body(); JInvocation invocation = constructorBody.invoke("super"); for (JVar arg : superParametersToAdd.values()) { JVar param = constructor.param(arg.type(), arg.name()); invocation.arg(param); } }
public static JMethod createGetter( final PluginContext ctx, final JDefinedClass parent, final JVar variable ) { final JMethod get = createBeanMethod( ctx, parent, variable.type(), getGetterName( ctx, variable ) ); get.body()._return( variable ); return get; }
public void moveTo(WriterBuilder builder) { currentBlock.add( JExpr._this().invoke(((AbstractWriterBuilder)builder).method) .arg(xswVar).arg(JExpr.cast(objectVar.type(), objectVar)).arg(rtContextVar)); }
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()); } } }