private String[] getMethodParameterNames(Method method, String raw) { return getParameterNames(method, method.getName(), method.getParameterTypes(), raw); }
public String[] lookupParameterNames(AccessibleObject accessible) { return lookupParameterNames(accessible, true); }
public UrlJavadocProvider(URL base) throws IOException { this.base = base; streamToString(urlToStream(new URL(base + "/package-list"))); }
public String[] lookupParameterNames(AccessibleObject accessible, boolean throwExceptionIfMissing) { if (!(accessible instanceof Member)) throw new IllegalArgumentException(accessible.getClass().getCanonicalName()); try { String javadocFilename = getJavadocFilename((Member) accessible); InputStream stream = provider.getRawJavadoc(javadocFilename); String raw = streamToString(stream); if (accessible instanceof Method) return getMethodParameterNames((Method) accessible, raw); else if (accessible instanceof Constructor<?>) return getConstructorParameterNames((Constructor<?>) accessible, raw); else throw new IllegalArgumentException(accessible.getClass().getCanonicalName()); } catch (IOException e) { if (throwExceptionIfMissing) throw new ParameterNamesNotFoundException(accessible.toString(), e); else return Paranamer.EMPTY_NAMES; } catch (ParameterNamesNotFoundException e) { if (throwExceptionIfMissing) throw e; else return Paranamer.EMPTY_NAMES; } }
protected static String getCanonicalName(Class<?> klass) { // doesn't support names of nested classes if (klass.isArray()) return getCanonicalName(klass.getComponentType()) + "[]"; return klass.getName(); }
public InputStream getRawJavadoc(String fqn) throws IOException { return urlToStream(new URL(base + "/" + fqn)); } }
@Override public void execute() throws MojoExecutionException { try { project.addCompileSourceRoot(outputDir.getAbsolutePath()); File output = new File(outputDir, outputName); if (output.exists() && project.getFile().lastModified() < output.lastModified()) { getLog().info("No changes detected, skipping: " + output); return; } if (Strings.isNullOrEmpty(javadoc)) getLog().warn("Javadocs not attached for paranamer."); else paranamer = new CachingParanamer(new JavadocParanamer(getFile(javadoc))); File jar = getFile(input); JarMethodScanner scanner = new JarMethodScanner(jar); List<Method> methods = Lists.newArrayList( Iterables.filter(scanner.getStaticMethods(scan), new Predicate<Method>() { @Override public boolean apply(Method input) { return exclude == null || !input.getName().matches(exclude); } })); String generated = generate(methods); output.getParentFile().mkdirs(); getLog().info("Generating " + output.getAbsoluteFile()); Files.write(generated, output, Charsets.UTF_8); } catch (Exception e) { throw new MojoExecutionException("java generation", e); } }
public String[] lookupParameterNames(AccessibleObject accessible, boolean throwExceptionIfMissing) { if (!(accessible instanceof Member)) throw new IllegalArgumentException(accessible.getClass().getCanonicalName()); try { String javadocFilename = getJavadocFilename((Member) accessible); InputStream stream = provider.getRawJavadoc(javadocFilename); String raw = streamToString(stream); if (accessible instanceof Method) return getMethodParameterNames((Method) accessible, raw); else if (accessible instanceof Constructor<?>) return getConstructorParameterNames((Constructor<?>) accessible, raw); else throw new IllegalArgumentException(accessible.getClass().getCanonicalName()); } catch (IOException e) { if (throwExceptionIfMissing) throw new ParameterNamesNotFoundException(accessible.toString(), e); else return Paranamer.EMPTY_NAMES; } catch (ParameterNamesNotFoundException e) { if (throwExceptionIfMissing) throw e; else return Paranamer.EMPTY_NAMES; } }
protected static String getJavadocFilename(Member member) { return getCanonicalName(member.getDeclaringClass()).replace('.', '/') + ".html"; }
public InputStream getRawJavadoc(String fqn) throws IOException { return urlToStream(new URL(base + "/" + fqn)); } }
public UrlJavadocProvider(URL base) throws IOException { this.base = base; streamToString(urlToStream(new URL(base + "/package-list"))); }
protected static String getCanonicalName(Class<?> klass) { // doesn't support names of nested classes if (klass.isArray()) return getCanonicalName(klass.getComponentType()) + "[]"; return klass.getName(); }
private String[] getMethodParameterNames(Method method, String raw) { return getParameterNames(method, method.getName(), method.getParameterTypes(), raw); }
public String[] lookupParameterNames(AccessibleObject accessible) { return lookupParameterNames(accessible, true); }
protected static String getJavadocFilename(Member member) { return getCanonicalName(member.getDeclaringClass()).replace('.', '/') + ".html"; }
private String[] getConstructorParameterNames(Constructor<?> cons, String raw) { return getParameterNames(cons, cons.getDeclaringClass().getSimpleName(), cons.getParameterTypes(), raw); }
private String[] getConstructorParameterNames(Constructor<?> cons, String raw) { return getParameterNames(cons, cons.getDeclaringClass().getSimpleName(), cons.getParameterTypes(), raw); }