package com.alibaba.cobar.client.sqlparser.bean;

import java.util.ArrayList;
import java.util.List;

public class Condition {
	private final Column column;

	private final BinaryOperator operator;

	private final List<Comparable<?>> values = new ArrayList<Comparable<?>>();

	public Condition(Column column, BinaryOperator operator) {
		this.column = column;
		this.operator = operator;
	}

	public Column getColumn() {
		return this.column;
	}

	public BinaryOperator getOperator() {
		return this.operator;
	}

	public List<Comparable<?>> getValues() {
		return this.values;
	}

	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(column.getTableName()).append(".").append(column.getColumnName()).append(operator.expression)
				.append(values.toString());
		return sb.toString();
	}

	/**
	 * 列对象.
	 * 
	 */
	public static class Column {

		private final String columnName;

		private final String tableName;

		public Column(String columnName, String tableName) {
			this.columnName = columnName;
			this.tableName = tableName;
		}

		public Column() {
			this.columnName = null;
			this.tableName = null;
		}

		public String getColumnName() {
			return this.columnName;
		}

		public String getTableName() {
			return this.tableName;
		}
	}

	/**
	 * 操作符枚举.
	 * 
	 */
	public enum BinaryOperator {

		EQUAL("="), BETWEEN("BETWEEN"), IN("IN");

		private final String expression;

		BinaryOperator(String expression) {
			this.expression = expression;
		}

		@Override
		public String toString() {
			return expression;
		}
	}
}

@@ -1268,16 +1268,388 @@
 me;%0A%09%09%7D%0A
+%09%09%0A%09    @Override%0A%09    public int hashCode()%7B%0A%09    %09return (tableName+columnName).hashCode();%0A%09    %7D%0A%09    %0A%09    @Override%0A%09    public boolean equals(Object other)%7B%0A%09    %09if(other instanceof Column)%7B%0A%09    %09%09Column c = (Column)other;%0A%09    %09%09if(columnName.equals(c.columnName)&&tableName.equals(c.tableName))%7B%0A%09    %09%09%09return true;%0A%09    %09%09%7D%0A%09    %09%7D%0A%09    %09return false;%0A%09    %7D%0A
 %09%7D%0A%0A%09/**

add condition equal