All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.speedment.jpastreamer.field.internal.LongFieldImpl Maven / Gradle / Ivy

/*
 * JPAstreamer - Express JPA queries with Java Streams
 * Copyright (c) 2020-2020, 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.field.internal;

import com.speedment.jpastreamer.field.internal.predicate.longs.*;
import com.speedment.jpastreamer.field.method.LongGetter;
import com.speedment.jpastreamer.field.LongField;
import com.speedment.jpastreamer.field.comparator.LongFieldComparator;
import com.speedment.jpastreamer.field.comparator.NullOrder;
import com.speedment.jpastreamer.field.internal.comparator.LongFieldComparatorImpl;
import com.speedment.jpastreamer.field.internal.method.GetLongImpl;
import com.speedment.jpastreamer.field.method.GetLong;
import com.speedment.jpastreamer.field.predicate.FieldPredicate;
import com.speedment.jpastreamer.field.predicate.Inclusion;
import com.speedment.jpastreamer.field.predicate.SpeedmentPredicate;

import java.util.Collection;

import static com.speedment.jpastreamer.field.internal.util.CollectionUtil.collectionToSet;
import static java.util.Objects.requireNonNull;

/**
 * Default implementation of the {@link LongField}-interface.
 * 
 * Generated by com.speedment.sources.pattern.FieldImplPattern
 * 
 * @param  entity type
 *
 * @author Emil Forslund
 * @since  3.0.0
 */
public final class LongFieldImpl implements LongField {
    
    private final Class table;
    private final String columnName;
    private final GetLong getter;
    private final boolean unique;

    public LongFieldImpl(
            Class table,
            String columnName,
            LongGetter getter,
            boolean unique) {
        this.table = requireNonNull(table);
        this.columnName = requireNonNull(columnName);
        this.getter     = new GetLongImpl<>(this, getter);
        this.unique     = unique;
    }

    @Override
    public Class table() {
        return table;
    }

    @Override
    public GetLong getter() {
        return getter;
    }
    
    @Override
    public boolean isUnique() {
        return unique;
    }
    
    @Override
    public LongFieldComparator comparator() {
        return new LongFieldComparatorImpl<>(this);
    }
    
    @Override
    public LongFieldComparator reversed() {
        return comparator().reversed();
    }
    
    @Override
    public LongFieldComparator comparatorNullFieldsFirst() {
        return comparator();
    }
    
    @Override
    public NullOrder getNullOrder() {
        return NullOrder.LAST;
    }
    
    @Override
    public boolean isReversed() {
        return false;
    }
    
    @Override
    public FieldPredicate equal(Long value) {
        return new LongEqualPredicate<>(this, value);
    }
    
    @Override
    public FieldPredicate greaterThan(Long value) {
        return new LongGreaterThanPredicate<>(this, value);
    }
    
    @Override
    public FieldPredicate greaterOrEqual(Long value) {
        return new LongGreaterOrEqualPredicate<>(this, value);
    }
    
    @Override
    public FieldPredicate between(
            Long start,
            Long end,
            Inclusion inclusion) {
        return new LongBetweenPredicate<>(this, start, end, inclusion);
    }
    
    @Override
    public FieldPredicate in(Collection values) {
        return new LongInPredicate<>(this, collectionToSet(values));
    }
    
    @Override
    public SpeedmentPredicate notEqual(Long value) {
        return new LongNotEqualPredicate<>(this, value);
    }
    
    @Override
    public SpeedmentPredicate lessOrEqual(Long value) {
        return new LongLessOrEqualPredicate<>(this, value);
    }
    
    @Override
    public SpeedmentPredicate lessThan(Long value) {
        return new LongLessThanPredicate<>(this, value);
    }
    
    @Override
    public SpeedmentPredicate notBetween(
            Long start,
            Long end,
            Inclusion inclusion) {
        return new LongNotBetweenPredicate<>(this, start, end, inclusion);
    }
    
    @Override
    public SpeedmentPredicate notIn(Collection values) {
        return new LongNotInPredicate<>(this, collectionToSet(values));
    }

    @Override
    public String columnName() {
        return columnName;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy