Java tutorial
/** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License and the extra * conditions for OpenLR. (see openlr-license.txt) * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /** * Copyright (C) 2009,2010 TomTom International B.V. * * TomTom (Legal Department) * Email: legal@tomtom.com * * TomTom (Technical contact) * Email: openlr@tomtom.com * * Address: TomTom International B.V., Oosterdoksstraat 114, 1011DK Amsterdam, * the Netherlands */ package eu.datex2.schema._2_0rc2._2_0; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; /** * <p>Java class for Accident complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="Accident"> * <complexContent> * <extension base="{http://datex2.eu/schema/2_0RC2/2_0}TrafficElement"> * <sequence> * <element name="accidentType" type="{http://datex2.eu/schema/2_0RC2/2_0}AccidentTypeEnum" maxOccurs="unbounded"/> * <element name="accidentExtension" type="{http://datex2.eu/schema/2_0RC2/2_0}_ExtensionType" minOccurs="0"/> * </sequence> * </extension> * </complexContent> * </complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "Accident", propOrder = { "accidentType", "accidentExtension" }) public class Accident extends TrafficElement { /** The accident type. */ @XmlElement(required = true) protected List<AccidentTypeEnum> accidentType; /** The accident extension. */ protected ExtensionType accidentExtension; /** * Gets the value of the accidentType property. * * <p> * This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a <CODE>set</CODE> method for the accidentType property. * * <p> * For example, to add a new item, do as follows: * <pre> * getAccidentType().add(newItem); * </pre> * * * <p> * Objects of the following type(s) are allowed in the list * * @return the accident type * {@link AccidentTypeEnum } */ public final List<AccidentTypeEnum> getAccidentType() { if (accidentType == null) { accidentType = new ArrayList<AccidentTypeEnum>(); } return this.accidentType; } /** * Gets the value of the accidentExtension property. * * @return the accident extension * possible object is * {@link ExtensionType } */ public final ExtensionType getAccidentExtension() { return accidentExtension; } /** * Sets the value of the accidentExtension property. * * @param value * allowed object is * {@link ExtensionType } * */ public final void setAccidentExtension(final ExtensionType value) { this.accidentExtension = value; } /** * {@inheritDoc} */ @Override public final void toString(final ToStringBuilder toStringBuilder) { super.toString(toStringBuilder); List<AccidentTypeEnum> theAccidentType; theAccidentType = this.getAccidentType(); toStringBuilder.append("accidentType", theAccidentType); ExtensionType theAccidentExtension; theAccidentExtension = this.getAccidentExtension(); toStringBuilder.append("accidentExtension", theAccidentExtension); } /** * {@inheritDoc} */ @Override public final String toString() { final ToStringBuilder toStringBuilder = new ToStringBuilder(this); toString(toStringBuilder); return toStringBuilder.toString(); } /** * {@inheritDoc} */ @Override public final void equals(final Object object, final EqualsBuilder equalsBuilder) { if (!(object instanceof Accident)) { equalsBuilder.appendSuper(false); return; } if (this == object) { return; } super.equals(object, equalsBuilder); final Accident that = ((Accident) object); equalsBuilder.append(this.getAccidentType(), that.getAccidentType()); equalsBuilder.append(this.getAccidentExtension(), that.getAccidentExtension()); } /** * {@inheritDoc} */ @Override public final boolean equals(final Object object) { if (!(object instanceof Accident)) { return false; } if (this == object) { return true; } final EqualsBuilder equalsBuilder = new EqualsBuilder(); equals(object, equalsBuilder); return equalsBuilder.isEquals(); } /** * {@inheritDoc} */ @Override public final void hashCode(final HashCodeBuilder hashCodeBuilder) { super.hashCode(hashCodeBuilder); hashCodeBuilder.append(this.getAccidentType()); hashCodeBuilder.append(this.getAccidentExtension()); } /** * {@inheritDoc} */ @Override public final int hashCode() { final HashCodeBuilder hashCodeBuilder = new HashCodeBuilder(); hashCode(hashCodeBuilder); return hashCodeBuilder.toHashCode(); } }