All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.anotheria.anosite.gen.anoaccessconfiguration.data.ConstraintDocument Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
/**
 ********************************************************************************
 *** ConstraintDocument.java                                                  ***
 *** generated by AnoSiteGenerator (ASG), Version: 2.6.3                      ***
 *** Copyright (C) 2005 - 2010 Anotheria.net, www.anotheria.net               ***
 *** All Rights Reserved.                                                     ***
 ********************************************************************************
 *** Don't edit this code, if you aren't sure                                 ***
 *** that you do exactly know what you are doing!                             ***
 *** It's better to invest time in the generator, as into the generated code. ***
 ********************************************************************************
 */

package net.anotheria.anosite.gen.anoaccessconfiguration.data;

import net.anotheria.asg.data.AbstractASGDocument;
import java.util.List;
import net.anotheria.anodoc.data.StringProperty;
import net.anotheria.util.crypt.MD5Util;
import net.anotheria.util.sorter.IComparable;
import net.anotheria.util.BasicComparable;


public class ConstraintDocument extends AbstractASGDocument implements Constraint, IComparable{

	public ConstraintDocument() {
		super("");
	}

	public ConstraintDocument(String id){
		super(id);
	}

	public ConstraintDocument(ConstraintDocument toClone){
		super(toClone);
	}

	ConstraintDocument(ConstraintBuilder builder){
		super("");
		setName(builder.name);
		setClassName(builder.className);
		setContextInitializers(builder.contextInitializers);
		setParameter1(builder.parameter1);
		setParameter2(builder.parameter2);
		setParameter3(builder.parameter3);
		setParameter4(builder.parameter4);
		setParameter5(builder.parameter5);
		setDescription(builder.description);
	}

	public String getName(){
		return getString(PROP_NAME);
	}

	public void setName(String value){
		setString(PROP_NAME, value);
	}

	public String getClassName(){
		return getString(PROP_CLASS_NAME);
	}

	public void setClassName(String value){
		setString(PROP_CLASS_NAME, value);
	}

	public List getContextInitializers(){
		return copyToStringList(getList(PROP_CONTEXT_INITIALIZERS));
	}

	public void setContextInitializers(List value){
		setList(PROP_CONTEXT_INITIALIZERS, copyFromStringList(value));
	}

	public String getParameter1(){
		return getString(PROP_PARAMETER1);
	}

	public void setParameter1(String value){
		setString(PROP_PARAMETER1, value);
	}

	public String getParameter2(){
		return getString(PROP_PARAMETER2);
	}

	public void setParameter2(String value){
		setString(PROP_PARAMETER2, value);
	}

	public String getParameter3(){
		return getString(PROP_PARAMETER3);
	}

	public void setParameter3(String value){
		setString(PROP_PARAMETER3, value);
	}

	public String getParameter4(){
		return getString(PROP_PARAMETER4);
	}

	public void setParameter4(String value){
		setString(PROP_PARAMETER4, value);
	}

	public String getParameter5(){
		return getString(PROP_PARAMETER5);
	}

	public void setParameter5(String value){
		setString(PROP_PARAMETER5, value);
	}

	public String getDescription(){
		return getString(PROP_DESCRIPTION);
	}

	public void setDescription(String value){
		setString(PROP_DESCRIPTION, value);
	}


	public String toString(){
		String ret = "Constraint ";
		ret += "["+getId()+"] ";
		ret += "name: "+getName();
		ret += ", ";
		ret += "className: "+getClassName();
		ret += ", ";
		ret += "contextInitializers: "+getContextInitializers();
		ret += ", ";
		ret += "parameter1: "+getParameter1();
		ret += ", ";
		ret += "parameter2: "+getParameter2();
		ret += ", ";
		ret += "parameter3: "+getParameter3();
		ret += ", ";
		ret += "parameter4: "+getParameter4();
		ret += ", ";
		ret += "parameter5: "+getParameter5();
		ret += ", ";
		ret += "description: "+getDescription();
		return ret;
	}

	public int getContextInitializersSize(){
		return getList(PROP_CONTEXT_INITIALIZERS).size();
	}

	public void addContextInitializersElement(String contextInitializer){
		getListPropertyAnyCase(PROP_CONTEXT_INITIALIZERS).add(new StringProperty("" + contextInitializer, contextInitializer));
	} //method

	public void removeContextInitializersElement(int index){
		getListProperty(PROP_CONTEXT_INITIALIZERS).remove(index);
	} //method

	public void swapContextInitializersElement(int index1, int index2){
		String tmp1, tmp2;
		tmp1 = ((StringProperty)getList(PROP_CONTEXT_INITIALIZERS).get(index1)).getString();
		tmp2 = ((StringProperty)getList(PROP_CONTEXT_INITIALIZERS).get(index2)).getString();
		((StringProperty)getList(PROP_CONTEXT_INITIALIZERS).get(index1)).setString(tmp2);
		((StringProperty)getList(PROP_CONTEXT_INITIALIZERS).get(index2)).setString(tmp1);
	} //method

	public String getContextInitializersElement(int index){
		StringProperty p = (StringProperty)getList(PROP_CONTEXT_INITIALIZERS).get(index);
		return p.getString();
	} //method


	public int compareTo(Constraint comparable){
		return compareTo(comparable, ConstraintSortType.SORT_BY_DEFAULT);
	}

	public int compareTo(IComparable anotherComparable, int method){
		ConstraintDocument anotherDoc = (ConstraintDocument) anotherComparable;
		switch(method){
			case ConstraintSortType.SORT_BY_ID:
				return BasicComparable.compareString(getId(), anotherDoc.getId());
			case ConstraintSortType.SORT_BY_NAME:
				return BasicComparable.compareString(getName(), anotherDoc.getName());
			case ConstraintSortType.SORT_BY_CLASSNAME:
				return BasicComparable.compareString(getClassName(), anotherDoc.getClassName());
			case ConstraintSortType.SORT_BY_PARAMETER1:
				return BasicComparable.compareString(getParameter1(), anotherDoc.getParameter1());
			case ConstraintSortType.SORT_BY_PARAMETER2:
				return BasicComparable.compareString(getParameter2(), anotherDoc.getParameter2());
			case ConstraintSortType.SORT_BY_PARAMETER3:
				return BasicComparable.compareString(getParameter3(), anotherDoc.getParameter3());
			case ConstraintSortType.SORT_BY_PARAMETER4:
				return BasicComparable.compareString(getParameter4(), anotherDoc.getParameter4());
			case ConstraintSortType.SORT_BY_PARAMETER5:
				return BasicComparable.compareString(getParameter5(), anotherDoc.getParameter5());
			case ConstraintSortType.SORT_BY_DESCRIPTION:
				return BasicComparable.compareString(getDescription(), anotherDoc.getDescription());
			default:
				throw new RuntimeException("Sort method "+method+" is not supported.");
		}
	}

	public String getDefinedName(){
		return "Constraint";
	}

	public String getDefinedParentName(){
		return "AnoAccessConfiguration";
	}

	public String getFootprint(){
		StringBuilder footprint = new StringBuilder();
		footprint.append(getName());
		footprint.append(getClassName());
		footprint.append(getContextInitializers());
		footprint.append(getParameter1());
		footprint.append(getParameter2());
		footprint.append(getParameter3());
		footprint.append(getParameter4());
		footprint.append(getParameter5());
		footprint.append(getDescription());
		return MD5Util.getMD5Hash(footprint);
	}

	public boolean equals(Object o){
		return o == this || ((o instanceof ConstraintDocument) && ((ConstraintDocument)o).getId().equals(getId()));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy