@Override public List<Field> getFields() { return m.getFields(); }
/** * Sets all method parameters in the specified model to <code>final</code>. * * @param model the model to operate on */ @Override public void accept(T model) { requireNonNull(model).getMethods() .forEach(m -> m.getFields() .forEach(f -> f.final_()) ); } }
/** * Returns the a method with the specified signature exists. * * @param model the model * @param method the method name to look for * @param params the number of parameters in the signature * @return <code>true</code> if found, else <code>false</code> */ protected boolean hasMethod(T model, String method, int params) { requireNonNull(model); requireNonNull(method); requireNonNull(params); Method found = null; for (Method m : model.getMethods()) { if (method.equals(m.getName()) && m.getFields().size() == params) { found = m; break; } } return found != null; } }
/** * Copy constructor. * * @param prototype the prototype */ protected MethodImpl(final Method prototype) { parent = prototype.getParent().orElse(null); name = requireNonNull(prototype).getName(); type = requireNonNull(prototype.getType()); javadoc = prototype.getJavadoc().map(Copier::copy).orElse(null); annotations = Copier.copy(prototype.getAnnotations()); imports = Copier.copy(prototype.getImports()); generics = Copier.copy(prototype.getGenerics()); params = Copier.copy(prototype.getFields()); code = Copier.copy(prototype.getCode(), s -> s); modifiers = Copier.copy(prototype.getModifiers(), c -> c.copy(), EnumSet.noneOf(Modifier.class)); exceptions = new HashSet<>(prototype.getExceptions()); }
@Override public List<Field> getFields() { return m.getFields(); }
@Override public List<Field> getFields() { return m.getFields(); }
/** * Sets all method parameters in the specified model to <code>final</code>. * * @param model the model to operate on */ @Override public void accept(T model) { requireNonNull(model).getMethods() .forEach(m -> m.getFields() .forEach(f -> f.final_()) ); } }
/** * Sets all method parameters in the specified model to <code>final</code>. * * @param model the model to operate on */ @Override public void accept(T model) { requireNonNull(model).getMethods() .forEach(m -> m.getFields() .forEach(f -> f.final_()) ); } }
/** * Returns the a method with the specified signature exists. * * @param model the model * @param method the method name to look for * @param params the number of parameters in the signature * @return <code>true</code> if found, else <code>false</code> */ protected boolean hasMethod(T model, String method, int params) { requireNonNull(model); requireNonNull(method); requireNonNull(params); Method found = null; for (Method m : model.getMethods()) { if (method.equals(m.getName()) && m.getFields().size() == params) { found = m; break; } } return found != null; } }
/** * Returns the a method with the specified signature exists. * * @param model the model * @param method the method name to look for * @param params the number of parameters in the signature * @return <code>true</code> if found, else <code>false</code> */ protected boolean hasMethod(T model, String method, int params) { requireNonNull(model); requireNonNull(method); requireNonNull(params); Method found = null; for (Method m : model.getMethods()) { if (method.equals(m.getName()) && m.getFields().size() == params) { found = m; break; } } return found != null; } }
@Override public String fieldSeparator(Method model) { if (model.getFields().size() > 3) { return "," + nl() + tab() + tab(); } else return ", "; }
/** * Copy constructor. * * @param prototype the prototype */ protected MethodImpl(final Method prototype) { parent = prototype.getParent().orElse(null); name = requireNonNull(prototype).getName(); type = requireNonNull(prototype.getType()); javadoc = prototype.getJavadoc().map(Copier::copy).orElse(null); annotations = Copier.copy(prototype.getAnnotations()); imports = Copier.copy(prototype.getImports()); generics = Copier.copy(prototype.getGenerics()); params = Copier.copy(prototype.getFields()); code = Copier.copy(prototype.getCode(), s -> s); modifiers = Copier.copy(prototype.getModifiers(), c -> c.copy(), EnumSet.noneOf(Modifier.class)); exceptions = new HashSet<>(prototype.getExceptions()); }
/** * Copy constructor. * * @param prototype the prototype */ protected MethodImpl(final Method prototype) { name = requireNonNull(prototype).getName(); type = requireNonNull(prototype.getType()); javadoc = prototype.getJavadoc().map(Copier::copy).orElse(null); annotations = Copier.copy(prototype.getAnnotations()); generics = Copier.copy(prototype.getGenerics()); params = Copier.copy(prototype.getFields()); code = Copier.copy(prototype.getCode(), s -> s); modifiers = Copier.copy(prototype.getModifiers(), c -> c.copy(), EnumSet.noneOf(Modifier.class)); exceptions = new HashSet<>(prototype.getExceptions()); }
@Override public Optional<String> transform(Generator gen, Method model) { requireNonNulls(gen, model); return Optional.of( renderJavadoc(gen, model) + renderAnnotations(gen, model) + renderModifiers(gen, model) + renderGenerics(gen, model) + renderType(gen, model) + renderName(gen, model) + ((model.getFields().size() > 3) ? "(" + nl() + tab() + tab() : "(") + renderFields(gen, model) + ") " + renderThrows(gen, model) + renderCode(gen, model) ); }