Code style fixes

This commit is contained in:
Alexey Andreev 2017-05-30 22:44:33 +03:00
parent 5ecfb3620c
commit 933a5c3efc
2 changed files with 14 additions and 10 deletions

View File

@ -991,9 +991,12 @@ class JSClassProcessor {
} }
private boolean isProperFunctor(ClassReader type) { private boolean isProperFunctor(ClassReader type) {
return type.hasModifier(ElementModifier.INTERFACE) if (!type.hasModifier(ElementModifier.INTERFACE)) {
&& type.getMethods().stream().filter(it->it.hasModifier(ElementModifier.ABSTRACT)) return false;
.toArray().length == 1; }
return type.getMethods().stream()
.filter(method -> method.hasModifier(ElementModifier.ABSTRACT))
.count() == 1;
} }
private Variable wrapFunctor(CallLocation location, Variable var, ClassReader type) { private Variable wrapFunctor(CallLocation location, Variable var, ClassReader type) {
@ -1002,7 +1005,8 @@ class JSClassProcessor {
return var; return var;
} }
String name = type.getMethods().stream() String name = type.getMethods().stream()
.filter(it->it.hasModifier(ElementModifier.ABSTRACT)).findFirst().get().getName(); .filter(method -> method.hasModifier(ElementModifier.ABSTRACT))
.findFirst().get().getName();
Variable functor = program.createVariable(); Variable functor = program.createVariable();
Variable nameVar = addStringWrap(addString(name, location.getSourceLocation()), location.getSourceLocation()); Variable nameVar = addStringWrap(addString(name, location.getSourceLocation()), location.getSourceLocation());
InvokeInstruction insn = new InvokeInstruction(); InvokeInstruction insn = new InvokeInstruction();

View File

@ -42,8 +42,8 @@ public class FunctorTest {
} }
@Test @Test
public void functorWithDefaultMethodPassed(){ public void functorWithDefaultMethodPassed() {
JSFunctionWithDefaultMethod javaFunction = (s) -> s+" returned"; JSFunctionWithDefaultMethod javaFunction = (s) -> s + " returned";
String returned = javaFunction.defaultMethod(); String returned = javaFunction.defaultMethod();
@ -51,8 +51,8 @@ public class FunctorTest {
} }
@Test @Test
public void functorWithStaticMethodPassed(){ public void functorWithStaticMethodPassed() {
JSFunctionWithStaticMethod javaFunction = (s) -> s+" returned"; JSFunctionWithStaticMethod javaFunction = (s) -> s + " returned";
String returned = javaFunction.apply(JSFunctionWithStaticMethod.staticMethod()); String returned = javaFunction.apply(JSFunctionWithStaticMethod.staticMethod());
@ -85,7 +85,7 @@ public class FunctorTest {
interface JSFunctionWithDefaultMethod extends JSObject { interface JSFunctionWithDefaultMethod extends JSObject {
String apply(String a); String apply(String a);
default String defaultMethod(){ default String defaultMethod() {
return apply("Content"); return apply("Content");
} }
} }
@ -94,7 +94,7 @@ public class FunctorTest {
interface JSFunctionWithStaticMethod extends JSObject { interface JSFunctionWithStaticMethod extends JSObject {
String apply(String a); String apply(String a);
public static String staticMethod(){ static String staticMethod() {
return "Content"; return "Content";
} }
} }