cz.muni.fi.dndtroopsapi.dto.TroopCreateDTO.java Source code

Java tutorial

Introduction

Here is the source code for cz.muni.fi.dndtroopsapi.dto.TroopCreateDTO.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 cz.muni.fi.dndtroopsapi.dto;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.springframework.format.annotation.NumberFormat;
import org.springframework.format.annotation.NumberFormat.Style;

/**
 *
 * @author Karel
 */
public class TroopCreateDTO {

    @NotNull
    @Size(min = 3, max = 64)
    private String name;

    @NotNull
    @Min(0)
    private BigDecimal money;

    @Size(min = 3, max = 1024)
    private String mission;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public BigDecimal getMoney() {
        return money;
    }

    public void setMoney(BigDecimal money) {
        this.money = money;
    }

    public String getMission() {
        return mission;
    }

    public void setMission(String mission) {
        this.mission = mission;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 97 * hash + ((name == null) ? 0 : name.hashCode());
        hash = 97 * hash + ((money == null) ? 0 : money.hashCode());
        hash = 97 * hash + ((mission == null) ? 0 : mission.hashCode());
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof TroopCreateDTO)) {
            return false;
        }
        final TroopCreateDTO other = (TroopCreateDTO) obj;

        if (this.name == null) {
            if (other.getName() != null) {
                return false;
            }
        }
        if (!name.equals(other.getName())) {
            return false;
        }

        if (this.money == null) {
            if (other.getMoney() != null) {
                return false;
            }
        }

        if (other.getMoney() == null) {
            if (this.money != null) {
                return false;
            }
        }
        if (!(this.money.compareTo(other.getMoney()) == 0)) {
            return false;
        }

        if (this.mission == null) {
            if (other.getMission() != null) {
                return false;
            }
        }
        if (!Objects.equals(this.mission, other.getMission())) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "TroopCreateDTO{" + "name=" + name + ", money=" + money + ", mission=" + mission + '}';
    }

}