若要在TreeMap中存放Object,此object需要这样写:
package com.got.box.domain;
import java.util.Set;
/**
* Authority generated by MyEclipse - Hibernate Tools
*/
@SuppressWarnings("serial")
public class Authority implements java.io.Serializable, Comparable {
// Fields
private Integer id;
private String name;
private String description;
private String code;
private Set member = new java.util.HashSet();
// Constructors
/** default constructor */
public Authority() {
}
/** constructor with id */
public Authority(Integer id) {
this.id = id;
}
// Property accessors
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public Set getMember() {
return member;
}
public void setMember(Set member) {
this.member = member;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public int compareTo(Object arg0) {
Authority autho = (Authority) arg0;
if (autho.getId().intValue() == this.getId().intValue()) {
return 0;
} else if (autho.getId().intValue() < this.getId().intValue()) {
return 1;
} else {
return -1;
}
}
}