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

io.github.biezhi.anima.core.JoinParam Maven / Gradle / Ivy

There is a newer version: 0.2.6
Show newest version
package io.github.biezhi.anima.core;

import io.github.biezhi.anima.Model;
import io.github.biezhi.anima.core.functions.TypeFunction;
import io.github.biezhi.anima.enums.OrderBy;
import io.github.biezhi.anima.utils.AnimaUtils;
import lombok.Data;

/**
 * @author biezhi
 * @date 2018/4/16
 */
@Data
public class JoinParam {

    private Class joinModel;
    private String                 onLeft;
    private String                 onRight;
    private String                 fieldName;
    private String                 orderBy;

    public JoinParam(Class joinModel) {
        this.joinModel = joinModel;
    }

    public  JoinParam as(TypeFunction function) {
        String fieldName = AnimaUtils.getLambdaColumnName(function);
        this.setFieldName(fieldName);
        return this;
    }

    public  JoinParam on(TypeFunction left, TypeFunction right) {
        String onLeft  = AnimaUtils.getLambdaColumnName(left);
        String onRight = AnimaUtils.getLambdaColumnName(right);
        this.setOnLeft(onLeft);
        this.setOnRight(onRight);
        return this;
    }

    public  JoinParam order(TypeFunction rightField, OrderBy orderBy) {
        String columnName = AnimaUtils.getLambdaColumnName(rightField);
        this.orderBy = columnName + " " + orderBy.name();
        return this;
    }

    public JoinParam order(String orderBy) {
        this.orderBy = orderBy;
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy