package com.inepex.ineom.shared.descriptor.fdesc;

import java.util.TreeSet;

import com.inepex.ineom.shared.IneT;
import com.inepex.ineom.shared.descriptor.DescriptorBase;
import com.inepex.ineom.shared.validation.KeyValueObjectValidationManager;

@SuppressWarnings("serial")
public abstract class FDesc extends DescriptorBase {

	private String key;

	// the field can be edited
	private boolean editable = true;

	protected TreeSet<String> validatorNames = new TreeSet<String>();

	protected IneT type = null;

	private String defaultDisplayName = null;

	private boolean nullable = true;

	public FDesc() {
	}

	public FDesc(String key, IneT type) {
		this.key = key;
		this.type = type;
	}

	public FDesc(String key, IneT type, String defaultDisplayName) {
		this.key = key;
		this.type = type;
		this.defaultDisplayName = defaultDisplayName;
	}

	public FDesc(String key, IneT type, String defaultDisplayName,
			String... properties) {
		this.key = key;
		this.type = type;
		this.defaultDisplayName = defaultDisplayName;
		addProps(properties);
	}

	public FDesc(String key, IneT type, String... properties) {
		this.key = key;
		this.type = type;
		addProps(properties);
	}

	public FDesc addValidators(String... names) {
		for (String name : names) {
			validatorNames.add(name);
		}

		return this;
	}

	public TreeSet<String> getValidatorNames() {
		return validatorNames;
	}

	public boolean hasValidator(String validatorName) {
		return validatorNames.contains(validatorName);
	}

	public String getKey() {
		return key;
	}

	public boolean isEditable() {
		return editable;
	}

	public FDesc setEditable(boolean editable) {
		this.editable = editable;
		return this;
	}

	public IneT getType() {
		return type;
	}

	public String getDefaultDisplayName() {
		return defaultDisplayName;
	}

	public void setDefaultDisplayName(String defaultDisplayName) {
		this.defaultDisplayName = defaultDisplayName;
	}

	public boolean isNullable() {
		return nullable;
	}

	public FDesc setNullable(boolean nullable) {
		this.nullable = nullable;
		return this;
	}

	public FDesc mandatory() {
		validatorNames.add(KeyValueObjectValidationManager.MANDATORY);
		return this;
	}

	public void setKey(String key) {
		this.key = key;
	}

}

@@ -580,24 +580,68 @@
 able = true;
+%0A%09%0A%09private boolean excludeFromDesc = false;
 %0A%0A%09public FD
@@ -2272,10 +2272,266 @@
 ey;%0A%09%7D%0A%0A
+%09public boolean isExcludeFromDesc() %7B%0A%09%09return excludeFromDesc;%0A%09%7D%0A%0A%09public FDesc setExcludeFromDesc(boolean excludeFromDesc) %7B%0A%09%09this.excludeFromDesc = excludeFromDesc;%0A%09%09return this;%0A%09%7D%0A%09%0A%09public FDesc excl() %7B%0A%09%09return setExcludeFromDesc(true);%0A%09%7D%0A%09%0A%09%0A%0A
 %7D%0A

add excludeFromDesc to FDesc