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

db.sql.api.impl.cmd.basic.OrderByDirection Maven / Gradle / Ivy

There is a newer version: 1.7.6-RC2
Show newest version
package db.sql.api.impl.cmd.basic;

import db.sql.api.Cmd;
import db.sql.api.SqlBuilderContext;
import db.sql.api.cmd.basic.IOrderByDirection;

public enum OrderByDirection implements IOrderByDirection {

    NONE("", ""),

    ASC(" ASC", ""),
    ASC_NULLS_FIRST(" ASC", " NULLS FIRST"),
    ASC_NULLS_LAST(" ASC", " NULLS LAST"),
    DESC(" DESC", ""),
    DESC_NULLS_FIRST(" DESC", " NULLS FIRST"),
    DESC_NULLS_LAST(" DESC", " NULLS LAST");
    private final String directionSQL;

    private final String nullsDirectionSQL;

    OrderByDirection(String directionSQL, String nullsDirectionSQL) {
        this.directionSQL = directionSQL;
        this.nullsDirectionSQL = nullsDirectionSQL;
    }


    public StringBuilder sql(Cmd module, Cmd parent, SqlBuilderContext context, StringBuilder sqlBuilder) {
        sqlBuilder.append(this.directionSQL);
        if (!IOrderByDirection.isSupportNullsOrder(context.getDbType())) {
            return sqlBuilder;
        } else {
            sqlBuilder.append(this.nullsDirectionSQL);
        }
        return sqlBuilder;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy