Created
February 2, 2015 11:16
-
-
Save pabloDon/d4915d1ddcee422a77d2 to your computer and use it in GitHub Desktop.
Ejemplo Hazelcast - Usuario
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package es.pdonaire.mensajeria.pojo; | |
import java.io.Serializable; | |
import java.util.Date; | |
public class Usuario implements Serializable { | |
private static final long serialVersionUID = 1L; | |
private String nickname; | |
private long timestamp; | |
public Usuario(String nickname, long timestamp) { | |
super(); | |
this.nickname = nickname; | |
this.timestamp = timestamp; | |
} | |
public String getNickname() { | |
return nickname; | |
} | |
public void setNickname(String nickname) { | |
this.nickname = nickname; | |
} | |
public long getTimestamp() { | |
return timestamp; | |
} | |
public void setTimestamp(long timestamp) { | |
this.timestamp = timestamp; | |
} | |
public String toString(){ | |
StringBuilder str = new StringBuilder(); | |
long timestamp = new Date().getTime(); | |
String status = ""; | |
if (timestamp - this.timestamp < 50000) | |
status = "Online"; | |
else if (timestamp - this.timestamp < 100000) | |
status = "Ausente"; | |
else | |
status = "Offline"; | |
str.append("[") | |
.append(status) | |
.append("] ") | |
.append(nickname); | |
return str.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment