blob: cfb0f842bf80ea6b62d61eac55303dd2217c8ef6 [file] [log] [blame]
/*
* Copyright (c) 2011, 2020 Oracle and/or its affiliates. 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:
// mmacivor - Initial implementation
package org.eclipse.persistence.testing.jaxb.annotations.xmlpath;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import jakarta.xml.bind.annotation.XmlAnyAttribute;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlIDREF;
import javax.xml.namespace.QName;
import org.eclipse.persistence.oxm.annotations.XmlPath;
public class Employee {
@XmlAttribute
@XmlPath("employee-info/@id")
public Integer id;
@XmlElement
@XmlPath("personal-info/first-name/text()")
public String firstName;
@XmlPath("personal-info/last-name/text()")
public String lastName;
@XmlPath("contact-info/address-id/text()")
@XmlIDREF
public Address address;
@XmlPath("contact-info/phones/phone-number")
public List<PhoneNumber> phones;
@XmlPath("responsibilities/responsibility/text()")
public List<String> responsibilities;
@XmlPath("extra-attributes")
@XmlAnyAttribute
public Map<QName, String> attributes;
@XmlPath("any-object-root")
public Object anyObject;
@XmlPath("any-collection-root")
public List<Object> anyCollection;
public boolean equals(Object obj) {
if(!(obj instanceof Employee)) {
return false;
}
Employee emp = (Employee)obj;
boolean equal = this.firstName.equals(emp.firstName);
equal = equal && this.lastName.equals(emp.lastName);
equal = equal && this.address.equals(emp.address);
Iterator<PhoneNumber> phones1 = this.phones.iterator();
Iterator<PhoneNumber> phones2 = emp.phones.iterator();
while(phones1.hasNext()) {
equal = (phones1.next().equals(phones2.next())) && equal;
}
for(QName nextKey:this.attributes.keySet()) {
String value1 = this.attributes.get(nextKey);
String value2 = emp.attributes.get(nextKey);
equal = equal && value1.equals(value2);
}
return equal;
}
}