package com.tandbergtv.metadatamanager.model;

/**
 * Class representing a rule that will override the default required validation
 * for a field in a spec.
 * 
 * @author nicholas
 * 
 */
public class Rule {

	private long id;
	private String xpath;
	private Boolean isRequired;

	public Rule() {
		super();
	}

	public Rule(long id) {
		this.setId(id);
	}

	public long getId() {
		return id;
	}

	/**
	 * This method is only for Hibernate and should not be used by the applications
	 * @param id
	 */
	private void setId(long id) {
		this.id = id;
	}

	public String getXpath() {
		return xpath;
	}

	public void setXpath(String xpath) {
		this.xpath = xpath;
	}

	public Boolean getIsRequired() {
		return isRequired;
	}

	public void setIsRequired(Boolean isRequired) {
		this.isRequired = isRequired;
	}

	public String toString() {
		return toString("");
	}

	public String toString(String tab) {
		String result = new String();
		result += tab + "Rule:\n";
		result += tab + "\tID: " + id + "\n";
		result += tab + "\tXPath: " + xpath + "\n";
		result += tab + (isRequired ? "\tIs Require\n" : "\tIs Not Require\n");
		return result;
	}
}
