view gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/services/requestobjects/DefaultFIS.java @ 1115:f953c9a559d8

Added license file and license headers. gnv-artifacts/trunk@1260 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 02 Nov 2010 17:46:55 +0000
parents 05bf8534a35a
children
line wrap: on
line source
/*
 * Copyright (c) 2010 by Intevation GmbH
 *
 * This program is free software under the LGPL (>=v2.1)
 * Read the file LGPL.txt coming with the software for details
 * or visit http://www.gnu.org/licenses/ if it does not exist.
 */

package de.intevation.gnv.artifacts.services.requestobjects;

import java.util.Collection;
import java.util.Iterator;

/**
 * The default implementation of <code>Fis</code>.
 *
 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
 *
 */
public class DefaultFIS implements FIS {

    /**
     * The ID of the FIS
     */
    private String id = null;

    /**
     * The Parameter which belongs to the FIS.
     */
    private Collection<Parameter> parameter = null;

    /**
     * Constructor
     *
     * @param id The id for this fis.
     */
    public DefaultFIS(String id){
        super();
        this.id = id;
    }
    /**
     * Constructor
     * @param id The id for this fis.
     * @param parameter A collection of parameters.
     */
    public DefaultFIS(String id, Collection<Parameter> parameter) {
        this(id);
        this.parameter = parameter;
    }


    public String getID() {
        return this.id;
    }

    public Collection<Parameter> getParameter() {
        return this.parameter;
    }

    /**
     * Two objects are equal if they have the same id.
     *
     * @param arg0 Object which is checked for equality.
     * @return True, if both objects are equal, otherwise false.
     */
    @Override
    public boolean equals(Object arg0) {
        boolean returnValue = false;
        if (arg0 instanceof FIS){
            returnValue = this.id.equals(((FIS)arg0).getID());
        }
        return returnValue;
    }

    /**
     * Creates a hash code using the id and the given parameters.
     *
     * @return A hash code.
     */
    @Override
    public int hashCode() {
        int hash = 7;
        hash = 47 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 47 * hash + (this.parameter != null ? this.parameter.hashCode() : 0);
        return hash;
    }

    /**
     * @param parameter Collection of parameters.
     */
    public void addParameter(Collection<Parameter> parameter) {
        if (this.parameter != null){
            Iterator<Parameter> it = parameter.iterator();
            while (it.hasNext()){
                Parameter tmpParameter = it.next();
                if (!this.parameter.contains(tmpParameter)){
                    this.parameter.add(tmpParameter);
                }
            }
        }else{
            this.parameter = parameter;
        }
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org