📄 groupentry.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -