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

net.anotheria.anosite.gen.asblogdata.data.CommentDocument Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
/**
 ********************************************************************************
 *** CommentDocument.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.asblogdata.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 CommentDocument extends AbstractASGDocument implements Comment, IComparable{

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

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

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

	CommentDocument(CommentBuilder builder){
		super("");
		setName(builder.name);
		setCreated(builder.created);
		setCommentator(builder.commentator);
		setContent(builder.content);
	}

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

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

	public long getCreated(){
		return getLong(PROP_CREATED);
	}

	public void setCreated(long value){
		setLong(PROP_CREATED, value);
	}

	public String getCommentator(){
		return getString(PROP_COMMENTATOR);
	}

	public void setCommentator(String value){
		setString(PROP_COMMENTATOR, value);
	}

	public String getContent(){
		return getString(PROP_CONTENT);
	}

	public void setContent(String value){
		setString(PROP_CONTENT, value);
	}


	public String toString(){
		String ret = "Comment ";
		ret += "["+getId()+"] ";
		ret += "name: "+getName();
		ret += ", ";
		ret += "created: "+getCreated();
		ret += ", ";
		ret += "commentator: "+getCommentator();
		ret += ", ";
		ret += "content: "+getContent();
		return ret;
	}


	public int compareTo(Comment comparable){
		return compareTo(comparable, CommentSortType.SORT_BY_DEFAULT);
	}

	public int compareTo(IComparable anotherComparable, int method){
		CommentDocument anotherDoc = (CommentDocument) anotherComparable;
		switch(method){
			case CommentSortType.SORT_BY_ID:
				return BasicComparable.compareString(getId(), anotherDoc.getId());
			case CommentSortType.SORT_BY_NAME:
				return BasicComparable.compareString(getName(), anotherDoc.getName());
			case CommentSortType.SORT_BY_CREATED:
				return BasicComparable.compareLong(getCreated(), anotherDoc.getCreated());
			case CommentSortType.SORT_BY_COMMENTATOR:
				return BasicComparable.compareString(getCommentator(), anotherDoc.getCommentator());
			case CommentSortType.SORT_BY_CONTENT:
				return BasicComparable.compareString(getContent(), anotherDoc.getContent());
			default:
				throw new RuntimeException("Sort method "+method+" is not supported.");
		}
	}

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

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

	public String getFootprint(){
		StringBuilder footprint = new StringBuilder();
		footprint.append(getName());
		footprint.append(getCreated());
		footprint.append(getCommentator());
		footprint.append(getContent());
		return MD5Util.getMD5Hash(footprint);
	}

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy