    private void parseExpressionEvaluateAndCheck(final String expression,
                                                 final TestNode root,
                                                 final Set<String> expected) {
        final NodeSelector<TestNode, StringName, StringName, Object> selector = this.parseExpression(expression);

        final Set<TestNode> selected = Sets.ordered();
        selector.apply(root,
                new FakeNodeSelectorContext<>() {
                    @Override
                    public boolean isFinished() {
                        return false;
                    }

                    @Override
                    public boolean test(final TestNode node) {
                        return true;
                    }

                    @Override
                    public void setNode(final TestNode node) {
                        this.node = node;
                    }

                    private TestNode node;

                    @Override
                    public TestNode selected(final TestNode node) {
                        selected.add(node);
                        return node;
                    }

                    @Override
                    public Object function(final ExpressionNodeName name, final List<Object> parameters) {
                        assertNotNull(this.node, "node missing");

                        return NODE.equals(name) ?
                                this.node :
                                NodeSelectorContexts.basicFunctions().apply(name)
                                        .get()
                                        .apply(Lists.readOnly(parameters), this.expressionFunctionContext());
                    }

                    private final ExpressionNodeName NODE = ExpressionNodeName.with("node");

                    private ExpressionFunctionContext expressionFunctionContext() {
                        return new FakeExpressionFunctionContext() {
                            @Override
                            public <T> Either<T, String> convert(final Object value,
                                                                 final Class<T> target) {
                                return convert0(value, target);
                            }
                        };
                    }

                    private <T> Either<T, String> convert0(final Object value,
                                                           final Class<T> target) {
                        return this.convert(value, target);
                    }

                    @Override
                    public <T> Either<T, String> convert(final Object value, final Class<T> target) {
                        Objects.requireNonNull(value, "value");
                        Objects.requireNonNull(target, "target");

                        return Cast.to(target.isInstance(value) ?
                                Either.left(target.cast(value)) :
                                target == BigDecimal.class ?
                                        this.convertToBigDecimal(value) :
                                        target == Boolean.class ?
                                                this.convertToBoolean(value) :
                                                target == Integer.class ?
                                                        this.convertToInteger(value) :
                                                        target == Number.class ?
                                                                this.convertToNumber(value) :
                                                                target == String.class ?
                                                                        this.convertToString(value) :
                                                                        this.failConversion(value, target));
                    }

                    /**
                     * Currently {@link walkingkooka.tree.expression.ExpressionNode} will convert a pair of {@link Boolean} into
                     * {@link BigDecimal} prior to performing the operation such as equals.
                     */
                    private Either<BigDecimal, String> convertToBigDecimal(final Object value) {
                        final Converter converter = value instanceof Boolean ?
                                Converters.booleanTrueFalse(Boolean.class, Boolean.TRUE, BigDecimal.class, BigDecimal.ONE, BigDecimal.ZERO) :
                                value instanceof String ?
                                        Converters.parser(BigDecimal.class, Parsers.bigDecimal(), (c) -> ParserContexts.basic(c, c)) :
                                        Converters.numberNumber();
                        return converter.convert(value, BigDecimal.class, this.converterContext);
                    }

                    private Either<Boolean, String> convertToBoolean(final Object value) {
                        return Converters.truthyNumberBoolean().convert(value, Boolean.class, this.converterContext);
                    }

                    private Either<Number, String> convertToNumber(final Object value) {
                        return value instanceof String ?
                                Either.left(Integer.parseInt((String) value)) :
                                Converters.booleanTrueFalse(Boolean.class, Boolean.TRUE, Number.class, 1L, 0L)
                                        .convert(value, Number.class, ConverterContexts.fake());
                    }

                    private Either<Integer, String> convertToInteger(final Object value) {
                        if (value instanceof Number) {
                            return Either.left(Number.class.cast(value).intValue());
                        }
                        return Either.left(Integer.parseInt(String.valueOf(value)));
                    }

                    private Either<String, String> convertToString(final Object value) {
                        return Converters.objectString().convert(value, String.class, this.converterContext);
                    }

                    private <T> Either<T, String> failConversion(final Object value, final Class<T> target) {
                        return Either.right("Failed to convert " + CharSequences.quoteIfChars(value) + " to " + target.getSimpleName());
                    }

                    private final ConverterContext converterContext = ConverterContexts.basic(DateTimeContexts.fake(), decimalNumberContext());
                });

        assertEquals(expected, names(selected), () -> expression + "\n" + selector.unwrapIfCustomToStringNodeSelector() + "\n" + root);
    }

    private void parseExpressionEvaluateAndCheck(final String expression,
                                                 final TestNode root,
                                                 final Set<String> expected) {
        final NodeSelector<TestNode, StringName, StringName, Object> selector = this.parseExpression(expression);

        final Set<TestNode> selected = Sets.ordered();
        selector.apply(root,
                new FakeNodeSelectorContext<TestNode, StringName, StringName, Object>() {
                    @Override
                    public boolean isFinished() {
                        return false;
                    }

                    @Override
                    public boolean test(final TestNode node) {
                        return true;
                    }

                    @Override
                    public void setNode(final TestNode node) {
                        this.node = node;
                    }

                    private TestNode node;

                    @Override
                    public TestNode selected(final TestNode node) {
                        selected.add(node);
                        return node;
                    }

                    @Override
                    public Object function(final ExpressionNodeName name, final List<Object> parameters) {
                        assertNotNull(this.node, "node missing");

                        return NODE.equals(name) ?
                                this.node :
                                NodeSelectorContexts.basicFunctions().apply(name)
                                        .get()
                                        .apply(Lists.readOnly(parameters), this.expressionFunctionContext());
                    }

                    private final ExpressionNodeName NODE = ExpressionNodeName.with("node");

                    private ExpressionFunctionContext expressionFunctionContext() {
                        return new FakeExpressionFunctionContext() {
                            @Override
                            public <T> Either<T, String> convert(final Object value,
                                                                 final Class<T> target) {
                                return convert0(value, target);
                            }
                        };
                    }

                    private <T> Either<T, String> convert0(final Object value,
                                                           final Class<T> target) {
                        return this.convert(value, target);
                    }

                    @Override
                    public <T> Either<T, String> convert(final Object value, final Class<T> target) {
                        Objects.requireNonNull(value, "value");
                        Objects.requireNonNull(target, "target");

                        return Cast.to(target.isInstance(value) ?
                                Either.left(target.cast(value)) :
                                target == BigDecimal.class ?
                                        this.convertToBigDecimal(value) :
                                        target == Boolean.class ?
                                                this.convertToBoolean(value) :
                                                target == Integer.class ?
                                                        this.convertToInteger(value) :
                                                        target == Number.class ?
                                                                this.convertToNumber(value) :
                                                                target == String.class ?
                                                                        this.convertToString(value) :
                                                                        this.failConversion(value, target));
                    }

                    /**
                     * Currently {@link walkingkooka.tree.expression.ExpressionNode} will convert a pair of {@link Boolean} into
                     * {@link BigDecimal} prior to performing the operation such as equals.
                     */
                    private Either<BigDecimal, String> convertToBigDecimal(final Object value) {
                        final Converter converter = value instanceof Boolean ?
                                Converters.booleanTrueFalse(Boolean.class, Boolean.TRUE, BigDecimal.class, BigDecimal.ONE, BigDecimal.ZERO) :
                                value instanceof String ?
                                        Converters.parser(BigDecimal.class, Parsers.bigDecimal(), (c) -> ParserContexts.basic(c, c)) :
                                        Converters.numberNumber();
                        return converter.convert(value, BigDecimal.class, this.converterContext);
                    }

                    private Either<Boolean, String> convertToBoolean(final Object value) {
                        return Converters.truthyNumberBoolean().convert(value, Boolean.class, this.converterContext);
                    }

                    private Either<Number, String> convertToNumber(final Object value) {
                        return value instanceof String ?
                                Either.left(Integer.parseInt((String) value)) :
                                Converters.booleanTrueFalse(Boolean.class, Boolean.TRUE, Number.class, 1L, 0L)
                                        .convert(value, Number.class, ConverterContexts.fake());
                    }

                    private Either<Integer, String> convertToInteger(final Object value) {
                        if (value instanceof Number) {
                            return Either.left(Number.class.cast(value).intValue());
                        }
                        return Either.left(Integer.parseInt(String.valueOf(value)));
                    }

                    private Either<String, String> convertToString(final Object value) {
                        return Converters.objectString().convert(value, String.class, this.converterContext);
                    }

                    private <T> Either<T, String> failConversion(final Object value, final Class<T> target) {
                        return Either.right("Failed to convert " + CharSequences.quoteIfChars(value) + " to " + target.getSimpleName());
                    }

                    private final ConverterContext converterContext = ConverterContexts.basic(DateTimeContexts.fake(), decimalNumberContext());
                });

        assertEquals(expected, names(selected), () -> expression + "\n" + selector.unwrapIfCustomToStringNodeSelector() + "\n" + root);
    }

Replace Generic With Diamond FakeNodeSelectorContext<TestNode,StringName,StringName,Object> with FakeNodeSelectorContext<> in method private parseExpressionEvaluateAndCheck(expression String, root TestNode, expected Set<String>) : void from class walkingkooka.tree.select.NodeSelectorNodeSelectorParserTokenVisitorTest


    final void acceptMapAndCheck(final NodeSelector<TestNode, StringName, StringName, Object> selector,
                                 final TestNode start,
                                 final TestNode result) {
        TestNode.clear();

        final String startToString = start.toString();

        assertEquals(result,
                selector.apply(start,
                        this.context0(() -> false,
                                Predicates.always(),
                                new Function<>() {
                                    @Override
                                    public TestNode apply(final TestNode testNode) {
                                        return TestNode.with(testNode.name().value() + "*" + this.i++)
                                                .setChildren(testNode.children());
                                    }

                                    private int i;

                                    @Override
                                    public String toString() {
                                        return "mapper: next: " + i;
                                    }
                                })));

        assertEquals(startToString,
                start.toString(),
                "toString has changed for starting node, indicating it probably was mutated");
    }

    final void acceptMapAndCheck(final NodeSelector<TestNode, StringName, StringName, Object> selector,
                                 final TestNode start,
                                 final TestNode result) {
        TestNode.clear();

        final String startToString = start.toString();

        assertEquals(result,
                selector.apply(start,
                        this.context0(() -> false,
                                Predicates.always(),
                                new Function<TestNode, TestNode>() {
                                    @Override
                                    public TestNode apply(final TestNode testNode) {
                                        return TestNode.with(testNode.name().value() + "*" + this.i++)
                                                .setChildren(testNode.children());
                                    }

                                    private int i;

                                    @Override
                                    public String toString() {
                                        return "mapper: next: " + i;
                                    }
                                })));

        assertEquals(startToString,
                start.toString(),
                "toString has changed for starting node, indicating it probably was mutated");
    }

Replace Generic With Diamond Function<TestNode,TestNode> with Function<> in method package acceptMapAndCheck(selector NodeSelector<TestNode,StringName,StringName,Object>, start TestNode, result TestNode) : void from class walkingkooka.tree.select.NodeSelectorTestCase4


    final NodeSelectorContext<TestNode, StringName, StringName, Object> context0(final BooleanSupplier finisher,
                                                                                final Predicate<TestNode> filter,
                                                                                final Function<TestNode, TestNode> mapper) {
        final NodeSelectorContext<TestNode, StringName, StringName, Object> context = NodeSelectorContexts.basic(finisher,
                filter,
                mapper,
                this.functions(),
                this.converter(),
                ConverterContexts.fake(),
                TestNode.class);

        return new NodeSelectorContext<>() {
            @Override
            public boolean isFinished() {
                return context.isFinished();
            }

            private void finisherGuardCheck() {
                assertEquals(false, this.isFinished(), () -> "finisher should be false: " + this);
            }

            @Override
            public boolean test(final TestNode node) {
                this.finisherGuardCheck();
                return context.test(node);
            }

            @Override
            public void setNode(final TestNode node) {
                this.finisherGuardCheck();
                context.setNode(node);
            }

            @Override
            public TestNode selected(final TestNode node) {
                this.finisherGuardCheck();
                return context.selected(node);
            }

            @Override
            public Object function(final ExpressionNodeName name,
                                   final List<Object> parameters) {
                this.finisherGuardCheck();
                return context.function(name, parameters);
            }

            @Override
            public <T> Either<T, String> convert(final Object value, final Class<T> target) {
                this.finisherGuardCheck();
                return context.convert(value, target);
            }

            @Override
            public MathContext mathContext() {
                this.finisherGuardCheck();
                return context.mathContext();
            }

            @Override
            public String toString() {
                return context.toString();
            }
        };
    }

    final NodeSelectorContext<TestNode, StringName, StringName, Object> context0(final BooleanSupplier finisher,
                                                                                final Predicate<TestNode> filter,
                                                                                final Function<TestNode, TestNode> mapper) {
        final NodeSelectorContext<TestNode, StringName, StringName, Object> context = NodeSelectorContexts.basic(finisher,
                filter,
                mapper,
                this.functions(),
                this.converter(),
                ConverterContexts.fake(),
                TestNode.class);

        return new NodeSelectorContext<TestNode, StringName, StringName, Object>() {
            @Override
            public boolean isFinished() {
                return context.isFinished();
            }

            private void finisherGuardCheck() {
                assertEquals(false, this.isFinished(), () -> "finisher should be false: " + this);
            }

            @Override
            public boolean test(final TestNode node) {
                this.finisherGuardCheck();
                return context.test(node);
            }

            @Override
            public void setNode(final TestNode node) {
                this.finisherGuardCheck();
                context.setNode(node);
            }

            @Override
            public TestNode selected(final TestNode node) {
                this.finisherGuardCheck();
                return context.selected(node);
            }

            @Override
            public Object function(final ExpressionNodeName name,
                                   final List<Object> parameters) {
                this.finisherGuardCheck();
                return context.function(name, parameters);
            }

            @Override
            public <T> Either<T, String> convert(final Object value, final Class<T> target) {
                this.finisherGuardCheck();
                return context.convert(value, target);
            }

            @Override
            public MathContext mathContext() {
                this.finisherGuardCheck();
                return context.mathContext();
            }

            @Override
            public String toString() {
                return context.toString();
            }
        };
    }

Replace Generic With Diamond NodeSelectorContext<TestNode,StringName,StringName,Object> with NodeSelectorContext<> in method package context0(finisher BooleanSupplier, filter Predicate<TestNode>, mapper Function<TestNode,TestNode>) : NodeSelectorContext<TestNode,StringName,StringName,Object> from class walkingkooka.tree.select.NodeSelectorTestCase4


    @Override
    public NumberConverterNumberVisitor<BigDecimal> createVisitor() {
        return new NumberConverterNumberVisitor<>(this.converter(), BigDecimal.class);
    }

    @Override
    public NumberConverterNumberVisitor<BigDecimal> createVisitor() {
        return new NumberConverterNumberVisitor<BigDecimal>(this.converter(), BigDecimal.class);
    }

Replace Generic With Diamond NumberConverterNumberVisitor<BigDecimal> with NumberConverterNumberVisitor<> in method public createVisitor() : NumberConverterNumberVisitor<BigDecimal> from class walkingkooka.convert.NumberConverterNumberVisitorTest


    private String toXmlText(final XmlNode node) {
        try (final StringWriter writer = new StringWriter()) {
            final Transformer transformer = TransformerFactory.newInstance().newTransformer();
            node.toXml(transformer, writer);
            writer.flush();
            return writer.toString();
        } catch (final IOException cause) {
            throw new HttpServerException(cause.getMessage(), cause);
        } catch (final TransformerException cause) {
            throw new HttpServerException(cause.getMessage(), cause);
        }
    }

    private String toXmlText(final XmlNode node) {
        try {
            final StringWriter writer = new StringWriter();
            final Transformer transformer = TransformerFactory.newInstance().newTransformer();
            node.toXml(transformer, writer);
            writer.flush();
            return writer.toString();
        } catch (final TransformerException cause) {
            throw new HttpServerException(cause.getMessage(), cause);
        }
    }

Try With Resources try(final StringWriter writer=new StringWriter()) in method private toXmlText(node XmlNode) : String from class walkingkooka.net.http.server.hateos.HateosContentTypeXmlNode


    private HateosHandler<BigInteger, TestHateosResource, TestHateosResource2> handler(final String toString) {
        return new FakeHateosHandler<>() {
            @Override
            public String toString() {
                return toString;
            }
        };
    }

    private HateosHandler<BigInteger, TestHateosResource, TestHateosResource3> handler(final String toString) {
        return new FakeHateosHandler<BigInteger, TestHateosResource, TestHateosResource3>() {
            public String toString() {
                return toString;
            }
        };
    }

Replace Generic With Diamond FakeHateosHandler<BigInteger,TestHateosResource,TestHateosResource3> with FakeHateosHandler<> in method private handler(toString String) : HateosHandler<BigInteger,TestHateosResource,TestHateosResource2> from class walkingkooka.net.http.server.hateos.HateosHandlerRouterBuilderTest


    @Test
    public void testHandleIdAndCheck() {
        final BigInteger id = this.id();
        final Optional<TestHateosResource> in = this.resource();
        final Map<HttpRequestAttribute<?>, Object> parameters = this.parameters();

        final TestHateosResource out = TestHateosResource.with(BigInteger.ONE);

        this.handleAndCheck(new FakeHateosHandler<>() {
                                @Override
                                public Optional<TestHateosResource> handle(final BigInteger i,
                                                                           final Optional<TestHateosResource> r,
                                                                           final Map<HttpRequestAttribute<?>, Object> p) {
                                    assertSame(id, i);
                                    assertSame(in, r);
                                    assertSame(parameters, p);

                                    return Optional.of(out);
                                }
                            },
                id,
                in,
                parameters,
                Optional.of(out));
    }

    @Test
    public void testHandleIdAndCheck() {
        final BigInteger id = this.id();
        final Optional<TestHateosResource> resource = this.resource();
        final Map<HttpRequestAttribute<?>, Object> parameters = this.parameters();

        final TestHateosResource2 resource2 = TestHateosResource2.with(BigInteger.valueOf(222));

        this.handleAndCheck(new FakeHateosHandler<BigInteger, TestHateosResource, TestHateosResource2>() {
                                @Override
                                public Optional<TestHateosResource2> handle(final BigInteger i,
                                                                            final Optional<TestHateosResource> r,
                                                                            final Map<HttpRequestAttribute<?>, Object> p) {
                                    assertSame(id, i);
                                    assertSame(resource, r);
                                    assertSame(parameters, p);

                                    return Optional.of(resource2);
                                }
                            },
                id,
                resource,
                parameters,
                Optional.of(resource2));
    }

Replace Generic With Diamond FakeHateosHandler<BigInteger,TestHateosResource,TestHateosResource2> with FakeHateosHandler<> in method public testHandleIdAndCheck() : void from class walkingkooka.net.http.server.hateos.HateosHandlerTestingTest


    @Test
    public void testHandleUnsupported() {
        this.handleUnsupported(new FakeHateosHandler<>() {
        });
    }

    @Test
    public void testHandleUnsupported() {
        this.handleUnsupported(new FakeHateosHandler<BigInteger, TestHateosResource, TestHateosResource2>() {
        });
    }

Replace Generic With Diamond FakeHateosHandler<BigInteger,TestHateosResource,TestHateosResource2> with FakeHateosHandler<> in method public testHandleUnsupported() : void from class walkingkooka.net.http.server.hateos.HateosHandlerTestingTest


    @Test
    public void testHandleCollectionAndCheck() {
        final Range<BigInteger> id = this.collection();
        final Optional<TestHateosResource2> in = Optional.of(TestHateosResource2.with(this.collection()));
        final Map<HttpRequestAttribute<?>, Object> parameters = this.parameters();

        final Optional<TestHateosResource2> out = Optional.of(TestHateosResource2.with(Range.singleton(BigInteger.valueOf(222))));

        this.handleCollectionAndCheck(new FakeHateosHandler<>() {
                                          @Override
                                          public Optional<TestHateosResource2> handleCollection(final Range<BigInteger> i,
                                                                                final Optional<TestHateosResource2> r,
                                                                                final Map<HttpRequestAttribute<?>, Object> p) {
                                              assertSame(id, i);
                                              assertSame(in, r);
                                              assertSame(parameters, p);

                                              return out;
                                          }
                                      },
                id,
                in,
                parameters,
                out);
    }

    @Test
    public void testHandleCollectionAndCheck() {
        final Range<BigInteger> id = this.collection();
        final Optional<TestHateosResource> resources = Optional.of(TestHateosResource.with(BigInteger.valueOf(999)));
        final Map<HttpRequestAttribute<?>, Object> parameters = this.parameters();

        final Optional<TestHateosResource2> resource2 = Optional.of(TestHateosResource2.with(BigInteger.valueOf(222)));

        this.handleCollectionAndCheck(new FakeHateosHandler<BigInteger, TestHateosResource, TestHateosResource2>() {
                                          @Override
                                          public Optional<TestHateosResource2> handleCollection(final Range<BigInteger> i,
                                                                                final Optional<TestHateosResource> r,
                                                                                final Map<HttpRequestAttribute<?>, Object> p) {
                                              assertSame(id, i);
                                              assertSame(resources, r);
                                              assertSame(parameters, p);

                                              return resource2;
                                          }
                                      },
                id,
                resources,
                parameters,
                resource2);
    }

