ca.qhrtech.entities.BGLTable.java Source code

Java tutorial

Introduction

Here is the source code for ca.qhrtech.entities.BGLTable.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ca.qhrtech.entities;

import ca.qhrtech.utilities.LocalDateTimeDeserializer;
import ca.qhrtech.utilities.LocalDateTimeSerializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import org.jsondoc.core.annotation.ApiObject;
import org.jsondoc.core.annotation.ApiObjectField;

/**
 *
 * @author bryan.bergen
 */
@Entity
@ApiObject(description = "A Table represents a Game and a group of Users at a specific time")
public class BGLTable implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @ApiObjectField(description = "A Table's unique identifier")
    private long id;

    @ManyToOne
    @ApiObjectField(description = "The User who created the table")
    private BGLUser creator;

    @ManyToOne
    @ApiObjectField(description = "The Game being played at this table")
    private Game game;

    @ApiObjectField(description = "The id of the poll on a 3rd party polling site. Used to decide a game")
    private long pollId;

    @ApiObjectField(description = "Determines whether this table is publicly visible to all users, or only invitees")
    private boolean publiclyVisible;

    @ApiObjectField(description = "Flag for whether the game is upcoming or completed")
    private boolean completed;

    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @ApiObjectField(description = "The time the game is scheduled to be played at the table")
    private LocalDateTime startDate;

    @ManyToMany
    @ApiObjectField(description = "The list of current invitees")
    private List<BGLUser> invites;

    public BGLTable() {
    }

    public BGLTable(BGLUser creator) {
        this.creator = creator;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getId() {
        return id;
    }

    public BGLUser getCreator() {
        return creator;
    }

    public Game getGame() {
        return game;
    }

    public void setGame(Game game) {
        this.game = game;
    }

    public long getPollId() {
        return pollId;
    }

    public void setPollId(long pollId) {
        this.pollId = pollId;
    }

    public boolean isPubliclyVisible() {
        return publiclyVisible;
    }

    public void setPubliclyVisible(boolean publiclyVisible) {
        this.publiclyVisible = publiclyVisible;
    }

    public boolean isCompleted() {
        return completed;
    }

    public void setCompleted(boolean completed) {
        this.completed = completed;
    }

    public LocalDateTime getStartDate() {
        return startDate;
    }

    public void setStartDate(LocalDateTime startDate) {
        this.startDate = startDate;
    }

    public List<BGLUser> getInvites() {
        return invites;
    }

    public void setInvites(List<BGLUser> invites) {
        this.invites = invites;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 23 * hash + (int) (this.id ^ (this.id >>> 32));
        hash = 23 * hash + Objects.hashCode(this.creator);
        hash = 23 * hash + Objects.hashCode(this.game);
        hash = 23 * hash + (int) (this.pollId ^ (this.pollId >>> 32));
        hash = 23 * hash + (this.publiclyVisible ? 1 : 0);
        hash = 23 * hash + (this.completed ? 1 : 0);
        hash = 23 * hash + Objects.hashCode(this.startDate);
        hash = 23 * hash + Objects.hashCode(this.invites);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final BGLTable other = (BGLTable) obj;
        if (this.id != other.id) {
            return false;
        }
        if (this.pollId != other.pollId) {
            return false;
        }
        if (this.publiclyVisible != other.publiclyVisible) {
            return false;
        }
        if (this.completed != other.completed) {
            return false;
        }
        if (!Objects.equals(this.creator, other.creator)) {
            return false;
        }
        if (!Objects.equals(this.game, other.game)) {
            return false;
        }
        if (!Objects.equals(this.startDate, other.startDate)) {
            return false;
        }
        if (!Objects.equals(this.invites, other.invites)) {
            return false;
        }
        return true;
    }

}