Package com.pusher.client.channel
Class User
- java.lang.Object
-
- com.pusher.client.channel.User
-
public class User extends java.lang.Object
Represents a user that is subscribed to aPresenceChannel.
-
-
Constructor Summary
Constructors Constructor Description User(java.lang.String id, java.lang.String jsonData)Create a new user.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object other)java.lang.StringgetId()A unique identifier for the user within a Pusher application.java.lang.StringgetInfo()Custom additional information about a user as a String encoding a JSON hash<V> VgetInfo(java.lang.Class<V> clazz)Custom additional information about a user decoded as a new instance of the provided POJO bean typeinthashCode()java.lang.StringtoString()
-
-
-
Constructor Detail
-
User
public User(java.lang.String id, java.lang.String jsonData)
Create a new user. Users should not be created within an application. Users are created within the library and represent subscriptions to presence channels.- Parameters:
id- The user idjsonData- The user JSON data
-
-
Method Detail
-
getId
public java.lang.String getId()
A unique identifier for the user within a Pusher application.- Returns:
- The unique id.
-
getInfo
public java.lang.String getInfo()
Custom additional information about a user as a String encoding a JSON hash- Returns:
- The user info as a JSON string
-
getInfo
public <V> V getInfo(java.lang.Class<V> clazz)
Custom additional information about a user decoded as a new instance of the provided POJO bean type
e.g. if
getInfo()returns{"name":"Mr User","number":9}then you might implement as follows:public class UserInfo { private String name; private Integer number; public String getName() { return name; } public void setName(String name) { this.name = name; } public Integer getNumber() { return number; } public void setNumber(Integer number) { this.number = number; } } UserInfo info = user.getInfo(UserInfo.class); info.getName() // returns "Mr User" info.getNumber() // returns 9- Type Parameters:
V- The class of the info- Parameters:
clazz- the class into which the user info JSON representation should be parsed.- Returns:
- V An instance of clazz, populated with the user info
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
-