This repository has been archived on 2022-12-14. You can view files and clone it, but cannot push or open issues or pull requests.
geiserpbot/src/elements/ChatListItem.java
vylion 8ce038dbdd Finished minimal persistence support (hopefully with no bugs - heh).
Added recognition of a chat name change as an event.
Added beta features configuration.
2016-10-16 20:24:34 +02:00

41 lines
961 B
Java

package elements;
import elements.exceptions.ReadErrorListException;
/**
* Created by Guillermo Serrahima on 10/9/16.
*/
public class ChatListItem {
private String name;
private Integer value;
public ChatListItem(String name, int value) {
this.name = name;
this.value = value;
}
public ChatListItem(String line) throws ReadErrorListException {
loadItem(line);
}
public int compareTo(ChatListItem c) {
return name.compareTo(c.name);
}
@Override
public String toString() {
return name + ": " + value;
}
public String saveItem() {
return name + ";" + value;
}
private void loadItem(String line) throws ReadErrorListException {
String[] reading = line.split(";");
if(reading.length > 2) throw new ReadErrorListException("Unidentified item.");
this.name = reading[0];
this.value = Integer.parseInt(reading[1]);
}
}