package com.uas.search.b2b.model;

import java.io.Serializable;

/**
 * 排序
 * 
 * @author sunyj
 * @since 2016年11月23日 下午1:47:44
 */
public class Sort implements Serializable {

	/**
	 * 序列号
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 所排序的字段的类型
	 */
	public static enum Type {
		/** 字段为字符串 */
		STRING,

		/** 字段为Integer */
		INT,

		/** 字段为Float */
		FLOAT,

		/** 字段为Long */
		LONG,

		/** 字段为Double */
		DOUBLE;
	}

	/**
	 * 排序的字段名称（在表中的列名）
	 */
	private String field;

	/**
	 * 排序默认为降序，若为true，则为升序
	 */
	private boolean reverse = false;

	/**
	 * 排序的字段的类型，默认为String
	 */
	private Type type = Type.STRING;

	/**
	 * 若排序字段的值为空，设置一个默认值
	 */
	private Object missingValue;

	public Sort(String field, boolean reverse, Type type, Object missingValue) {
		super();
		this.field = field;
		this.reverse = reverse;
		this.type = type;
		this.missingValue = missingValue;
	}

	public Sort(String field, boolean reverse, Object missingValue) {
		super();
		this.field = field;
		this.reverse = reverse;
		this.missingValue = missingValue;
	}

	public Sort(String field, Type type, Object missingValue) {
		super();
		this.field = field;
		this.type = type;
		this.missingValue = missingValue;
	}

	public Sort(String field, Object missingValue) {
		super();
		this.field = field;
		this.missingValue = missingValue;
	}

	public Sort() {
		super();
	}

	public String getField() {
		return field;
	}

	public void setField(String field) {
		this.field = field;
	}

	public boolean isReverse() {
		return reverse;
	}

	public void setReverse(boolean reverse) {
		this.reverse = reverse;
	}

	public Type getType() {
		return type;
	}

	public void setType(Type type) {
		this.type = type;
	}

	public Object getMissingValue() {
		return missingValue;
	}

	public void setMissingValue(Object missingValue) {
		this.missingValue = missingValue;
	}

	@Override
	public String toString() {
		return "Sort [field=" + field + ", reverse=" + reverse + ", type=" + type + ", missingValue=" + missingValue
				+ "]";
	}

}