com.speedment.jpastreamer.builder.standard.internal.MockRendererFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of builder-standard Show documentation
Show all versions of builder-standard Show documentation
Standard provider for creating stream builders
/*
* JPAstreamer - Express JPA queries with Java Streams
* Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved.
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE
*/
package com.speedment.jpastreamer.builder.standard.internal;
import com.speedment.jpastreamer.pipeline.Pipeline;
import com.speedment.jpastreamer.renderer.RenderResult;
import com.speedment.jpastreamer.renderer.Renderer;
import com.speedment.jpastreamer.renderer.RendererFactory;
import com.speedment.jpastreamer.streamconfiguration.StreamConfiguration;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
import java.util.stream.BaseStream;
public final class MockRendererFactory implements RendererFactory {
private final BiConsumer, RenderResult, ?, ?>> listener;
public MockRendererFactory(BiConsumer, RenderResult, ?, ?>> listener) {
this.listener = listener;
}
@Override
public Renderer createRenderer(EntityManagerFactory entityManagerFactory) {
return new MockRenderer();
}
@Override
public Renderer createRenderer(Supplier entityManagerSupplier) {
return new MockRenderer();
}
@Override
public Renderer createRenderer(EntityManager entityManager) {
return new MockRenderer();
}
private final class MockRenderer implements Renderer {
@Override
public > RenderResult render(Pipeline pipeline, StreamConfiguration streamConfiguration) {
final RenderResult renderResult = null;
MockRendererFactory.this.listener.accept(pipeline, renderResult);
return null;
}
@Override
public void close() {
// Do nothing
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy