/*
 * Copyright 2016 the original author or authors.
 *
 * 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 org.gradle.plugin.devel;

import com.google.common.base.Objects;
import org.gradle.api.Named;

import javax.annotation.Nullable;
import java.io.Serializable;


//TODO version - could be different from main artifact's version
/**
 * Describes a Gradle plugin under development.
 *
 * @see org.gradle.plugin.devel.plugins.JavaGradlePluginPlugin
 * @since 2.14
 */
public class PluginDeclaration implements Named, Serializable {
    private final String name;
    private String id;
    private String implementationClass;
    private String displayName;
    private String description;

    public PluginDeclaration(String name) {
        this.name = name;
    }

    @Override
    public String getName() {
        return name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getImplementationClass() {
        return implementationClass;
    }

    public void setImplementationClass(String implementationClass) {
        this.implementationClass = implementationClass;
    }

    /**
     * Returns the display name for this plugin declaration.
     *
     * <p>The display name is used when publishing this plugin to repositories
     * that support human-readable artifact names.
     *
     * @since 4.10
     */
    @Nullable
    public String getDisplayName() {
        return displayName;
    }

    /**
     * Sets the display name for this plugin declaration.
     *
     * <p>The display name is used when publishing this plugin to repositories
     * that support human-readable artifact names.
     *
     * @since 4.10
     */
    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    /**
     * Returns the description for this plugin declaration.
     *
     * <p>The description is used when publishing this plugin to repositories
     * that support providing descriptions for artifacts.
     *
     * @since 4.10
     */
    @Nullable
    public String getDescription() {
        return description;
    }

    /**
     * Sets the description for this plugin declaration.
     *
     * <p>The description is used when publishing this plugin to repositories
     * that support providing descriptions for artifacts.
     *
     * @since 4.10
     */
    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof PluginDeclaration) {
            PluginDeclaration other = (PluginDeclaration) obj;
            return Objects.equal(name, other.name)
                && Objects.equal(id, other.id)
                && Objects.equal(implementationClass, other.implementationClass);
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(name, id, implementationClass);
    }
}

@@ -648,47 +648,8 @@
 l;%0A%0A
-import com.google.common.base.Objects;%0A
 impo
@@ -737,16 +737,42 @@
 izable;%0A
+import java.util.Objects;%0A
 %0A%0A//TODO
@@ -1015,16 +1015,96 @@
 s Named,
+%0A    // TODO: Shouldn't be serializable, remove the interface in Gradle 8.0.%0A   
  Seriali
@@ -3143,24 +3143,86 @@
 ject obj) %7B%0A
+        if (this == obj) %7B%0A            return true;%0A        %7D%0A
         if (
@@ -3352,16 +3352,17 @@
 ts.equal
+s
 (name, o
@@ -3404,16 +3404,17 @@
 ts.equal
+s
 (id, oth
@@ -3452,16 +3452,17 @@
 ts.equal
+s
 (impleme
@@ -3497,24 +3497,156 @@
 tationClass)
+%0A                && Objects.equals(displayName, other.displayName)%0A                && Objects.equals(description, other.description)
 ;%0A        %7D%0A
@@ -3743,20 +3743,16 @@
 cts.hash
-Code
 (name, i

Fix equals on PluginDeclaration