All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.intelie.live.plugins.messenger.data.RoomData Maven / Gradle / Ivy

The newest version!
package net.intelie.live.plugins.messenger.data;

import java.util.Objects;
import java.util.Set;

public class RoomData {
    private final String id;
    private final String name;
    private final String type;
    private final Long createdAt;
    private final UserData author;
    private final Set users;

    public RoomData(String id){
        this(id, null, null, null, null, null);
    }

    public RoomData(String id, String name, String type, UserData author, Long createdAt, Set users) {
        this.id = id;
        this.name = name;
        this.type = type;
        this.author = author;
        this.users = users;
        this.createdAt = createdAt;
    }

    public Long createdAt() {
        return createdAt;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public UserData getAuthor() {
        return author;
    }

    public boolean isUser(Integer userId) {
        return users != null && users.stream().anyMatch(ud -> ud.getId() == userId);
    }

    public boolean isAdmin(Integer userId) {
        return users != null && users.stream().anyMatch(userData ->  userData.getId() == userId && userData.isAdmin());
    }

    public Set getUsers() {
        return users;
    }

    public String getType() {
        return type;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        RoomData roomData = (RoomData) o;
        return Objects.equals(id, roomData.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy