package com.persagy.adm.diagram.core.model.logic;

import com.google.gson.annotations.Expose;

/**
 * 设备数据过滤器
 * @author zhaoyk
 */
abstract public class DataFilter {

	public static final int TYPE_MATCH = 1;

	public static final int TYPE_AND = 2;

	public static final int TYPE_OR = 3;

	/**
	 * 过滤器类型
	 */
	@Expose
	protected int type;

	/**
	 * 否定
	 */
	@Expose
	protected boolean not;

	public int getType() {
		return type;
	}

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

	public boolean isNot() {
		return not;
	}

	public void setNot(boolean not) {
		this.not = not;
	}

	/**
	 * 过滤操作，返回true时通过
	 */
	public boolean filter(Object data) {
		boolean rtn = judge(data);
		return not ? !rtn : rtn;
	}

	/**
	 * 子类实现具体的判断逻辑
	 */
	abstract protected boolean judge(Object data);

}
