public Invokation out(@Nullable Object content) { if (content instanceof Invokable) { content = ((Invokable) content).invoke(this); } if (content == null) { return this; } if (content instanceof CharSequence) { consumer.append((CharSequence) content); } else { consumer.append(content.toString()); } return this; }
@Override void apply(Invokation invokation, CharSequence content, @Nullable Templates.Invokable original) { String collapsed = CharMatcher.whitespace().trimAndCollapseFrom(content, ' '); int estimatedLimitOnThisLine = LIMIT - invokation.consumer.getCurrentIndentation().length(); if (collapsed.length() < estimatedLimitOnThisLine) { invokation.out(collapsed); } else { if (original != null) { original.invoke(invokation); } else { invokation.out(content); } } } };
@Override public Invokable invoke(Invokation invokation, Object... parameters) { String packageName = parameters[0].toString(); String simpleName = parameters[1].toString(); Element originatingElement = (Element) parameters[2]; Invokable body = (Invokable) parameters[3]; ResourceKey key = new ResourceKey(packageName, simpleName, Delegates.unwrap(originatingElement)); SourceFile javaFile = getFiles().sourceFiles.get(key); body.invoke(new Invokation(javaFile.consumer)); javaFile.complete(); return null; } };
protected final void invoke(Templates.Invokable invokable) { invokable.invoke(Templates.Invokation.initial()); }
public static void $(Invokation invokation, Invokable invokable, Object... parameters) { invokable.invoke(invokation, parameters); }
@Override public Invokable invoke(Invokation invokation, Object... parameters) { String interfaceName = parameters[0].toString(); Invokable body = (Invokable) parameters[1]; ResourceKey key = new ResourceKey("", META_INF_SERVICES + interfaceName); AppendServiceFile servicesFile = getFiles().appendResourceFiles.get(key); body.invoke(new Invokation(servicesFile.consumer)); return null; } };
@Override void apply(Invokation invokation, CharSequence content, @Nullable Templates.Invokable original) { boolean hasNonWhitespace = !CharMatcher.whitespace().matchesAllOf(content); if (hasNonWhitespace) { if (original != null) { original.invoke(invokation); } else { invokation.out(content); } } } };