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

net.e6tech.elements.web.federation.Event Maven / Gradle / Ivy

There is a newer version: 2.7.12
Show newest version
package net.e6tech.elements.web.federation;

import net.e6tech.elements.common.federation.Member;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;

public class Event {

    public enum Type {
        ANNOUNCE,
        BROADCAST,
        REMOVE
    }

    private String domainName;
    private UUID uuid = UUID.randomUUID();
    private Set visited = new HashSet<>();
    private List members;
    private Type type;
    private CollectiveImpl.Type collectiveType;
    private int cycle = 4;

    private byte[] payload;

    public Event() {
    }

    public Event(String domainName, Type type, CollectiveImpl.Type collectiveType, List members, int cycle) {
        this.domainName = domainName;
        this.type = type;
        this.collectiveType = collectiveType;
        this.members = members;
        members.forEach(m -> visited.add(m.getMemberId()));
        this.cycle = cycle;
    }

    public String getDomainName() {
        return domainName;
    }

    public void setDomainName(String domainName) {
        this.domainName = domainName;
    }

    public UUID getUuid() {
        return uuid;
    }

    public void setUuid(UUID uuid) {
        this.uuid = uuid;
    }

    public synchronized Set getVisited() {
        return new HashSet<>(visited);
    }

    public synchronized void setVisited(Set visited) {
        this.visited = visited;
    }

    public synchronized Event addVisited(Set visited) {
        this.visited.addAll(visited);
        return this;
    }

    public List getMembers() {
        return members;
    }

    public void setMember(List members) {
        this.members = members;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public CollectiveImpl.Type getCollectiveType() {
        return collectiveType;
    }

    public void setCollectiveType(CollectiveImpl.Type collectiveType) {
        this.collectiveType = collectiveType;
    }

    public int getCycle() {
        return cycle;
    }

    public void setCycle(int cycle) {
        this.cycle = cycle;
    }

    public byte[] getPayload() {
        return payload;
    }

    public void setPayload(byte[] payload) {
        this.payload = payload;
    }

    @Override
    public String toString() {
        return "collective=" + collectiveType + ",type=" + type + "," + members.toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy