Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-schlichtherle committed Aug 17, 2023
1 parent f4ef094 commit 726fbb6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions java/src/main/java/bali/java/AnnotationProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ private PackageElement packageOf(Element e) {
}

@RequiredArgsConstructor
@Getter
final class ModuleInterface {

@Getter
private final TypeElement element;

@Getter(lazy = true)
Expand Down Expand Up @@ -483,19 +483,19 @@ boolean resolveNullable() {
@Getter(lazy = true)
private final String companionInterfaceRef = getElement().getSimpleName() + "$.super";

Consumer<Output> forAllDependencyMethods() {
Consumer<Output> forAllComponentMethods() {
return out -> filteredOverridableMethods((TypeElement) getMakeElement())
// HC SVNT DRACONES!
.map(e -> new Tuple2<>(newDependencyMethod(e), e))
.map(e -> new Tuple2<>(newComponentMethod(e), e))
.filter(t -> t.getT1().isCachingDisabled() || checkCacheableReturnType(t.getT2()))
.map(t ->
(t.getT1().isCachingDisabled() ? new DisabledCachingVisitor() : methodVisitor(t.getT2()))
.visitDependencyMethod(t.getT1()))
.visitComponentMethod(t.getT1()))
.forEach(c -> c.accept(out));
}

DependencyMethod newDependencyMethod(ExecutableElement e) {
return new DependencyMethod() {
ComponentMethod newComponentMethod(ExecutableElement e) {
return new ComponentMethod() {

@Override
ExecutableElement getMethodElement() {
Expand All @@ -504,7 +504,7 @@ ExecutableElement getMethodElement() {
};
}

abstract class DependencyMethod extends Method {
abstract class ComponentMethod extends Method {

@Getter(lazy = true)
private final Optional<Tuple2<TypeElement, Element>> accessedElement = resolveAccessedElement();
Expand Down
8 changes: 4 additions & 4 deletions java/src/main/java/bali/java/MethodVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package bali.java;

import bali.java.AnnotationProcessor.ModuleInterface.ModuleMethod;
import bali.java.AnnotationProcessor.ModuleInterface.Method;
import bali.java.AnnotationProcessor.ModuleInterface.ModuleMethod.DependencyMethod;
import bali.java.AnnotationProcessor.ModuleInterface.ModuleMethod;
import bali.java.AnnotationProcessor.ModuleInterface.ModuleMethod.ComponentMethod;

import java.util.function.Consumer;

Expand All @@ -29,7 +29,7 @@ default Consumer<Output> visitModuleMethod4CompanionInterface(ModuleMethod m) {
out.ad("new ").ad(m.getLocalMakeType()).ad("()");
if (m.isMakeTypeAbstract()) {
out.ad(" {").nl().in();
m.forAllDependencyMethods().accept(out);
m.forAllComponentMethods().accept(out);
out.out().ad("}");
}
})
Expand All @@ -43,7 +43,7 @@ default Consumer<Output> visitModuleMethod4CompanionClass(ModuleMethod m) {
.andThen(visitMethodEnd(m));
}

default Consumer<Output> visitDependencyMethod(DependencyMethod m) {
default Consumer<Output> visitComponentMethod(ComponentMethod m) {
return visitField(m, "")
.andThen(visitMethodBegin(m))
.andThen(out -> out.ad(m.getAccessedElementRef()))
Expand Down

0 comments on commit 726fbb6

Please sign in to comment.