You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.0 KiB
40 lines
1.0 KiB
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
|
|
|