Replace Generic With Diamond FakeHateosHandler<BigInteger,TestHateosResource,TestHateosResource2> with FakeHateosHandler<> in method public testHandleCollectionAndCheck() : void from class walkingkooka.net.http.server.hateos.HateosHandlerTestingTest


    @Test
    public void testHandleCollectionUnsupported() {
        this.handleCollectionUnsupported(new FakeHateosHandler<>() {
        });
    }

    @Test
    public void testHandleCollectionUnsupported() {
        this.handleCollectionUnsupported(new FakeHateosHandler<BigInteger, TestHateosResource, TestHateosResource2>() {
        });
    }

Replace Generic With Diamond FakeHateosHandler<BigInteger,TestHateosResource,TestHateosResource2> with FakeHateosHandler<> in method public testHandleCollectionUnsupported() : void from class walkingkooka.net.http.server.hateos.HateosHandlerTestingTest


    static <N extends Node<N, NAME, ANAME, AVALUE>,
            NAME extends Name,
            ANAME extends Name,
            AVALUE> AndNodeSelectorNodeSelectorContext<N, NAME, ANAME, AVALUE> with(final NodeSelectorContext<N, NAME, ANAME, AVALUE> context) {
        return new AndNodeSelectorNodeSelectorContext<>(context);
    }

    static <N extends Node<N, NAME, ANAME, AVALUE>,
            NAME extends Name,
            ANAME extends Name,
            AVALUE> AndNodeSelectorNodeSelectorContext<N, NAME, ANAME, AVALUE> with(final NodeSelectorContext<N, NAME, ANAME, AVALUE> context) {
        return new AndNodeSelectorNodeSelectorContext<N, NAME, ANAME, AVALUE>(context);
    }

Replace Generic With Diamond AndNodeSelectorNodeSelectorContext<N,NAME,ANAME,AVALUE> with AndNodeSelectorNodeSelectorContext<> in method package with(context NodeSelectorContext<N,NAME,ANAME,AVALUE>) : AndNodeSelectorNodeSelectorContext<N,NAME,ANAME,AVALUE> from class walkingkooka.tree.select.AndNodeSelectorNodeSelectorContext


    /**
     * Factory that creates a new {@link ExpressionNodeSelectorExpressionEvaluationContext}, using the given {@link Node} as the context.
     */
    static <N extends Node<N, NAME, ANAME, AVALUE>,
            NAME extends Name,
            ANAME extends Name,
            AVALUE>
    ExpressionNodeSelectorExpressionEvaluationContext<N, NAME, ANAME, AVALUE> with(final N node,
                                                                                final NodeSelectorContext<N, NAME, ANAME, AVALUE> context) {
        return new ExpressionNodeSelectorExpressionEvaluationContext<>(node, context);
    }

    /**
     * Factory that creates a new {@link ExpressionNodeSelectorExpressionEvaluationContext}, using the given {@link Node} as the context.
     */
    static <N extends Node<N, NAME, ANAME, AVALUE>,
            NAME extends Name,
            ANAME extends Name,
            AVALUE>
    ExpressionNodeSelectorExpressionEvaluationContext<N, NAME, ANAME, AVALUE> with(final N node,
                                                                                final NodeSelectorContext<N, NAME, ANAME, AVALUE> context) {
        return new ExpressionNodeSelectorExpressionEvaluationContext<N, NAME, ANAME, AVALUE>(node, context);
    }

Replace Generic With Diamond ExpressionNodeSelectorExpressionEvaluationContext<N,NAME,ANAME,AVALUE> with ExpressionNodeSelectorExpressionEvaluationContext<> in method package with(node N, context NodeSelectorContext<N,NAME,ANAME,AVALUE>) : ExpressionNodeSelectorExpressionEvaluationContext<N,NAME,ANAME,AVALUE> from class walkingkooka.tree.select.ExpressionNodeSelectorExpressionEvaluationContext


    @Override
    protected NodeSelectorNodeSelectorParserTokenVisitor<TestFakeNode, StringName, StringName, Object> createParserTokenVisitor() {
        return new NodeSelectorNodeSelectorParserTokenVisitor<>(null, null, null);
    }

    @Override
    protected NodeSelectorNodeSelectorParserTokenVisitor<TestFakeNode, StringName, StringName, Object> createParserTokenVisitor() {
        return new NodeSelectorNodeSelectorParserTokenVisitor<TestFakeNode, StringName, StringName, Object>(null, null);
    }

Replace Generic With Diamond NodeSelectorNodeSelectorParserTokenVisitor<TestFakeNode,StringName,StringName,Object> with NodeSelectorNodeSelectorParserTokenVisitor<> in method protected createParserTokenVisitor() : NodeSelectorNodeSelectorParserTokenVisitor<TestFakeNode,StringName,StringName,Object> from class walkingkooka.tree.select.NodeSelectorNodeSelectorParserTokenVisitorTest


    @Test
    public void testHandleMessageEvent() {
        final TestMessagePort port = new TestMessagePort();
        final BrowserHttpServer server = BrowserHttpServer.with((request, response) -> {
            response.setStatus(HttpStatusCode.CREATED.setMessage("Custom CREATED Message 123"));
            response.addEntity(HttpEntity.EMPTY.setBodyText("Response-" + request.bodyText()));
        }, port, MESSAGE_FILTER, TARGET_ORIGIN);
        server.start();

        final List<String> postedMessage = Lists.array();

        final MessageEvent<String> event = new MessageEvent<>("message");
        event.source = new Window() {
            @Override
            public void postMessage(final Object message,
                                    final String targetOrigin) {
                postedMessage.add(message.toString());
            }
        };
        event.data = "{\"body\": \"body-text-123\"}";

        server.handleMessageEvent(event);
        server.stop();

        this.checkEquals(Lists.of("{\n" +
                "  \"status-code\": 201,\n" +
                "  \"status-message\": \"Custom CREATED Message 123\",\n" +
                "  \"body\": \"Response-body-text-123\"\n" +
                "}"), postedMessage);
    }

    @Test
    public void testHandleMessageEvent() {
        final TestMessagePort port = new TestMessagePort();
        final BrowserHttpServer server = BrowserHttpServer.with((request, response) -> {
            response.setStatus(HttpStatusCode.CREATED.setMessage("Custom CREATED Message 123"));
            response.addEntity(HttpEntity.EMPTY.setBodyText("Response-" + request.bodyText()));
        }, port, MESSAGE_FILTER, TARGET_ORIGIN);
        server.start();

        final List<String> postedMessage = Lists.array();

        final MessageEvent<String> event = new MessageEvent<String>("message");
        event.source = new Window() {
            @Override
            public void postMessage(final Object message,
                                    final String targetOrigin) {
                postedMessage.add(message.toString());
            }
        };
        event.data = "{\"body\": \"body-text-123\"}";

        server.handleMessageEvent(event);
        server.stop();

        this.checkEquals(Lists.of("{\n" +
                "  \"status-code\": 201,\n" +
                "  \"status-message\": \"Custom CREATED Message 123\",\n" +
                "  \"body\": \"Response-body-text-123\"\n" +
                "}"), postedMessage);
    }

Replace Generic With Diamond MessageEvent<String> with MessageEvent<> in method public testHandleMessageEvent() : void from class walkingkooka.net.http.server.browser.BrowserHttpServerTest


    public Promise<Void> testWindow() {
        final MessagePort window = Js.cast(DomGlobal.window);

        final HttpServer server = BrowserHttpServers.messagePort((req, resp) -> {
                    resp.setVersion(HttpProtocolVersion.VERSION_1_0);
                    resp.setStatus(HttpStatusCode.withCode(999).setMessage("Custom Status Message"));
                    resp.addEntity(HttpEntity.EMPTY.addHeader(HttpHeaderName.SERVER, "TestMessageServer").setBodyText("Response-" + req.bodyText()));
                }, window,
                new Predicate<>() {

                    public boolean test(final MessageEvent<String> event) {
                        DomGlobal.console.log("Message filter data: " + event.data);
                        return this.counter++ == 0;
                    }

                    // the first message will be a HttpRequest, the next will be the HttpResponse sent back which we want to ignore.
                    int counter;
                },
                "*");

        server.start();

        final List<String> messages = Lists.array();

        // will capture ALL messages, including the request and the response posted back
        window.addEventListener("message", new EventListener() {
            @Override
            public void handleEvent(final Event event) {
                final MessageEvent<String> messageEvent = Js.cast(event);
                DomGlobal.console.log("window message handleEvent: " + messageEvent.data);
                messages.add(messageEvent.data);
            }
        }, false);

        final String request = "GET /path1/file2 HTTP/1.0\r\nContent-Length: 1\r\nContent-Type: text/plain\r\n\r\nBody1234";
        DomGlobal.postMessage(request, "*");

        return new Promise<>(
                (resolve, reject) -> {
                    DomGlobal.setTimeout((ignored) -> {
                                final String response = "HTTP/1.0 999 Custom Status Message\r\nServer: TestMessageServer\r\n\r\nResponse-Body1234";
                                this.checkEquals(Lists.of(request, response), messages);
                                server.stop();
                                resolve.onInvoke((Void) null);
                            },
                            500);
                });
    }

    public Promise<Void> testWindow() {
        final MessagePort window = Js.cast(DomGlobal.window);

        final HttpServer server = BrowserHttpServers.messagePort((req, resp) -> {
                    resp.setVersion(HttpProtocolVersion.VERSION_1_0);
                    resp.setStatus(HttpStatusCode.withCode(999).setMessage("Custom Status Message"));
                    resp.addEntity(HttpEntity.EMPTY.addHeader(HttpHeaderName.SERVER, "TestMessageServer").setBodyText("Response-" + req.bodyText()));
                }, window,
                new Predicate<MessageEvent<String>>() {

                    public boolean test(final MessageEvent<String> event) {
                        DomGlobal.console.log("Message filter data: " + event.data);
                        return this.counter++ == 0;
                    }

                    // the first message will be a HttpRequest, the next will be the HttpResponse sent back which we want to ignore.
                    int counter;
                },
                "*");

        server.start();

        final List<String> messages = Lists.array();

        // will capture ALL messages, including the request and the response posted back
        window.addEventListener("message", new EventListener() {
            @Override
            public void handleEvent(final Event event) {
                final MessageEvent<String> messageEvent = Js.cast(event);
                DomGlobal.console.log("window message handleEvent: " + messageEvent.data);
                messages.add(messageEvent.data);
            }
        }, false);

        final String request = "GET /path1/file2 HTTP/1.0\r\nContent-Length: 1\r\nContent-Type: text/plain\r\n\r\nBody1234";
        DomGlobal.postMessage(request, "*");

        return new Promise<Void>(
                (resolve, reject) -> {
                    DomGlobal.setTimeout((ignored) -> {
                                final String response = "HTTP/1.0 999 Custom Status Message\r\nServer: TestMessageServer\r\n\r\nResponse-Body1234";
                                this.checkEquals(Lists.of(request, response), messages);
                                server.stop();
                                resolve.onInvoke((Void) null);
                            },
                            500);
                });
    }

