package de.memtext.baseobjects; public class ComparableObject extends NamedObject implements Comparable { private int sortNr; private static final long serialVersionUID = 1; public ComparableObject(String name, int sortNr) { super(name); this.sortNr = sortNr; } public int compareTo(Object o) { int result = 0; if (getSortNr() < ((ComparableObject) o).getSortNr()) result = -1; if (getSortNr() > ((ComparableObject) o).getSortNr()) result = 1; return result; } public int getSortNr() { return sortNr; } public boolean equals(Object o) { boolean result = false; ComparableObject comp = (ComparableObject) o; if (this.getName().equals(comp.getName()) && this.getSortNr() == comp.getSortNr()) result = true; return result; } public void setSortNr(int sortNr) { this.sortNr = sortNr; } } //Created on 22.10.2004 at 16:20:48