blob: 27c4879f32daa9afd5da6967078eb2d847ac8336 [file] [log] [blame]
/*
* Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016 IBM Corporation. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// 08/24/2016 - Will Dazey
// - 500145 : Nested Embeddables Test
package org.eclipse.persistence.jpa.embeddable.model;
import jakarta.persistence.Embeddable;
import jakarta.persistence.Embedded;
@Embeddable
public class Address {
@Embedded
protected Zipcode zipcode;
public Address() { }
public Address(Zipcode zipcode) {
this.setZipcode(zipcode);
}
public Zipcode getZipcode() {
return zipcode;
}
public void setZipcode(Zipcode zipcode) {
this.zipcode = zipcode;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((zipcode == null) ? 0 : zipcode.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Address other = (Address) obj;
if (zipcode == null) {
if (other.zipcode != null)
return false;
} else if (!zipcode.equals(other.zipcode))
return false;
return true;
}
}