groupentry.java
来自「java图形化界面编程 功能和记事本通讯录相似 记录通讯人的姓名和联系方法等」· Java 代码 · 共 109 行
JAVA
109 行
package elegate.cn.edu.nju;
import java.io.Serializable;
import java.util.LinkedList;
/**
* a class describe a group entry
* @author Elegate
* @author cs department of NJU
* @version 1.0
*/
final public class GroupEntry implements Serializable
{
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* group name of the group entry
*/
private String groupName;
/**
* linked list to save group members' id
*/
private LinkedList<Long> groupMembers;
/**
* create a group entry with group name specified
* @param groupName the group name
*/
public GroupEntry(String groupName)
{
if(groupName==null||groupName.length()==0)
this.groupName="Group";
else
this.groupName=groupName;
this.groupMembers=new LinkedList<Long>();
}
/**
* get the group name of the group entry
* @return the group name of the group entry
* @see #setGroupName(String)
*/
public String getGroupName()
{
return this.groupName;
}
/**
* set the group name of the group entry
* @param groupName the new group name
* @see #getGroupName()
*/
public void setGroupName(String groupName)
{
this.groupName=groupName;
}
public LinkedList<Long> getGroupMembers()
{
return this.groupMembers;
}
/**
* add a group member to the group
* @param id the id of an address entry
*/
public void addGroupMember(long id)
{
if(!this.groupMembers.contains(id))
this.groupMembers.add(id);
}
/**
* remove an address entry from the group
* @param id the id of an address entry
*/
public void removeMember(long id)
{
this.groupMembers.remove(id);
}
/**
* overridden method <strong>equals</strong>
*/
public boolean equals(Object obj)
{
if(obj==this)
return true;
if(obj==null)
return false;
if(this.getClass()!=obj.getClass())
return false;
GroupEntry group=(GroupEntry)obj;
return group.groupName.equals(this.groupName);
}
/**
* overridden method <strong>toString</strong>
*/
public String toString()
{
/*return this.getClass().getName()+"[groupName="
+this.groupName+",groupMembers="+this.groupMembers+"]";
*/
return groupName;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?