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

net.anotheria.anosite.gen.asuserdata.data.UserDefDocument Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
/**
 ********************************************************************************
 *** UserDefDocument.java                                                     ***
 *** generated by AnoSiteGenerator (ASG), Version: 3.2.2                      ***
 *** Copyright (C) 2005 - 2023 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.asuserdata.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 UserDefDocument extends AbstractASGDocument implements UserDef, IComparable{

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

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

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

	UserDefDocument(UserDefBuilder builder){
		super("");
		setLogin(builder.login);
		setStatus(builder.status);
		setPassword(builder.password);
	}

	public String getLogin(){
		return getString(PROP_LOGIN);
	}

	public void setLogin(String value){
		setString(PROP_LOGIN, value);
	}

	public List getStatus(){
		return copyToStringList(getList(PROP_STATUS));
	}

	public void setStatus(List value){
		setList(PROP_STATUS, copyFromStringList(value));
	}

	public String getPassword(){
		return getString(PROP_PASSWORD);
	}

	public void setPassword(String value){
		setString(PROP_PASSWORD, value);
	}


	public String toString(){
		String ret = "UserDef ";
		ret += "["+getId()+"] ";
		ret += "login: "+getLogin();
		ret += ", ";
		ret += "status: "+getStatus();
		ret += ", ";
		ret += "password: "+getPassword();
		return ret;
	}

	public int getStatusSize(){
		return getList(PROP_STATUS).size();
	}

	public void addStatusElement(String statusLink){
		getListPropertyAnyCase(PROP_STATUS).add(new StringProperty("" + statusLink, statusLink));
	} //method

	public void removeStatusElement(int index){
		getListProperty(PROP_STATUS).remove(index);
	} //method

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

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


	public int compareTo(UserDef comparable){
		return compareTo(comparable, UserDefSortType.SORT_BY_DEFAULT);
	}

	public int compareTo(IComparable anotherComparable, int method){
		UserDefDocument anotherDoc = (UserDefDocument) anotherComparable;
		switch(method){
			case UserDefSortType.SORT_BY_ID:
				return BasicComparable.compareString(getId(), anotherDoc.getId());
			case UserDefSortType.SORT_BY_LOGIN:
				return BasicComparable.compareString(getLogin(), anotherDoc.getLogin());
			case UserDefSortType.SORT_BY_PASSWORD:
				return BasicComparable.compareString(getPassword(), anotherDoc.getPassword());
			default:
				throw new RuntimeException("Sort method "+method+" is not supported.");
		}
	}

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

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

	public String getFootprint(){
		StringBuilder footprint = new StringBuilder();
		footprint.append(getLogin());
		footprint.append(getStatus());
		footprint.append(getPassword());
		return MD5Util.getMD5Hash(footprint);
	}

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy