package com.uas.report.crystal2jasper;

/**
 * @author sunyj
 * @since 2017年5月23日 下午2:15:26
 */
public class Link {

	private String fromColumnName;
	private String toColumnName;
	private LinkType joinType;

	public Link(String fromColumnName, String toColumnName, LinkType joinType) {
		super();
		this.fromColumnName = fromColumnName;
		this.toColumnName = toColumnName;
		this.joinType = joinType;
	}

	public String getFromColumnName() {
		return fromColumnName;
	}

	public void setFromColumnName(String fromColumnName) {
		this.fromColumnName = fromColumnName;
	}

	public String getToColumnName() {
		return toColumnName;
	}

	public void setToColumnName(String toColumnName) {
		this.toColumnName = toColumnName;
	}

	public LinkType getJoinType() {
		return joinType;
	}

	public void setJoinType(LinkType joinType) {
		this.joinType = joinType;
	}

	@Override
	public String toString() {
		return "Link [fromColumnName=" + fromColumnName + ", toColumnName=" + toColumnName + ", joinType=" + joinType
				+ "]";
	}

	public enum LinkType {
		/**
		 * 等于
		 */
		EQ("="),

		/**
		 * 不等于
		 */
		NE("!="),

		/**
		 * 大于
		 */
		GT(">"),

		/**
		 * 小于
		 */
		LT("<"),

		/**
		 * 大于等于
		 */
		GTE(">="),

		/**
		 * 小于等于
		 */
		LTE("<=");

		private String expression;

		private LinkType(String expression) {
			this.expression = expression;
		}

		public String getExpression() {
			return expression;
		}

		public static LinkType getLinkType(String linkType) {
			return valueOf(linkType.toUpperCase());
		}
	}

}
