001package com.pusher.rest.data;
002
003import com.pusher.rest.util.Prerequisites;
004
005/**
006 * Represents a precence channel "user", that is a user from the domain of your application.
007 */
008public class PresenceUser {
009
010    private final Object userId;
011    private final Object userInfo;
012
013    /**
014     * Represents a presence channel user with no additional data associated other than the userId
015     *
016     * @param userId the unique ID to associate with the user
017     */
018    public PresenceUser(final String userId) {
019        this((Object)userId, null);
020    }
021
022    /**
023     * Represents a presence channel user with no additional data associated other than the userId
024     *
025     * @param userId the unique ID to associate with the user
026     */
027    public PresenceUser(final Number userId) {
028        this((Object)userId, null);
029    }
030
031    /**
032     * Represents a presence channel user and a map of data associated with the user
033     *
034     * @param userId the unique ID to associate with the user
035     * @param userInfo additional data to be associated with the user
036     */
037    public PresenceUser(final String userId, final Object userInfo) {
038        this((Object)userId, userInfo);
039    }
040
041    /**
042     * Represents a presence channel user and a map of data associated with the user
043     *
044     * @param userId the unique ID to associate with the user
045     * @param userInfo additional data to be associated with the user
046     */
047    public PresenceUser(final Number userId, final Object userInfo) {
048        this((Object)userId, userInfo);
049    }
050
051    /**
052     * There's not really a great way to accept either a string or numeric value in a typesafe way,
053     * so this will have to do.
054     *
055     * @param userId the unique ID to associate with the user
056     * @param userInfo additional data to be associated with the user
057     */
058    private PresenceUser(final Object userId, final Object userInfo) {
059        Prerequisites.nonNull("userId", userId);
060
061        this.userId = userId;
062        this.userInfo = userInfo;
063    }
064
065    public Object getUserId() {
066        return userId;
067    }
068
069    public Object getUserInfo() {
070        return userInfo;
071    }
072}