From 933a5c3efc831e622f6bc2129ca9e0c868fce5a3 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 30 May 2017 22:44:33 +0300 Subject: [PATCH] Code style fixes --- .../java/org/teavm/jso/impl/JSClassProcessor.java | 12 ++++++++---- .../test/java/org/teavm/jso/test/FunctorTest.java | 12 ++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java b/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java index 2e60efa2f..d232d357a 100644 --- a/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java +++ b/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java @@ -991,9 +991,12 @@ class JSClassProcessor { } private boolean isProperFunctor(ClassReader type) { - return type.hasModifier(ElementModifier.INTERFACE) - && type.getMethods().stream().filter(it->it.hasModifier(ElementModifier.ABSTRACT)) - .toArray().length == 1; + if (!type.hasModifier(ElementModifier.INTERFACE)) { + return false; + } + return type.getMethods().stream() + .filter(method -> method.hasModifier(ElementModifier.ABSTRACT)) + .count() == 1; } private Variable wrapFunctor(CallLocation location, Variable var, ClassReader type) { @@ -1002,7 +1005,8 @@ class JSClassProcessor { return var; } 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 nameVar = addStringWrap(addString(name, location.getSourceLocation()), location.getSourceLocation()); InvokeInstruction insn = new InvokeInstruction(); diff --git a/tests/src/test/java/org/teavm/jso/test/FunctorTest.java b/tests/src/test/java/org/teavm/jso/test/FunctorTest.java index cb1b995a4..744811a6c 100644 --- a/tests/src/test/java/org/teavm/jso/test/FunctorTest.java +++ b/tests/src/test/java/org/teavm/jso/test/FunctorTest.java @@ -42,8 +42,8 @@ public class FunctorTest { } @Test - public void functorWithDefaultMethodPassed(){ - JSFunctionWithDefaultMethod javaFunction = (s) -> s+" returned"; + public void functorWithDefaultMethodPassed() { + JSFunctionWithDefaultMethod javaFunction = (s) -> s + " returned"; String returned = javaFunction.defaultMethod(); @@ -51,8 +51,8 @@ public class FunctorTest { } @Test - public void functorWithStaticMethodPassed(){ - JSFunctionWithStaticMethod javaFunction = (s) -> s+" returned"; + public void functorWithStaticMethodPassed() { + JSFunctionWithStaticMethod javaFunction = (s) -> s + " returned"; String returned = javaFunction.apply(JSFunctionWithStaticMethod.staticMethod()); @@ -85,7 +85,7 @@ public class FunctorTest { interface JSFunctionWithDefaultMethod extends JSObject { String apply(String a); - default String defaultMethod(){ + default String defaultMethod() { return apply("Content"); } } @@ -94,7 +94,7 @@ public class FunctorTest { interface JSFunctionWithStaticMethod extends JSObject { String apply(String a); - public static String staticMethod(){ + static String staticMethod() { return "Content"; } }