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

tech.ydb.yoj.databind.expression.NotExpr Maven / Gradle / Ivy

Go to download

Core data-binding logic used by YOJ (YDB ORM for Java) to convert between Java objects and database rows (or anything representable by a Java Map, really).

The newest version!
package tech.ydb.yoj.databind.expression;

import lombok.AllArgsConstructor;
import lombok.NonNull;
import lombok.Value;
import tech.ydb.yoj.databind.schema.Schema;

import java.util.List;
import java.util.function.UnaryOperator;

import static lombok.AccessLevel.PACKAGE;
import static tech.ydb.yoj.databind.expression.FilterExpression.Type.NOT;

@Value
@AllArgsConstructor(access = PACKAGE)
public class NotExpr implements FilterExpression {
    @NonNull
    Schema schema;

    @NonNull
    FilterExpression delegate;

    @Override
    public Type getType() {
        return NOT;
    }

    @Override
    public  V visit(@NonNull Visitor visitor) {
        return visitor.visitNotExpr(this);
    }

    @Override
    public FilterExpression negate() {
        return delegate;
    }

    @Override
    public  NotExpr forSchema(@NonNull Schema dstSchema, @NonNull UnaryOperator pathTransformer) {
        return new NotExpr<>(dstSchema, this.delegate.forSchema(dstSchema, pathTransformer));
    }

    @Override
    public List> getChildren() {
        return List.of(delegate);
    }

    @Override
    public String toString() {
        return "NOT (" + delegate + ")";
    }
}