⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 address.java

📁 Java EE 5 许多新功能都包含经过修补的 EJB 架构
💻 JAVA
字号:
/*
 * Copyright 2006 Borys Burnayev
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.rdacorp.petstore.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Version;

/**
 * @author Borys Burnayev
 */
@Entity
@Table(name = "LOCATION")
@SequenceGenerator(name = "LocationSeq", sequenceName = "SQ_LOCATION")
public class Address {

   private Integer addressId;

   private String addressLine1;

   private String addressLine2;

   private String city;

   private String zip;

   private State state;

   private int version;

   @Column(name = "row_version")
   @Version
   public int getVersion() {
      return version;
   }

   public void setVersion(int version) {
      this.version = version;
   }

   public Address(String addressLine1, String addressLine2, String city, String zip, State state) {
      this.addressLine1 = addressLine1;
      this.addressLine2 = addressLine2;
      this.city = city;
      this.zip = zip;
      this.state = state;
   }

   public Address() {
   }

   @Id
   @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "LocationSeq")
   @Column(name = "location_sysid")
   public Integer getAddressId() {
      return this.addressId;
   }

   public void setAddressId(Integer addressId) {
      this.addressId = addressId;
   }

   @Column(name = "address_line_1")
   public String getAddressLine1() {
      return this.addressLine1;
   }

   public void setAddressLine1(String addressLine1) {
      this.addressLine1 = addressLine1;
   }

   @Column(name = "address_line_2")
   public String getAddressLine2() {
      return this.addressLine2;
   }

   public void setAddressLine2(String addressLine2) {
      this.addressLine2 = addressLine2;
   }

   @Column(name = "city")
   public String getCity() {
      return this.city;
   }

   public void setCity(String city) {
      this.city = city;
   }

   @Column(name = "postal_cd")
   public String getZip() {
      return this.zip;
   }

   public void setZip(String postalCd) {
      this.zip = postalCd;
   }

   @ManyToOne
   @JoinColumn(name = "state_sysid", referencedColumnName = "us_state_id")
   public State getState() {
      return this.state;
   }

   public void setState(State usStateType) {
      this.state = usStateType;
   }

   public String toString() {
      String id = addressId != null ? addressId.toString() : "<no ID>";
      return "Address " + id + ":\nAddress Line 1: " + addressLine1 + "\nAddress Line 2: " + addressLine2 + "\nCity: "
               + city + "\n" + state + "Zip: " + zip + "\n";
   }

   public boolean equals(Object object) {
      if (!(object instanceof Address))
         return false;
      Address address = (Address) object;
      return addressLine1.equals(address.addressLine1) && city.equals(address.city) && zip.equals(address.zip)
               && state.equals(address.state);
   }

   public int hashCode() {
      return addressLine1.hashCode();
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -