/*
 * Copyright (c) 2006-2014 DMDirc Developers
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.dmdirc.ui.core.autocommands;

import com.dmdirc.commandparser.auto.AutoCommand;

import com.google.common.base.MoreObjects;

import java.util.Objects;
import java.util.Optional;

import javax.annotation.Nonnull;

/**
 * Mutable version of an {@link AutoCommand}.
 */
public class MutableAutoCommand {

    private Optional<String> server;
    private Optional<String> network;
    private Optional<String> profile;
    private String response;

    public MutableAutoCommand(
            final Optional<String> server,
            final Optional<String> network,
            final Optional<String> profile,
            @Nonnull final String response) {
        this.server = server;
        this.network = network;
        this.profile = profile;
        this.response = response;
    }

    public Optional<String> getServer() {
        return server;
    }

    public void setServer(final Optional<String> server) {
        this.server = server;
    }

    public Optional<String> getNetwork() {
        return network;
    }

    public void setNetwork(final Optional<String> network) {
        this.network = network;
    }

    public Optional<String> getProfile() {
        return profile;
    }

    public void setProfile(final Optional<String> profile) {
        this.profile = profile;
    }

    @Nonnull
    public String getResponse() {
        return response;
    }

    public void setResponse(@Nonnull final String response) {
        this.response = response;
    }

    public AutoCommand getAutoCommand() {
        return new AutoCommand(server, network, profile, response);
    }

    @Override
    public boolean equals(final Object object) {
        if (object == null) {
            return false;
        }
        if (getClass() != object.getClass()) {
            return false;
        }
        final MutableAutoCommand command = (MutableAutoCommand) object;
        return Objects.equals(server, command.getServer()) &&
                Objects.equals(network, command.getNetwork()) &&
                Objects.equals(profile, command.getProfile()) &&
                Objects.equals(response, command.getResponse());
    }

    public boolean equalsAutoCommand(final AutoCommand command) {
        if (command == null) {
            return false;
        }
        return Objects.equals(server, command.getServer()) &&
                Objects.equals(network, command.getNetwork()) &&
                Objects.equals(profile, command.getProfile()) &&
                Objects.equals(response, command.getResponse());
    }

    @Override
    public int hashCode() {
        return Objects.hash(server, network, profile, response);
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("Connection", server)
                .add("Network", network)
                .add("Profile", profile)
                .add("Response", response)
                .toString();
    }
}

@@ -3362,20 +3362,23 @@
     
-if (
+return 
 command 
 == n
@@ -3377,69 +3377,18 @@
 and 
-=
+!
 = null
-) %7B%0A            return false;%0A        %7D%0A        return
+ &&
  Obj

Simplify equals method.