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

net.anotheria.anosite.gen.asresourcedata.data.FileLinkDocument Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
/**
 ********************************************************************************
 *** FileLinkDocument.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.asresourcedata.data;

import net.anotheria.asg.data.AbstractASGDocument;
import net.anotheria.util.crypt.MD5Util;
import net.anotheria.util.sorter.IComparable;
import net.anotheria.util.BasicComparable;

public class FileLinkDocument extends AbstractASGDocument implements FileLink, IComparable{

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

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

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

	FileLinkDocument(FileLinkBuilder builder){
		super("");
		setName(builder.name);
		setTitle(builder.title);
		setFile(builder.file);
		setSize(builder.size);
	}

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

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

	public String getTitle(){
		return getString(PROP_TITLE);
	}

	public void setTitle(String value){
		setString(PROP_TITLE, value);
	}

	public String getFile(){
		return getString(PROP_FILE);
	}

	public void setFile(String value){
		setString(PROP_FILE, value);
	}

	public String getSize(){
		return getString(PROP_SIZE);
	}

	public void setSize(String value){
		setString(PROP_SIZE, value);
	}


	public String toString(){
		String ret = "FileLink ";
		ret += "["+getId()+"] ";
		ret += "name: "+getName();
		ret += ", ";
		ret += "title: "+getTitle();
		ret += ", ";
		ret += "file: "+getFile();
		ret += ", ";
		ret += "size: "+getSize();
		return ret;
	}


	public int compareTo(FileLink comparable){
		return compareTo(comparable, FileLinkSortType.SORT_BY_DEFAULT);
	}

	public int compareTo(IComparable anotherComparable, int method){
		FileLinkDocument anotherDoc = (FileLinkDocument) anotherComparable;
		switch(method){
			case FileLinkSortType.SORT_BY_ID:
				return BasicComparable.compareString(getId(), anotherDoc.getId());
			case FileLinkSortType.SORT_BY_NAME:
				return BasicComparable.compareString(getName(), anotherDoc.getName());
			case FileLinkSortType.SORT_BY_TITLE:
				return BasicComparable.compareString(getTitle(), anotherDoc.getTitle());
			case FileLinkSortType.SORT_BY_FILE:
				return BasicComparable.compareString(getFile(), anotherDoc.getFile());
			case FileLinkSortType.SORT_BY_SIZE:
				return BasicComparable.compareString(getSize(), anotherDoc.getSize());
			default:
				throw new RuntimeException("Sort method "+method+" is not supported.");
		}
	}

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

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

	public String getFootprint(){
		StringBuilder footprint = new StringBuilder();
		footprint.append(getName());
		footprint.append(getTitle());
		footprint.append(getFile());
		footprint.append(getSize());
		return MD5Util.getMD5Hash(footprint);
	}

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy