edu.infsci2560.models.Transaction.java Source code

Java tutorial

Introduction

Here is the source code for edu.infsci2560.models.Transaction.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 edu.infsci2560.models;

import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
 *
 * @author jim37
 */
@Entity
public class Transaction {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    protected Long id;
    protected Date time;
    protected Long carId;
    protected String price;

    public Transaction() {
        this.id = Long.MAX_VALUE;
        this.time = null;
        this.carId = null;
        this.price = null;
    }

    public Transaction(Long carId, String price) {
        Date now = new Date();
        this.time = now;
        this.carId = carId;
        this.price = price;
    }

    @Override
    public String toString() {
        return "[ id=" + this.id + ", time=" + this.time + ", carId=" + this.carId + ", price=" + this.price + " ]";
    }

    @Override
    public boolean equals(Object other) {
        return EqualsBuilder.reflectionEquals(this, other);
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public Long getId() {
        return id;
    }

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

    public Long getCarId() {
        return carId;
    }

    public void setCarId(Long carId) {
        this.carId = carId;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

}