Replace Generic With Diamond Predicate<MessageEvent<String>> with Predicate<> in method public testWindow() : Promise<Void> from class walkingkooka.net.http.server.browser.BrowserHttpServerTest


    public String generateToken() {
        StringBuilder tokenBuilder = new StringBuilder();
        IntStream.rangeClosed(1, size)
                .map(i -> random.nextInt(TOKEN_CHARACTERS.length - 1))
                .mapToObj(pos -> TOKEN_CHARACTERS[pos])
                .forEach(tokenBuilder::append);

        return tokenBuilder.toString();
    }

    public String generateToken() {
        StringBuilder tokenBuilder = new StringBuilder();
        for (int i = 1; i <= size; i++) {
            tokenBuilder.append(TOKEN_CHARACTERS[random.nextInt(TOKEN_CHARACTERS.length - 1)]);
        }

        return tokenBuilder.toString();
    }

Replace Loop With Pipeline for(int i=1; i <= size; i++) with IntStream.rangeClosed(1,size).map(i -> random.nextInt(TOKEN_CHARACTERS.length - 1)).mapToObj(pos -> TOKEN_CHARACTERS[pos]).forEach(tokenBuilder::append); in method public generateToken() : String from class com.github.games647.verificationserver.TokenGenerator


    public Config() throws IOException {
        try (InputStream resourceStream = getClass().getResourceAsStream('/' + FILE_NAME)) {
            config = new Properties();
            config.load(resourceStream);
        }
    }

    public Config() throws IOException {
        InputStream resourceStream = null;
        try {
            resourceStream = getClass().getResourceAsStream('/' + FILE_NAME);
            config = new Properties();
            config.load(resourceStream);
        } finally {
            if (resourceStream != null) {
                resourceStream.close();
            }
        }
    }

Try With Resources try(InputStream resourceStream=getClass().getResourceAsStream('/' + FILE_NAME)) in method public Config() from class com.github.games647.verificationserver.Config


    public void loadFile() throws IOException {
        File file = new File(FILE_NAME);
        Path path = file.toPath();

        if (!file.exists()) {
            saveConfig();
        }

        try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
            config.load(reader);
        }
    }

    public void loadFile() throws IOException {
        File file = new File(FILE_NAME);
        Path path = file.toPath();

        if (!file.exists()) {
            saveConfig();
        }

        BufferedReader reader = null;
        try {
            reader = Files.newBufferedReader(path, StandardCharsets.UTF_8);
            config.load(reader);
        } finally {
            if (reader != null) {
                reader.close();
            }
        }
    }

Try With Resources try(BufferedReader reader=Files.newBufferedReader(path,StandardCharsets.UTF_8)) in method public loadFile() : void from class com.github.games647.verificationserver.Config


    private void saveConfig() throws IOException {
        File file = new File(FILE_NAME);
        Path path = file.toPath();

        //go to the root folder of the jar
        InputStream resourceStream = getClass().getResourceAsStream('/' + FILE_NAME);
        try (OutputStream out = Files.newOutputStream(path, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE)) {
            byte[] buf = new byte[1_024];
            int len;
            while ((len = resourceStream.read(buf)) > 0) {
                out.write(buf, 0, len);
            }
        } finally {
            if (resourceStream != null) {
                resourceStream.close();
            }
        }
    }

    private void saveConfig() throws IOException {
        File file = new File(FILE_NAME);
        Path path = file.toPath();

        InputStream resourceStream = getClass().getResourceAsStream('/' + FILE_NAME);
        OutputStream out = null;
        try {
            out = Files.newOutputStream(path, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);

            byte[] buf = new byte[1024];
            int len;
            while ((len = resourceStream.read(buf)) > 0) {
                out.write(buf, 0, len);
            }
        } finally {
            if (out != null) {
                out.close();
            }

            if (resourceStream != null) {
                resourceStream.close();
            }
        }
    }

Try With Resources try(OutputStream out=Files.newOutputStream(path,StandardOpenOption.CREATE_NEW,StandardOpenOption.WRITE)) in method private saveConfig() : void from class com.github.games647.verificationserver.Config


    public void createTable() throws SQLException {
        String createUsers = config.get("createUserTable");
        String createToken = config.get("createTokenTable");
        if (createToken.isEmpty() && createUsers.isEmpty()) {
            throw new IllegalStateException("No query specified");
        }

        try (Connection con = dataSource.getConnection()) {
            Statement statement = con.createStatement();
            statement.execute(createUsers);
            statement.execute(createToken);

            LOGGER.info("Finished database setup");
        } catch (SQLException sqlEx) {
            LOGGER.error("Failed to create Table", sqlEx);
            //rethrow it to abort execution
            throw sqlEx;
        }
    }

    public void createTable() throws SQLException {
        String createUsers = config.get("createUserTable");
        String createToken = config.get("createTokenTable");
        if (createToken.isEmpty() && createUsers.isEmpty()) {
            throw new IllegalStateException("No query specified");
        }

        Connection con = null;
        try {
            con = dataSource.getConnection();
            Statement statement = con.createStatement();
            statement.execute(createUsers);
            statement.execute(createToken);
        } catch (SQLException sqlEx) {
            LOGGER.error("Failed to create Table", sqlEx);
            //rethrow it to abort execution
            throw sqlEx;
        } finally {
            if (con != null) {
                con.close();
            }
        }
    }

Try With Resources try(Connection con=dataSource.getConnection()) in method public createTable() : void from class com.github.games647.verificationserver.VerificationServer


/**
     * Static Semantics: BoundNames
     *

     *
12.1.2 Static Semantics: BoundNames
     *
13.3.3.1 Static Semantics: BoundNames
     *

     *
     * @param node
     *            the binding node
     * @return the bound names
     */
    public static List<Name> BoundNames(Binding node) {
        if (node instanceof BindingIdentifier) {
            return singletonList(((BindingIdentifier) node).getName());
        }
        assert node instanceof BindingPattern;
        return node.accept(BoundNames.INSTANCE, new InlineArrayList<>());
    }

/**
     * Static Semantics: BoundNames
     *

     *
12.1.2 Static Semantics: BoundNames
     *
13.3.3.1 Static Semantics: BoundNames
     *

     *
     * @param node
     *            the binding node
     * @return the bound names
     */
    public static List<Name> BoundNames(Binding node) {
        if (node instanceof BindingIdentifier) {
            return singletonList(((BindingIdentifier) node).getName());
        }
        assert node instanceof BindingPattern;
        return node.accept(BoundNames.INSTANCE, new InlineArrayList<Name>());
    }

Replace Generic With Diamond InlineArrayList<Name> with InlineArrayList<> in method public BoundNames(node Binding) : List<Name> from class com.github.anba.es6draft.semantics.StaticSemantics


/**
     * Static Semantics: BoundNames
     *

     *
14.1.3 Static Semantics: BoundNames
     *
14.2.2 Static Semantics: BoundNames
     *

     *
     * @param formals
     *            the formal parameters list
     * @return the bound names
     */
    public static List<Name> BoundNames(List<FormalParameter> formals) {
        // TODO: Some callers expect the returned list to be mutable.
        InlineArrayList<Name> list = new InlineArrayList<>();
        for (FormalParameter formalParameter : formals) {
            formalParameter.accept(BoundNames.INSTANCE, list);
        }
        return list;
    }

/**
     * Static Semantics: BoundNames
     *

     *
14.1.3 Static Semantics: BoundNames
     *
14.2.2 Static Semantics: BoundNames
     *

     *
     * @param formals
     *            the formal parameters list
     * @return the bound names
     */
    public static List<Name> BoundNames(List<FormalParameter> formals) {
        // TODO: Some callers expect the returned list to be mutable.
        InlineArrayList<Name> list = new InlineArrayList<Name>();
        for (FormalParameter formalParameter : formals) {
            formalParameter.accept(BoundNames.INSTANCE, list);
        }
        return list;
    }

Replace Generic With Diamond InlineArrayList<Name> with InlineArrayList<> in method public BoundNames(formals List<FormalParameter>) : List<Name> from class com.github.anba.es6draft.semantics.StaticSemantics


/**
     * Static Semantics: BoundNames
     *

     *
13.3.1.2 Static Semantics: BoundNames
     *
14.1.3 Static Semantics: BoundNames
     *
14.4.2 Static Semantics: BoundNames
     *
14.5.2 Static Semantics: BoundNames
     *

     *
     * @param node
     *            the declaration node
     * @return the bound names
     */
    public static List<Name> BoundNames(Declaration node) {
        if (node instanceof HoistableDeclaration) {
            return singletonList(BoundName((HoistableDeclaration) node));
        }
        if (node instanceof ClassDeclaration) {
            return singletonList(BoundName((ClassDeclaration) node));
        }
        if (node instanceof ExportDefaultExpression) {
            return BoundNames(((ExportDefaultExpression) node).getBinding());
        }
        assert node instanceof LexicalDeclaration;
        return node.accept(BoundNames.INSTANCE, new InlineArrayList<>());
    }

/**
     * Static Semantics: BoundNames
     *

     *
13.3.1.2 Static Semantics: BoundNames
     *
14.1.3 Static Semantics: BoundNames
     *
14.4.2 Static Semantics: BoundNames
     *
14.5.2 Static Semantics: BoundNames
     *

     *
     * @param node
     *            the declaration node
     * @return the bound names
     */
    public static List<Name> BoundNames(Declaration node) {
        if (node instanceof HoistableDeclaration) {
            return singletonList(BoundName((HoistableDeclaration) node));
        }
        if (node instanceof ClassDeclaration) {
            return singletonList(BoundName((ClassDeclaration) node));
        }
        if (node instanceof ExportDefaultExpression) {
            return BoundNames(((ExportDefaultExpression) node).getBinding());
        }
        assert node instanceof LexicalDeclaration;
        return node.accept(BoundNames.INSTANCE, new InlineArrayList<Name>());
    }

