Account.java

  1. /*
  2.  * Copyright 2005-2025 the original author or authors.
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  * http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16. package org.openwms.common.account;

  17. import jakarta.persistence.Column;
  18. import jakarta.persistence.Entity;
  19. import jakarta.persistence.Table;
  20. import jakarta.persistence.UniqueConstraint;
  21. import jakarta.validation.constraints.NotEmpty;
  22. import org.ameba.integration.jpa.ApplicationEntity;

  23. import java.io.Serializable;
  24. import java.util.Objects;

  25. /**
  26.  * An Account encapsulates identifying information about the actual cost center. Other domain entities may be assigned to an Account and
  27.  * therefore reserved to be used only by this Account. The Account must not be mixed with the Tenant. A Tenant can have multiple Accounts
  28.  * and is not managed as domain object.
  29.  *
  30.  * @author Heiko Scherrer
  31.  * @GlossaryTerm
  32.  */
  33. @Entity
  34. @Table(name = "COM_ACCOUNT", uniqueConstraints = {
  35.         @UniqueConstraint(name = "UC_ACC_ID", columnNames = "C_IDENTIFIER"),
  36.         @UniqueConstraint(name = "UC_ACC_NAME", columnNames = "C_NAME")
  37. })
  38. public class Account extends ApplicationEntity implements Serializable {

  39.     /** Unique identifier. */
  40.     @NotEmpty
  41.     @Column(name = "C_IDENTIFIER", nullable = false, updatable = false)
  42.     private String identifier;

  43.     /** Name of the Account. */
  44.     @NotEmpty
  45.     @Column(name = "C_NAME", nullable = false)
  46.     private String name;

  47.     /** Flag to set the Account as default. */
  48.     @Column(name = "C_DEFAULT", nullable = false)
  49.     private boolean defaultAccount = false;

  50.     public String getIdentifier() {
  51.         return identifier;
  52.     }

  53.     public void setIdentifier(String identifier) {
  54.         this.identifier = identifier;
  55.     }

  56.     public String getName() {
  57.         return name;
  58.     }

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

  62.     public boolean isDefaultAccount() {
  63.         return defaultAccount;
  64.     }

  65.     public void setDefaultAccount(boolean defaultAccount) {
  66.         this.defaultAccount = defaultAccount;
  67.     }

  68.     /**
  69.      * The {@code identifier}.
  70.      *
  71.      * @return The identifier
  72.      */
  73.     @Override
  74.     public String toString() {
  75.         return identifier;
  76.     }

  77.     /**
  78.      * {@inheritDoc}
  79.      *
  80.      * All fields,
  81.      */
  82.     @Override
  83.     public boolean equals(Object o) {
  84.         if (this == o) return true;
  85.         if (o == null || getClass() != o.getClass()) return false;
  86.         Account account = (Account) o;
  87.         return defaultAccount == account.defaultAccount &&
  88.                 Objects.equals(identifier, account.identifier) &&
  89.                 Objects.equals(name, account.name);
  90.     }

  91.     /**
  92.      * {@inheritDoc}
  93.      *
  94.      * All fields,
  95.      */
  96.     @Override
  97.     public int hashCode() {
  98.         return Objects.hash(identifier, name, defaultAccount);
  99.     }
  100. }