view com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/Command.java @ 90:8f2dd0dbdb87

Externalize strings
author Omair Majid <omajid@redhat.com>
date Tue, 21 Jan 2014 19:51:04 -0500
parents b788a26c0d4d
children 4356c844cff9
line wrap: on
line source

package com.redhat.thermostat.tools.eclipse.plugin.model;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlType;

@XmlType(propOrder = {
        "name", "description", "usage",
        "arguments", "options",
        "environments",
        "bundles"})
public class Command extends ModelObject {

    private String name;
    private String description;
    private String usage;
    private List<String> arguments = new ArrayList<>();
    private List<Option> options = new ArrayList<>();
    private Environments environments = new Environments();
    private List<Bundle> bundles = new ArrayList<>();

    public Command() {
        // no-arg java bean constructor
    }

    public Command(String name, String description, String usage,
            List<String> arguments, List<Option> options,
            Environments environments, List<Bundle> bundles) {
        this.name = name;
        this.description = description;
        this.usage = usage;

        this.arguments = arguments;
        this.options = options;
        this.environments = environments;
        this.bundles = bundles;
    }

    @XmlElement(name="name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        firePropertyChange("name", this.name, this.name = name); //$NON-NLS-1$
    }

    @XmlElement(name="description")
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        firePropertyChange("description", this.description, this.description = description); //$NON-NLS-1$
    }

    @XmlElement(name="usage")
    public String getUsage() {
        return usage;
    }

    public void setUsage(String usage) {
        firePropertyChange("usage", this.usage, this.usage = usage); //$NON-NLS-1$
    }

    @XmlElementWrapper(name="arguments")
    @XmlElement(name="argument")
    public List<String> getArguments() {
        return arguments;
    }

    public void setArguments(List<String> arguments) {
        firePropertyChange("arguments", this.arguments, this.arguments = arguments); //$NON-NLS-1$
    }

    public void addArgument(String argument) {
        this.arguments.add(argument);
        firePropertyChange("arguments", null, this.arguments); //$NON-NLS-1$
    }

    public void removeArgument(String argument) {
        this.arguments.remove(argument);
        firePropertyChange("arguments", null, this.arguments); //$NON-NLS-1$
    }

    @XmlElementWrapper(name="options")
    @XmlElement(name="option")
    public List<Option> getOptions() {
        return options;
    }

    public void setOptions(List<Option> options) {
        firePropertyChange("options", this.options, this.options = options); //$NON-NLS-1$
    }

    @XmlElement(name="environments")
    public Environments getEnvironments() {
        return environments;
    }

    public void setEnvironments(Environments environments) {
        firePropertyChange("environments", this.environments, this.environments = environments); //$NON-NLS-1$
    }

    @XmlElementWrapper(name="bundles")
    @XmlElement(name="bundle")
    public List<Bundle> getBundles() {
        return bundles;
    }

    public void setBundles(List<Bundle> bundles) {
        this.bundles = bundles;
    }

    public void addBundle(Bundle bundle) {
        this.bundles.add(bundle);
        firePropertyChange("bundles", null, this.bundles); //$NON-NLS-1$
    }

    public void removeBundle(Bundle bundle) {
        this.bundles.remove(bundle);
        firePropertyChange("bundles", null, this.bundles); //$NON-NLS-1$
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof Command)) {
            return false;
        }
        Command other = (Command) obj;
        return Objects.equals(this.name, other.name) &&
                Objects.equals(this.description, other.description) &&
                Objects.equals(this.usage, other.usage) &&
                Objects.equals(this.arguments, other.arguments) &&
                Objects.equals(this.options, other.options) &&
                Objects.equals(this.environments, other.environments) &&
                Objects.equals(this.bundles, other.bundles);
    }
}