Replace Generic With Diamond InlineArrayList<Name> with InlineArrayList<> in method public BoundNames(node Declaration) : List<Name> from class com.github.anba.es6draft.semantics.StaticSemantics


    /**
     * 13.3.2.1 Static Semantics: BoundNames
     *
     * @param node
     *            the variable statement
     * @return the bound names
     */
    public static List<Name> BoundNames(VariableStatement node) {
        return node.accept(BoundNames.INSTANCE, new InlineArrayList<>());
    }

    /**
     * 13.3.2.1 Static Semantics: BoundNames
     *
     * @param node
     *            the variable statement
     * @return the bound names
     */
    public static List<Name> BoundNames(VariableStatement node) {
        return node.accept(BoundNames.INSTANCE, new InlineArrayList<Name>());
    }

Replace Generic With Diamond InlineArrayList<Name> with InlineArrayList<> in method public BoundNames(node VariableStatement) : List<Name> from class com.github.anba.es6draft.semantics.StaticSemantics


    /**
     * 15.2.2.2 Static Semantics: BoundNames
     *
     * @param node
     *            the import declaration
     * @return the bound names
     */
    public static List<Name> BoundNames(ImportDeclaration node) {
        return node.accept(BoundNames.INSTANCE, new InlineArrayList<>());
    }

    /**
     * 15.2.2.2 Static Semantics: BoundNames
     *
     * @param node
     *            the import declaration
     * @return the bound names
     */
    public static List<Name> BoundNames(ImportDeclaration node) {
        return node.accept(BoundNames.INSTANCE, new InlineArrayList<Name>());
    }

Replace Generic With Diamond InlineArrayList<Name> with InlineArrayList<> in method public BoundNames(node ImportDeclaration) : List<Name> from class com.github.anba.es6draft.semantics.StaticSemantics


    /**
     * 15.2.3.2 Static Semantics: BoundNames
     *
     * @param node
     *            the export declaration
     * @return the bound names
     */
    public static List<Name> BoundNames(ExportDeclaration node) {
        return node.accept(BoundNames.INSTANCE, new InlineArrayList<>());
    }

    /**
     * 15.2.3.2 Static Semantics: BoundNames
     *
     * @param node
     *            the export declaration
     * @return the bound names
     */
    public static List<Name> BoundNames(ExportDeclaration node) {
        return node.accept(BoundNames.INSTANCE, new InlineArrayList<Name>());
    }

Replace Generic With Diamond InlineArrayList<Name> with InlineArrayList<> in method public BoundNames(node ExportDeclaration) : List<Name> from class com.github.anba.es6draft.semantics.StaticSemantics


        @Override
        public void visit(BindingElement node, Variable<? extends Iterator<?>> iterator) {
            Binding binding = node.getBinding();
            Expression initializer = node.getInitializer();

            if (binding instanceof BindingPattern) {
                // BindingElement : BindingPattern Initializer{opt}
                /* steps 1-2 */
                emitIteratorNext(node, iterator);

                /* step 3 */
                // stack: [v] -> [v']
                if (initializer != null) {
                    emitDefaultInitializer(initializer);
                }

                /* step 4 */
                // stack: [v'] -> []
                BindingInitialization((BindingPattern) binding);
                return;
            }

            // BindingElement : SingleNameBinding
            // SingleNameBinding : BindingIdentifier Initializer{opt}
            assert binding instanceof BindingIdentifier;

            if (envRec == null) {
                /* step 1 */
                BindingIdentifier bindingId = (BindingIdentifier) binding;

                /* steps 2-3 */
                // stack: [] -> [ref]
                IdReferenceOp op = IdReferenceOp.of(bindingId);
                op.resolveBinding(bindingId, mv);

                /* steps 4-5 */
                emitIteratorNext(node, iterator);

                /* step 6 */
                // stack: [ref, v] -> [ref, v']
                if (initializer != null) {
                    emitDefaultInitializer(initializer, bindingId);
                }

                /* steps 7-8 */
                // stack: [ref, v'] -> []
                op.putValue(bindingId, ValType.Any, mv);
            } else {
                /* step 1 */
                BindingIdentifier bindingId = (BindingIdentifier) binding;

                /* steps 2-3, 7-8 */
                BindingOp<EnvironmentRecord> op = BindingOp.of(envRec, bindingId.getName());
                op.initializeBinding(envRec, bindingId.getName(), asm -> {
                    /* steps 4-5 */
                    emitIteratorNext(node, iterator);

                    /* step 6 */
                    // stack: [<env, id>|ref, v] -> [<env, id>|ref, v']
                    if (initializer != null) {
                        emitDefaultInitializer(initializer, bindingId);
                    }
                }, mv);
            }
        }

        @Override
        public void visit(final BindingElement node, final Variable<? extends Iterator<?>> iterator) {
            final Binding binding = node.getBinding();
            final Expression initializer = node.getInitializer();

            if (binding instanceof BindingPattern) {
                // BindingElement : BindingPattern Initializer{opt}
                /* steps 1-2 */
                emitIteratorNext(node, iterator);

                /* step 3 */
                // stack: [v] -> [v']
                if (initializer != null) {
                    emitDefaultInitializer(initializer);
                }

                /* step 4 */
                // stack: [v'] -> []
                BindingInitialization((BindingPattern) binding);
                return;
            }

            // BindingElement : SingleNameBinding
            // SingleNameBinding : BindingIdentifier Initializer{opt}
            assert binding instanceof BindingIdentifier;

            if (envRec == null) {
                /* step 1 */
                BindingIdentifier bindingId = (BindingIdentifier) binding;

                /* steps 2-3 */
                // stack: [] -> [ref]
                IdReferenceOp op = IdReferenceOp.of(bindingId);
                op.resolveBinding(bindingId, mv);

                /* steps 4-5 */
                emitIteratorNext(node, iterator);

                /* step 6 */
                // stack: [ref, v] -> [ref, v']
                if (initializer != null) {
                    emitDefaultInitializer(initializer, bindingId);
                }

                /* steps 7-8 */
                // stack: [ref, v'] -> []
                op.putValue(bindingId, ValType.Any, mv);
            } else {
                /* step 1 */
                final BindingIdentifier bindingId = (BindingIdentifier) binding;

                /* steps 2-3, 7-8 */
                BindingOp<EnvironmentRecord> op = BindingOp.of(envRec, bindingId.getName());
                op.initializeBinding(envRec, bindingId.getName(), new Value<Object>() {
                    @Override
                    protected void load(InstructionAssembler assembler) {
                        /* steps 4-5 */
                        emitIteratorNext(node, iterator);

                        /* step 6 */
                        // stack: [<env, id>|ref, v] -> [<env, id>|ref, v']
                        if (initializer != null) {
                            emitDefaultInitializer(initializer, bindingId);
                        }
                    }
                }, mv);
            }
        }

