001/*
002 *  Copyright (c) 2022-2024, Mybatis-Flex (fuhai999@gmail.com).
003 *  <p>
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *  <p>
008 *  http://www.apache.org/licenses/LICENSE-2.0
009 *  <p>
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package com.mybatisflex.core.query;
017
018
019import com.mybatisflex.core.dialect.IDialect;
020
021import java.util.Arrays;
022import java.util.List;
023
024/**
025 * 原生列。
026 *
027 * @author michael
028 * @author 王帅
029 */
030public class RawQueryColumn extends QueryColumn implements HasParamsColumn {
031
032    protected String content;
033    protected Object[] params;
034
035    public RawQueryColumn(Object content, Object... params) {
036        this.content = String.valueOf(content);
037        this.params = params;
038    }
039
040    @Override
041    protected String toConditionSql(List<QueryTable> queryTables, IDialect dialect) {
042        return content;
043    }
044
045    @Override
046    protected String toSelectSql(List<QueryTable> queryTables, IDialect dialect) {
047        return content + WrapperUtil.buildColumnAlias(alias, dialect);
048    }
049
050    @Override
051    public String toString() {
052        return "RawQueryColumn{" +
053            "content='" + content + '\'' +
054            ", params='" + Arrays.toString(params) + '\'' +
055            '}';
056    }
057
058    public String getContent() {
059        return content;
060    }
061
062    public Object[] getParams() {
063        return params;
064    }
065
066    @Override
067    public RawQueryColumn clone() {
068        return (RawQueryColumn) super.clone();
069    }
070
071    @Override
072    public Object[] getParamValues() {
073        return params;
074    }
075
076}