/*
 * ******************************************************************************
 *   Copyright 2014-2015 Spectra Logic Corporation. All Rights Reserved.
 *   Licensed under the Apache License, Version 2.0 (the "License"). You may not use
 *   this file except in compliance with the License. A copy of the License is located at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 *   or in the "license" file accompanying this file.
 *   This file 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.spectralogic.ds3autogen.api.models.apispec;

import com.google.common.collect.ImmutableList;

import java.util.Objects;

public class Ds3Element {

    private final String name;
    private final String type;
    private final String componentType;
    private final ImmutableList<Ds3Annotation> ds3Annotations;
    private final boolean nullable;

    public Ds3Element(
            final String name,
            final String type,
            final String componentType,
            final ImmutableList<Ds3Annotation> ds3Annotations,
            final boolean nullable) {
        this.name = name;
        this.type = type;
        this.componentType = componentType;
        this.ds3Annotations = ds3Annotations;
        this.nullable = nullable;
    }

    public Ds3Element(
            final String name,
            final String type,
            final String componentType,
            final boolean nullable) {
        this(name, type, componentType, null, nullable);
    }

    public String getName() {
        return name;
    }

    public String getType() {
        return type;
    }

    public ImmutableList<Ds3Annotation> getDs3Annotations() {
        return ds3Annotations;
    }

    public String getComponentType() {
        return componentType;
    }

    @Override
    public int hashCode() {
        return Objects.hash(getName(), getType(), getComponentType());
    }

    /**
     * Compares the name, type, and component type. Does not compare the Ds3Annotation list
     */
    @Override
    public boolean equals(final Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof Ds3Element)) {
            return false;
        }
        final Ds3Element element = (Ds3Element) obj;

        return this.getName().equals(element.getName())
                && this.getType() != null
                && this.getType().equals(element.getType())
                && this.getComponentType() != null
                && this.getComponentType().equals(element.getComponentType());
    }

    public boolean isNullable() {
        return nullable;
    }}

@@ -2611,32 +2611,50 @@
 is.getType()
- != null
+.equals(element.getType())
 %0A           
@@ -2657,32 +2657,33 @@
          && 
+(
 this.get
 Type().equal
@@ -2674,41 +2674,36 @@
 .get
-Type().equals(element.getType())%0A
+ComponentType() == null%0A    
     
@@ -2706,39 +2706,41 @@
                 
-&& this
+? element
 .getComponentTyp
@@ -2743,17 +2743,17 @@
 tType() 
-!
+=
 = null%0A 
@@ -2759,34 +2759,37 @@
                 
-&&
+    :
  this.getCompone
@@ -2823,32 +2823,33 @@
 ComponentType())
+)
 ;%0A    %7D%0A%0A    pub

Fix Ds3Element compare for both when both are null