Replace Anonymous With Lambda com.github.anba.es6draft.compiler.BindingInitializationGenerator.IteratorBindingInitialization.visit.initializeBinding.new Value<Object> with asm -> {emitIteratorNext(node,iterator); in method public visit(node BindingElement, iterator Variable<? extends Iterator<?>>) : void from class com.github.anba.es6draft.compiler.BindingInitializationGenerator.IteratorBindingInitialization


        @Override
        public void visit(BindingRestElement node, Variable<? extends Iterator<?>> iterator) {
            BindingIdentifier identifier = node.getBindingIdentifier();
            if (envRec == null) {
                /* steps 1-2 */
                // stack: [] -> [ref]
                IdReferenceOp op = IdReferenceOp.of(identifier);
                op.resolveBinding(identifier, mv);

                /* steps 3-5 */
                // stack: [ref] -> [ref, array]
                emitCreateRestArray(node, iterator);

                /* step 5.b */
                // stack: [ref, array] -> []
                op.putValue(identifier, ValType.Any, mv);
            } else {
                /* steps 1-2, 5.b */
                BindingOp<EnvironmentRecord> op = BindingOp.of(envRec, identifier.getName());
                op.initializeBinding(envRec, identifier.getName(), asm -> {
                    /* steps 3-5 */
                    emitCreateRestArray(node, iterator);
                }, mv);
            }
        }

        @Override
        public void visit(final BindingRestElement node,
                final Variable<? extends Iterator<?>> iterator) {
            BindingIdentifier identifier = node.getBindingIdentifier();
            if (envRec == null) {
                /* steps 1-2 */
                // stack: [] -> [ref]
                IdReferenceOp op = IdReferenceOp.of(identifier);
                op.resolveBinding(identifier, mv);

                /* steps 3-5 */
                // stack: [ref] -> [ref, array]
                emitCreateRestArray(node, iterator);

                /* step 5.b */
                // stack: [ref, array] -> []
                op.putValue(identifier, ValType.Any, mv);
            } else {
                /* steps 1-2, 5.b */
                BindingOp<EnvironmentRecord> op = BindingOp.of(envRec, identifier.getName());
                op.initializeBinding(envRec, identifier.getName(), new Value<Object>() {
                    @Override
                    protected void load(InstructionAssembler assembler) {
                        /* steps 3-5 */
                        emitCreateRestArray(node, iterator);
                    }
                }, mv);
            }
        }

Replace Anonymous With Lambda com.github.anba.es6draft.compiler.BindingInitializationGenerator.IteratorBindingInitialization.visit.initializeBinding.new Value<Object> with asm -> {emitCreateRestArray(node,iterator); in method public visit(node BindingRestElement, iterator Variable<? extends Iterator<?>>) : void from class com.github.anba.es6draft.compiler.BindingInitializationGenerator.IteratorBindingInitialization


        @Override
        public void visit(BindingProperty node, PROPERTYNAME propertyName) {
            Binding binding = node.getBinding();
            Expression initializer = node.getInitializer();

            if (binding instanceof BindingPattern) {
                // stack: [] -> [cx, value]
                mv.loadExecutionContext();
                mv.load(value);

                /* steps 1-2 (Runtime Semantics: BindingInitialization 13.3.3.5) */
                // stack: [cx, value] -> [cx, value, propertyName]
                ValType type = evaluatePropertyName(propertyName);

                /* steps 1-2 */
                // stack: [cx, value, propertyName] -> [v]
                emitGetV(node, type);

                /* step 3 */
                // stack: [v] -> [v']
                if (initializer != null) {
                    emitDefaultInitializer(initializer);
                }

                /* step 4 */
                // stack: [v'] -> []
                BindingInitialization((BindingPattern) binding);
                return;
            }
            assert binding instanceof BindingIdentifier;

            if (envRec == null) {
                /* step 1 */
                BindingIdentifier bindingId = (BindingIdentifier) binding;
                IdReferenceOp op = IdReferenceOp.of(bindingId);

                ValType type;
                if (isSimplePropertyNameOrTarget(bindingId, propertyName)) {
                    /* steps 2-3 */
                    // stack: [] -> [ref]
                    op.resolveBinding(bindingId, mv);

                    // stack: [ref] -> [ref, cx, value]
                    mv.loadExecutionContext();
                    mv.load(value);

                    /* steps 1-2 (Runtime Semantics: BindingInitialization 13.3.3.5) */
                    // stack: [ref, cx, value] -> [ref, cx, value, propertyName]
                    type = evaluatePropertyName(propertyName);
                } else {
                    /* steps 1-2 (Runtime Semantics: BindingInitialization 13.3.3.5) */
                    // stack: [] -> []
                    type = evaluatePropertyName(propertyName);
                    Variable<?> propertyNameVar = mv.newScratchVariable(type.toClass());
                    mv.store(propertyNameVar);

                    /* steps 2-3 */
                    // stack: [] -> [ref]
                    op.resolveBinding(bindingId, mv);

                    // stack: [ref] -> [ref, cx, value, propertyName]
                    mv.loadExecutionContext();
                    mv.load(value);
                    mv.load(propertyNameVar);
                    mv.freeVariable(propertyNameVar);
                }

                /* steps 4-5 */
                // stack: [ref, cx, value, propertyName] -> [ref, v]
                emitGetV(node, type);

                /* step 6 */
                // stack: [ref, v] -> [ref, v']
                if (initializer != null) {
                    emitDefaultInitializer(initializer, bindingId);
                }

                /* steps 7-8 */
                // stack: [ref, v'] -> []
                op.putValue(bindingId, ValType.Any, mv);
            } else {
                /* step 1 */
                BindingIdentifier bindingId = (BindingIdentifier) binding;
                /* steps 2-3, 7-8 */
                BindingOp<EnvironmentRecord> op = BindingOp.of(envRec, bindingId.getName());
                op.initializeBinding(envRec, bindingId.getName(), asm -> {
                    // stack: [] -> [cx, value]
                    mv.loadExecutionContext();
                    mv.load(value);

                    /* steps 1-2 (Runtime Semantics: BindingInitialization 13.3.3.5) */
                    // stack: [cx, value] -> [cx, value, propertyName]
                    ValType type = evaluatePropertyName(propertyName);

                    /* steps 4-5 */
                    // stack: [cx, value, propertyName] -> [v]
                    emitGetV(node, type);

                    /* step 6 */
                    // stack: [v] -> [v']
                    if (initializer != null) {
                        emitDefaultInitializer(initializer, bindingId);
                    }
                }, mv);
            }
        }

        @Override
        public void visit(final BindingProperty node, final PROPERTYNAME propertyName) {
            final Binding binding = node.getBinding();
            final Expression initializer = node.getInitializer();

            if (binding instanceof BindingPattern) {
                // stack: [] -> [cx, value]
                mv.loadExecutionContext();
                mv.load(value);

                /* steps 1-2 (Runtime Semantics: BindingInitialization 13.3.3.5) */
                // stack: [cx, value] -> [cx, value, propertyName]
                ValType type = evaluatePropertyName(propertyName);

                /* steps 1-2 */
                // stack: [cx, value, propertyName] -> [v]
                emitGetV(node, type);

                /* step 3 */
                // stack: [v] -> [v']
                if (initializer != null) {
                    emitDefaultInitializer(initializer);
                }

                /* step 4 */
                // stack: [v'] -> []
                BindingInitialization((BindingPattern) binding);
                return;
            }
            assert binding instanceof BindingIdentifier;

            if (envRec == null) {
                /* step 1 */
                BindingIdentifier bindingId = (BindingIdentifier) binding;
                IdReferenceOp op = IdReferenceOp.of(bindingId);

                ValType type;
                if (isSimplePropertyNameOrTarget(bindingId, propertyName)) {
                    /* steps 2-3 */
                    // stack: [] -> [ref]
                    op.resolveBinding(bindingId, mv);

                    // stack: [ref] -> [ref, cx, value]
                    mv.loadExecutionContext();
                    mv.load(value);

                    /* steps 1-2 (Runtime Semantics: BindingInitialization 13.3.3.5) */
                    // stack: [ref, cx, value] -> [ref, cx, value, propertyName]
                    type = evaluatePropertyName(propertyName);
                } else {
                    /* steps 1-2 (Runtime Semantics: BindingInitialization 13.3.3.5) */
                    // stack: [] -> []
                    type = evaluatePropertyName(propertyName);
                    Variable<?> propertyNameVar = mv.newScratchVariable(type.toClass());
                    mv.store(propertyNameVar);

                    /* steps 2-3 */
                    // stack: [] -> [ref]
                    op.resolveBinding(bindingId, mv);

                    // stack: [ref] -> [ref, cx, value, propertyName]
                    mv.loadExecutionContext();
                    mv.load(value);
                    mv.load(propertyNameVar);
                    mv.freeVariable(propertyNameVar);
                }

                /* steps 4-5 */
                // stack: [ref, cx, value, propertyName] -> [ref, v]
                emitGetV(node, type);

                /* step 6 */
                // stack: [ref, v] -> [ref, v']
                if (initializer != null) {
                    emitDefaultInitializer(initializer, bindingId);
                }

                /* steps 7-8 */
                // stack: [ref, v'] -> []
                op.putValue(bindingId, ValType.Any, mv);
            } else {
                /* step 1 */
                final BindingIdentifier bindingId = (BindingIdentifier) binding;
                /* steps 2-3, 7-8 */
                BindingOp<EnvironmentRecord> op = BindingOp.of(envRec, bindingId.getName());
                op.initializeBinding(envRec, bindingId.getName(), new Value<Object>() {
                    @Override
                    protected void load(InstructionAssembler assembler) {
                        // stack: [] -> [cx, value]
                        mv.loadExecutionContext();
                        mv.load(value);

                        /* steps 1-2 (Runtime Semantics: BindingInitialization 13.3.3.5) */
                        // stack: [cx, value] -> [cx, value, propertyName]
                        ValType type = evaluatePropertyName(propertyName);

                        /* steps 4-5 */
                        // stack: [cx, value, propertyName] -> [v]
                        emitGetV(node, type);

                        /* step 6 */
                        // stack: [v] -> [v']
                        if (initializer != null) {
                            emitDefaultInitializer(initializer, bindingId);
                        }
                    }
                }, mv);
            }
        }

Replace Anonymous With Lambda com.github.anba.es6draft.compiler.BindingInitializationGenerator.KeyedBindingInitialization.visit.initializeBinding.new Value<Object> with asm -> {mv.loadExecutionContext(); in method public visit(node BindingProperty, propertyName PROPERTYNAME) : void from class com.github.anba.es6draft.compiler.BindingInitializationGenerator.KeyedBindingInitialization


    /**
     * 12.1.5.1 Runtime Semantics: InitializeBoundName(name, value, environment)
     * <p>
     * stack: [] {@literal ->} []
     *
     * @param mv
     *            the expression visitor
     */
    static <ENVREC extends EnvironmentRecord> void InitializeBoundNameWithInitializer(CodeGenerator codegen,
            Variable<? extends ENVREC> envRec, Name name, Expression initializer, ExpressionVisitor mv) {
        InitializeBoundName(envRec, name, asm -> {
            codegen.expressionBoxed(initializer, mv);
            if (IsAnonymousFunctionDefinition(initializer)) {
                SetFunctionName(initializer, name, mv);
            }
        }, mv);
    }

    /**
     * 12.1.5.1 Runtime Semantics: InitializeBoundName(name, value, environment)
     * <p>
     * stack: [] {@literal ->} []
     *
     * @param mv
     *            the expression visitor
     */
    static <ENVREC extends EnvironmentRecord> void InitializeBoundNameWithInitializer(
            final CodeGenerator codegen, Variable<? extends ENVREC> envRec, final Name name,
            final Expression initializer, final ExpressionVisitor mv) {
        InitializeBoundName(envRec, name, new Value<Object>() {
            @Override
            protected void load(InstructionAssembler assembler) {
                codegen.expressionBoxed(initializer, mv);
                if (IsAnonymousFunctionDefinition(initializer)) {
                    SetFunctionName(initializer, name, mv);
                }
            }
        }, mv);
    }

Replace Anonymous With Lambda com.github.anba.es6draft.compiler.BindingInitializationGenerator.InitializeBoundNameWithInitializer.InitializeBoundName.new Value<Object> with asm -> {codegen.expressionBoxed(initializer,mv); in method package InitializeBoundNameWithInitializer(codegen CodeGenerator, envRec Variable<? extends ENVREC>, name Name, initializer Expression, mv ExpressionVisitor) : void from class com.github.anba.es6draft.compiler.BindingInitializationGenerator


    protected static final <T> Iterable<T> reverse(List<T> list) {
        return () -> new Iterator<T>() {
            final ListIterator<T> iter = list.listIterator(list.size());

            @Override
            public boolean hasNext() {
                return iter.hasPrevious();
            }

            @Override
            public T next() {
                return iter.previous();
            }
        };
    }

    protected static final <T> Iterable<T> reverse(final List<T> list) {
        return new Iterable<T>() {
            @Override
            public Iterator<T> iterator() {
                return new Iterator<T>() {
                    ListIterator<T> iter = list.listIterator(list.size());

                    @Override
                    public boolean hasNext() {
                        return iter.hasPrevious();
                    }

                    @Override
                    public T next() {
                        return iter.previous();
                    }

                    @Override
                    public void remove() {
                        throw new UnsupportedOperationException();
                    }
                };
            }
        };
    }

Replace Anonymous With Lambda com.github.anba.es6draft.compiler.DeclarationBindingInstantiationGenerator.reverse.new Iterable<T> with () -> new Iterator<T>(){ in method protected reverse(list List<T>) : Iterable<T> from class com.github.anba.es6draft.compiler.DeclarationBindingInstantiationGenerator


    private static <T> Iterable<T> reverse(List<T> list) {
        return () -> new Iterator<T>() {
            final ListIterator<T> iter = list.listIterator(list.size());

            @Override
            public boolean hasNext() {
                return iter.hasPrevious();
            }

            @Override
            public T next() {
                return iter.previous();
            }
        };
    }

    private static <T> Iterable<T> reverse(final List<T> list) {
        return new Iterable<T>() {
            @Override
            public Iterator<T> iterator() {
                return new Iterator<T>() {
                    ListIterator<T> iter = list.listIterator(list.size());

                    @Override
                    public boolean hasNext() {
                        return iter.hasPrevious();
                    }

                    @Override
                    public T next() {
                        return iter.previous();
                    }

                    @Override
                    public void remove() {
                        throw new UnsupportedOperationException();
                    }
                };
            }
        };
    }

Replace Anonymous With Lambda com.github.anba.es6draft.compiler.completion.CompletionValueVisitor.reverse.new Iterable<T> with () -> new Iterator<T>(){ in method private reverse(list List<T>) : Iterable<T> from class com.github.anba.es6draft.compiler.completion.CompletionValueVisitor


    private static <T extends TestInfo> Function<Path, T> mapper(BiFunction<Path, Iterator<String>, T> fn) {
        return file -> {
            try (BufferedReader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) {
                return fn.apply(file, new LineIterator(reader));
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        };
    }

    private static <T extends TestInfo> Function<Path, T> mapper(
            final BiFunction<Path, Iterator<String>, T> fn) {
        return new Function<Path, T>() {
            @Override
            public T apply(Path file) {
                try (BufferedReader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) {
                    return fn.apply(file, new LineIterator(reader));
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
        };
    }

Replace Anonymous With Lambda com.github.anba.es6draft.util.Resources.mapper.new Function<Path,T> with file -> {try(BufferedReader reader=Files.newBufferedReader(file,StandardCharsets.UTF_8))return fn.apply(file,new LineIterator(reader)); in method private mapper(fn BiFunction<Path,Iterator<String>,T>) : Function<Path,T> from class com.github.anba.es6draft.util.Resources


    /**
     * Construct a new empty map.
     */
    public LinkedMap() {
        map = new HashMap<>();
        head = new Entry<>(null, null);
        head.prev = head;
        head.next = head;
    }

    /**
     * Construct a new empty map.
     */
    public LinkedMap() {
        map = new HashMap<>();
        head = new Entry<KEY, VALUE>(null, null);
        head.prev = head;
        head.next = head;
    }

Replace Generic With Diamond Entry<KEY,VALUE> with Entry<> in method public LinkedMap() from class com.github.anba.es6draft.runtime.internal.LinkedMap


    @Override
    public MODULE load(SourceIdentifier identifier) throws MalformedNameException, IOException {
        MODULE module = loadIfAbsent(identifier);
        loadRequested(module, new HashSet<>());
        return module;
    }

    @Override
    public MODULE load(SourceIdentifier identifier) throws MalformedNameException, IOException {
        MODULE module = loadIfAbsent(identifier);
        loadRequested(module, new HashSet<ModuleRecord>());
        return module;
    }

Replace Generic With Diamond HashSet<ModuleRecord> with HashSet<> in method public load(identifier SourceIdentifier) : MODULE from class com.github.anba.es6draft.runtime.modules.loader.AbstractModuleLoader


        public GetCapabilitiesExecutor(Realm realm) {
            this(realm, new MutRef<>(UNDEFINED), new MutRef<>(UNDEFINED));
            createDefaultFunctionProperties();
        }

        public GetCapabilitiesExecutor(Realm realm) {
            this(realm, new MutRef<Object>(UNDEFINED), new MutRef<Object>(UNDEFINED));
            createDefaultFunctionProperties();
        }

Replace Generic With Diamond MutRef<Object> with MutRef<> in method public GetCapabilitiesExecutor(realm Realm) from class com.github.anba.es6draft.runtime.objects.promise.PromiseAbstractOperations.GetCapabilitiesExecutor


	protected Quadrilateral2D paint(BufferedImage dst,
			RenderingHints renderingHints, BufferedImage img,
			Quadrilateral3D quad3D, boolean skipIfFlippedHorizontally,
			boolean skipIfFlippedVertically) {
		Quadrilateral2D quad2 = quad3D.toQuadrilateral2D(dst.getWidth(),
				dst.getHeight());

		if (skipIfFlippedHorizontally && quad2.isFlippedHorizontally()) {
			return null;
		}
		if (skipIfFlippedVertically && quad2.isFlippedVertically()) {
			return null;
		}

		try (ImageContext context = ImageContext.create(dst)) {
			context.setRenderingHints(renderingHints);
			context.drawImage(img, quad2.topLeft, quad2.topRight,
					quad2.bottomRight, quad2.bottomLeft);
		}

		return quad2;

	}

	protected Quadrilateral2D paint(BufferedImage dst,
			RenderingHints renderingHints, BufferedImage img,
			Quadrilateral3D quad3D, boolean skipIfFlippedHorizontally,
			boolean skipIfFlippedVertically) {
		Quadrilateral2D quad2 = quad3D.toQuadrilateral2D(dst.getWidth(),
				dst.getHeight());

		if (skipIfFlippedHorizontally && quad2.isFlippedHorizontally()) {
			return null;
		}
		if (skipIfFlippedVertically && quad2.isFlippedVertically()) {
			return null;
		}

		ImageContext context = ImageContext.create(dst);
		try {
			context.setRenderingHints(renderingHints);
			context.drawImage(img, quad2.topLeft, quad2.topRight,
					quad2.bottomRight, quad2.bottomLeft);
		} finally {
			context.dispose();
		}

		return quad2;

	}

Try With Resources try(ImageContext context=ImageContext.create(dst)) in method protected paint(dst BufferedImage, renderingHints RenderingHints, img BufferedImage, quad3D Quadrilateral3D, skipIfFlippedHorizontally boolean, skipIfFlippedVertically boolean) : Quadrilateral2D from class com.pump.image.transition.Transition3D


        @Override
        public void run() {
            ImageConsumer[] consumers = imageProducer.popPendingImageConsumers();
            if (consumers.length == 0)
                return;
            ImageConsumer multiConsumer = new MultiImageConsumer(consumers);

            int exitCode = ImageConsumer.IMAGEERROR;
            try {
                int width = imageProducer.pixelSource.getWidth();
                int height = imageProducer.pixelSource.getHeight();
                multiConsumer.setDimensions(width, height);

                try (PixelIterator iterator = imageProducer.pixelSource.createPixelIterator()) {
                    int hints = ImageConsumer.COMPLETESCANLINES + ImageConsumer.SINGLEPASS + ImageConsumer.SINGLEFRAME;
                    if (iterator.isTopDown())
                        hints += ImageConsumer.TOPDOWNLEFTRIGHT;

                    multiConsumer.setHints(hints);

                    ImageType type = ImageType.get(iterator.getType());
                    ColorModel colorModel = type.getColorModel();

                    multiConsumer.setColorModel(colorModel);

                    int pixelSize = iterator.getPixelSize();

                    int y = iterator.isTopDown() ? 0 : height - 1;
                    int yIncr = iterator.isTopDown() ? 1 : -1;
                    if (iterator.isInt()) {
                        int[] row = new int[iterator.getWidth() * pixelSize];
                        for (int k = 0; k < height; k++) {
                            iterator.next(row, 0);
                            multiConsumer.setPixels(0, y, width, 1, colorModel, row, 0, width * pixelSize);
                            y += yIncr;
                        }
                    } else {
                        byte[] row = new byte[iterator.getWidth() * iterator.getPixelSize()];
                        for (int k = 0; k < height; k++) {
                            iterator.next(row, 0);
                            multiConsumer.setPixels(0, y, width, 1, colorModel, row, 0, width * pixelSize);
                            y += yIncr;
                        }
                    }
                }
                exitCode = ImageConsumer.STATICIMAGEDONE;
            } catch(Throwable t) {
                t.printStackTrace();
            } finally {
                multiConsumer.imageComplete(exitCode);
            }
        }

        @Override
        public void run() {
            ImageConsumer[] consumers = imageProducer.popPendingImageConsumers();
            if (consumers.length == 0)
                return;
            ImageConsumer multiConsumer = new MultiImageConsumer(consumers);

            int exitCode = ImageConsumer.IMAGEERROR;
            try {
                int width = imageProducer.pixelSource.getWidth();
                int height = imageProducer.pixelSource.getHeight();
                multiConsumer.setDimensions(width, height);

                PixelIterator iterator = imageProducer.pixelSource.createPixelIterator();

                int hints = ImageConsumer.COMPLETESCANLINES + ImageConsumer.SINGLEPASS + ImageConsumer.SINGLEFRAME;
                if (iterator.isTopDown())
                    hints += ImageConsumer.TOPDOWNLEFTRIGHT;

                multiConsumer.setHints(hints);

                ImageType type = ImageType.get(iterator.getType());
                ColorModel colorModel = type.getColorModel();

                multiConsumer.setColorModel(colorModel);

                int pixelSize = iterator.getPixelSize();

                int y = iterator.isTopDown() ? 0 : height - 1;
                int yIncr = iterator.isTopDown() ? 1 : -1;
                if (iterator.isInt()) {
                    int[] row = new int[iterator.getWidth() * pixelSize];
                    for (int k = 0; k < height; k++) {
                        iterator.next(row, 0);
                        multiConsumer.setPixels(0, y, width, 1, colorModel, row, 0, width * pixelSize);
                        y += yIncr;
                    }
                } else {
                    byte[] row = new byte[iterator.getWidth() * iterator.getPixelSize()];
                    for (int k = 0; k < height; k++) {
                        iterator.next(row, 0);
                        multiConsumer.setPixels(0, y, width, 1, colorModel, row, 0, width * pixelSize);
                        y += yIncr;
                    }
                }
                exitCode = ImageConsumer.STATICIMAGEDONE;
            } catch(Throwable t) {
                t.printStackTrace();
            } finally {
                multiConsumer.imageComplete(exitCode);
            }
        }

Try With Resources try(PixelIterator iterator=imageProducer.pixelSource.createPixelIterator()) in method public run() : void from class com.pump.image.pixel.PixelSourceImageProducer.ImageProductionRunnable


		@Override
		public Void call() throws Exception {
			File classTransitionDir = new File(transitionDir,
					transition.getClass().getSimpleName());
			context.indexDirectory(classTransitionDir);
			transitionClassDirs.add(classTransitionDir);
			String filename = (transition.toString() + ".gif").replaceAll(" ",
					"");

			if (!classTransitionDir.exists() && !classTransitionDir.mkdirs())
				throw new IOException("File.mkdirs() failed for "
						+ classTransitionDir.getAbsolutePath());

			gifFile = new File(classTransitionDir, filename);

			try (AdjacentFile adjFile = context
					.createAdjacentFile(gifFile)) {
				try (FileOutputStream fileOut = adjFile.createOutputStream()) {
					writeTransition(transition, fileOut);
				} catch (Exception e) {
					adjFile.cancel();
					throw e;
				}
			}
			System.out.println("Wrote: " + gifFile.getAbsolutePath());
			return null;
		}

		@Override
		public Void call() throws Exception {
			File classTransitionDir = new File(transitionDir,
					transition.getClass().getSimpleName());
			context.indexDirectory(classTransitionDir);
			transitionClassDirs.add(classTransitionDir);
			String filename = (transition.toString() + ".gif").replaceAll(" ",
					"");

			if (!classTransitionDir.exists() && !classTransitionDir.mkdirs())
				throw new IOException("File.mkdirs() failed for "
						+ classTransitionDir.getAbsolutePath());

			gifFile = new File(classTransitionDir, filename);

			try (AdjacentFileOutputStream fileOut = context
					.createFileOutputStream(gifFile)) {
				try {
					writeTransition(transition, fileOut);
				} catch (Exception e) {
					fileOut.cancel();
					throw e;
				}
			}
			System.out.println("Wrote: " + gifFile.getAbsolutePath());
			return null;
		}

Try With Resources try(FileOutputStream fileOut=adjFile.createOutputStream()) in method public call() : Void from class com.pump.showcase.resourcegenerator.Transition2DDemoResourceGenerator.Output


	private static BufferedImage scale(String name, InputStreamSource src,
			int preferredType, Dimension destSize) {
		String pathLower = name.toLowerCase();
		if (pathLower.endsWith(".bmp")) {
			try (InputStream in = src.createInputStream()) {
				PixelIterator iter = BmpDecoderIterator.get(in);
				PixelIterator scalingIter = destSize == null ? iter
						: ScalingIterator.get(iter, destSize.width,
								destSize.height);
				PixelIterator finalIter = scalingIter;
				if (preferredType == BufferedImage.TYPE_INT_ARGB
						|| preferredType == BufferedImage.TYPE_INT_ARGB_PRE) {
					finalIter = new IntARGBConverter(scalingIter);
				} else if (preferredType == BufferedImage.TYPE_INT_RGB) {
					finalIter = new IntRGBConverter(scalingIter);
				} else if (preferredType == BufferedImage.TYPE_3BYTE_BGR) {
					finalIter = new ByteBGRConverter(scalingIter);
				} else if (preferredType == BufferedImage.TYPE_4BYTE_ABGR) {
					finalIter = new ByteBGRAConverter(scalingIter);
				} else {
					throw new IllegalArgumentException(
							"unrecognized type: " + preferredType);
				}
				BufferedImage image = BufferedImageIterator.create(finalIter,
						null);
				return image;
			} catch (IOException e) {
				return null;
			}
		}

		Image image;
		if (src instanceof FileInputStreamSource) {
			File file = ((FileInputStreamSource) src).getFile();
			image = Toolkit.getDefaultToolkit()
					.createImage(file.getAbsolutePath());
		} else if (src instanceof URLInputStreamSource) {
			URL url = ((URLInputStreamSource) src).getURL();
			image = Toolkit.getDefaultToolkit().createImage(url);
		} else {
			throw new IllegalStateException(src.getClass().getName());
		}
		try {
			// TODO: take into account preferredType
			return scale(image, null, destSize);
		} finally {
			if (image != null)
				image.flush();
		}
	}

/**
	 * Scales the source image file to a new, smaller size.
	 *
	 * @param source
	 *            the source image file.
	 * @param preferredType
	 *            TYPE_INT_RGB, TYPE_INT_ARGB,
	 *            TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR.
	 * @param destSize
	 *            the size of the new image.
	 * @return a new scaled image of type
	 *         BufferedImage.TYPE_INT_ARGB or
	 *         BufferedImage.TYPE_INT_RGB.
	 */
	public static BufferedImage scale(File source, int preferredType,
			Dimension destSize) {
		// NOTE: this method mirrors scale(URL, ...), so when you modify one:
		// modify the other
		String pathLower = source.getAbsolutePath().toLowerCase();
		if (pathLower.endsWith(".bmp")) {
			try {
				PixelIterator iter = BmpDecoderIterator.get(source);
				PixelIterator scalingIter = destSize == null ? iter
						: ScalingIterator.get(iter, destSize.width,
								destSize.height);
				PixelIterator finalIter = scalingIter;
				if (preferredType == BufferedImage.TYPE_INT_ARGB
						|| preferredType == BufferedImage.TYPE_INT_ARGB_PRE) {
					finalIter = new IntARGBConverter(scalingIter);
				} else if (preferredType == BufferedImage.TYPE_INT_RGB) {
					finalIter = new IntRGBConverter(scalingIter);
				} else if (preferredType == BufferedImage.TYPE_3BYTE_BGR) {
					finalIter = new ByteBGRConverter(scalingIter);
				} else if (preferredType == BufferedImage.TYPE_4BYTE_ABGR) {
					finalIter = new ByteBGRAConverter(scalingIter);
				} else {
					throw new IllegalArgumentException(
							"unrecognized type: " + preferredType);
				}
				BufferedImage image = BufferedImageIterator.create(finalIter,
						null);
				return image;
			} catch (IOException e) {
				return null;
			}
		}
		Image image = Toolkit.getDefaultToolkit()
				.createImage(source.getAbsolutePath());
		try {
			return scale(image, null, destSize);
		} finally {
			if (image != null)
				image.flush();
		}
	}

Try With Resources try(InputStream in=src.createInputStream()) in method private scale(name String, src InputStreamSource, preferredType int, destSize Dimension) : BufferedImage from class com.pump.image.pixel.Scaling


/**
	 * Scales the source image file to a new size.
	 *
	 * @param source
	 *            the source image file.
	 * @param preferredType
	 *            TYPE_INT_RGB, TYPE_INT_ARGB,
	 *            TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR.
	 * @param destSize
	 *            the size of the new image.
	 * @return a new scaled image of type
	 *         BufferedImage.TYPE_INT_ARGB or
	 *         BufferedImage.TYPE_INT_RGB.
	 */
	public static BufferedImage scale(URL source, int preferredType,
			Dimension destSize) {
		// NOTE: this method mirrors scale(File, ...), so when you modify one:
		// modify the other
		String pathLower = source.toString().toLowerCase();
		if (pathLower.endsWith(".bmp")) {
			InputStream in = null;
			try {
				in = source.openStream();
				PixelIterator iter = BmpDecoderIterator.get(in);
				PixelIterator scalingIter = destSize == null ? iter
						: ScalingIterator.get(iter, destSize.width,
								destSize.height);
				PixelIterator finalIter = scalingIter;
				if (preferredType == BufferedImage.TYPE_INT_ARGB
						|| preferredType == BufferedImage.TYPE_INT_ARGB_PRE) {
					finalIter = new IntARGBConverter(scalingIter);
				} else if (preferredType == BufferedImage.TYPE_INT_RGB) {
					finalIter = new IntRGBConverter(scalingIter);
				} else if (preferredType == BufferedImage.TYPE_3BYTE_BGR) {
					finalIter = new ByteBGRConverter(scalingIter);
				} else if (preferredType == BufferedImage.TYPE_4BYTE_ABGR) {
					finalIter = new ByteBGRAConverter(scalingIter);
				} else {
					throw new IllegalArgumentException(
							"unrecognized type: " + preferredType);
				}
				BufferedImage image = BufferedImageIterator.create(finalIter,
						null);
				return image;
			} catch (IOException e) {
				return null;
			} finally {
				try {
					if (in != null)
						in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		Image image = Toolkit.getDefaultToolkit().createImage(source);
		try {
			return scale(image, null, destSize);
		} finally {
			if (image != null)
				image.flush();
		}
	}


	protected BufferedImage createUnframedThumbnail(Dimension maxSize) {
		if (isDirectory() == true || canRead() == false)
			return null;

		String suffix = getExtension();
		if (suffix == null || suffix.length() == 0)
			return null;

		suffix = suffix.toLowerCase();

		try {
			if (suffix.equals("jpeg") || suffix.equals("jpg")) {
				try (InputStream in = createInputStream()) {
					BufferedImage bi = JPEGMetaData.getThumbnail(in);
					if (bi != null)
						return bi;
				}
			}

			if (suffix.equals("jpg") || suffix.equals("jpeg")
					|| suffix.equals("png") || suffix.equals("gif")
					|| suffix.equals("bmp")) {

				URL url = getURL();
				if (url != null) {
					try {
						Dimension d = ImageSize.get(url);
						d = Dimension2D.scaleProportionally(d, maxSize);
						return Scaling.scale(url, BufferedImage.TYPE_INT_ARGB,
								d);
					} catch (Throwable t) {
						// do nothing. Pity this failed.
					}
					// TODO: we could do more here. For example: we can parse
					// our own BMPs.
				}

				InputStream in = createInputStream();
				try {
					return ImageIO.read(in);
				} finally {
					try {
						in.close();
					} catch (IOException e) {
					}
				}
			}
		} catch (Throwable t) {
			System.err.println(this);
			t.printStackTrace();
		}
		return null;
	}

	protected BufferedImage createUnframedThumbnail(Dimension maxSize) {
		if (isDirectory() == true || canRead() == false)
			return null;

		String suffix = getExtension();
		if (suffix == null || suffix.length() == 0)
			return null;

		suffix = suffix.toLowerCase();

		try {
			if (suffix.equals("jpeg") || suffix.equals("jpg")) {
				InputStream in = createInputStream();
				try {
					JPEGMetaData metaData = new JPEGMetaData(in, true);
					BufferedImage bi = metaData.getThumbnail();
					if (bi != null)
						return bi;
				} finally {
					try {
						in.close();
					} catch (IOException e) {
					}
				}
			}

			if (suffix.equals("jpg") || suffix.equals("jpeg")
					|| suffix.equals("png") || suffix.equals("gif")
					|| suffix.equals("bmp")) {

				URL url = getURL();
				if (url != null) {
					try {
						Dimension d = ImageSize.get(url);
						d = Dimension2D.scaleProportionally(d, maxSize);
						return Scaling.scale(url, BufferedImage.TYPE_INT_ARGB,
								d);
					} catch (Throwable t) {
						// do nothing. Pity this failed.
					}
					// TODO: we could do more here. For example: we can parse
					// our own BMPs.
				}

				InputStream in = createInputStream();
				try {
					return ImageIO.read(in);
				} finally {
					try {
						in.close();
					} catch (IOException e) {
					}
				}
			}
		} catch (Throwable t) {
			System.err.println(this);
			t.printStackTrace();
		}
		return null;
	}

Try With Resources try(InputStream in=createInputStream()) in method protected createUnframedThumbnail(maxSize Dimension) : BufferedImage from class com.pump.io.location.IOLocation