File was renamed from src/main/java/hu/unr/fiber/cardapi/rest/CardEntity.java |
| | |
| | | package hu.unr.fiber.cardapi.rest; |
| | | |
| | | import hu.unr.fiber.cardapi.entity.CardEntityInterface; |
| | | import hu.unr.fiber.cardapi.interfaces.CardInterface; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | |
| | | public class CardEntity implements CardEntityInterface { |
| | | public class RestCard implements CardInterface { |
| | | public static final long INVALID_ID = 0; |
| | | private long id = INVALID_ID; |
| | | |
| | |
| | | private String number; |
| | | private String cardHolder; |
| | | |
| | | public CardEntity(long id) { |
| | | public RestCard(long id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public CardEntity(long id, String name, String number) { |
| | | public RestCard(long id, String name, String number) { |
| | | this.setId(id) |
| | | .setName(name) |
| | | .setNumber(number); |
| | | } |
| | | |
| | | public CardEntity(long id, String name, String number, String cardHolder) { |
| | | public RestCard(long id, String name, String number, String cardHolder) { |
| | | this.setId(id) |
| | | .setName(name) |
| | | .setNumber(number) |
| | |
| | | } |
| | | |
| | | public boolean validId() { |
| | | return (this.getId() != CardEntity.INVALID_ID); |
| | | return (this.getId() != RestCard.INVALID_ID); |
| | | } |
| | | |
| | | public CardEntity setId(long id) { |
| | | public RestCard setId(long id) { |
| | | this.id = id; |
| | | return this; |
| | | } |
| | |
| | | return name; |
| | | } |
| | | |
| | | public CardEntity setName(String name) { |
| | | public RestCard setName(String name) { |
| | | this.name = name; |
| | | return this; |
| | | } |
| | |
| | | return number; |
| | | } |
| | | |
| | | public CardEntity setNumber(String number) { |
| | | public RestCard setNumber(String number) { |
| | | this.number = number; |
| | | return this; |
| | | } |
| | |
| | | return cardHolder; |
| | | } |
| | | |
| | | public CardEntity setCardHolder(String cardHolder) { |
| | | public RestCard setCardHolder(String cardHolder) { |
| | | this.cardHolder = cardHolder; |
| | | return this; |
| | | } |
| | |
| | | public boolean equals(Object o) { |
| | | if (this == o) return true; |
| | | if (o == null || getClass() != o.getClass()) return false; |
| | | CardEntity card = (CardEntity) o; |
| | | RestCard card = (RestCard) o; |
| | | return id == card.id && |
| | | name.equals(card.name) && |
| | | number.equals(card.number) && |
| | | Objects.equals(cardHolder, card.cardHolder); |
| | | } |
| | | |
| | | public CardEntity update(CardEntityInterface otherCardEntity) { |
| | | this.setName(otherCardEntity.getName()); |
| | | this.setNumber(otherCardEntity.getNumber()); |
| | | this.setCardHolder(otherCardEntity.getCardHolder()); |
| | | public RestCard update(CardInterface otherCard) { |
| | | this.setName(otherCard.getName()); |
| | | this.setNumber(otherCard.getNumber()); |
| | | this.setCardHolder(otherCard.getCardHolder()); |
| | | return this; |
| | | } |
| | | |