com.baziaking.blackjack.domain.model.Action.java Source code

Java tutorial

Introduction

Here is the source code for com.baziaking.blackjack.domain.model.Action.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 com.baziaking.blackjack.domain.model;

import com.baziaking.blackjack.domain.enumeration.ActionType;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author arahis
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Action {

    private long actionId;
    private long gameId;
    private ActionType type;
    private long cashTransfered;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd,HH:00", timezone = "CET")
    private Date date = new Date();

    @XmlTransient
    private Game game;

    public Action() {
    }

    public long getActionId() {
        return actionId;
    }

    public void setActionId(long actionId) {
        this.actionId = actionId;
    }

    public long getGameId() {
        return gameId;
    }

    public void setGameId(long gameId) {
        this.gameId = gameId;
    }

    public ActionType getType() {
        return type;
    }

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

    public long getCashTransfered() {
        return cashTransfered;
    }

    public void setCashTransfered(long cashTransfered) {
        this.cashTransfered = cashTransfered;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Game getGame() {
        return game;
    }

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

    @Override
    public String toString() {
        return "Action{" + "actionId=" + actionId + ", gameId=" + gameId + ", type=" + type + ", cashTransfered="
                + cashTransfered + ", date=" + date + '}';
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 67 * hash + (int) (this.actionId ^ (this.actionId >>> 32));
        hash = 67 * hash + (int) (this.gameId ^ (this.gameId >>> 32));
        hash = 67 * hash + Objects.hashCode(this.type);
        hash = 67 * hash + (int) (this.cashTransfered ^ (this.cashTransfered >>> 32));
        hash = 67 * hash + Objects.hashCode(this.date);
        hash = 67 * hash + Objects.hashCode(this.game);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Action other = (Action) obj;
        if (this.actionId != other.actionId) {
            return false;
        }
        if (this.gameId != other.gameId) {
            return false;
        }
        if (this.type != other.type) {
            return false;
        }
        if (this.cashTransfered != other.cashTransfered) {
            return false;
        }
        if (!Objects.equals(this.date, other.date)) {
            return false;
        }
        if (!Objects.equals(this.game, other.game)) {
            return false;
        }
        return true;
    }

}