/*******************************************************************************
* Copyright 2012 Keith Johnson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package com.ubergeek42.weechat;
import com.ubergeek42.weechat.relay.protocol.HdataEntry;
public class NickItem {
private int group;
private int visible;
private int level;
private String name;
private String color;
private String prefix;
private String prefixColor;
public NickItem(HdataEntry hde) {
this.group = hde.getItem("group").asChar();
this.visible = hde.getItem("visible").asChar();
this.level = hde.getItem("level").asInt();
this.name = hde.getItem("name").asString();
this.color = hde.getItem("color").asString();
this.prefix = hde.getItem("prefix").asString();
this.prefixColor = hde.getItem("prefix_color").asString();
}
public boolean isVisible() {
return (this.visible == 0x01);
}
public boolean isGroup() {
return (this.group == 0x01);
}
@Override
public String toString() {
return name;
}
// Eclipse generated hashcode and equals methods
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
NickItem other = (NickItem) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
}