【Java开源代码栏目提醒】:网学会员在Java开源代码频道为大家收集整理了Category.java提供大家参考,希望对大家有所帮助!
package com.hbp.chapter7.model;
import java.util.HashSet;
import java.util.Set;
public class Category {
private Long id;
private String name;
private Category parentCategory;
private Set childCategories = new HashSet();
public Category() {
}
public Category(String name) {
this.name = name;
}
public Long getId() {
return id;
}
private void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Category getParentCategory() {
return parentCategory;
}
public void setParentCategory(Category parentCategory) {
this.parentCategory = parentCategory;
}
public Set getChildCategories() {
return childCategories;
}
public void setChildCategories(Set childCategories) {
this.childCategories = childCategories;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Category)) {
return false;
}
final Category cp = (Category) obj;
if (!cp.getName().equals(this.getName())) {
return false;
}
return true;
}
public int hashCode() {
return getName().hashCode();
}
}
上一篇:
CategorizedStatistics.java
下一篇:
网络能耗监测系统管理端的研究与实现