
com.speedment.jpastreamer.projection.internal.InternalProjection Maven / Gradle / Ivy
/*
* 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.projection.internal;
import static java.util.Objects.requireNonNull;
import com.speedment.jpastreamer.field.Field;
import com.speedment.jpastreamer.projection.Projection;
import javax.persistence.Tuple;
import java.util.Collections;
import java.util.Set;
public final class InternalProjection implements Projection {
private final Class entityClass;
private final Set> fields;
private final TupleContext tupleContext;
public InternalProjection(final Class entityClass, final Set> fields) {
this.entityClass = requireNonNull(entityClass);
this.fields = Collections.unmodifiableSet(fields);
this.tupleContext = new TupleContext<>(entityClass, fields);
}
@Override
public Class entityClass() {
return entityClass;
}
@Override
public Set> fields() {
return fields;
}
@Override
public Tuple apply(ENTITY entity) {
return tupleContext.create(entity);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy