ingo@1115: /* ingo@1115: * Copyright (c) 2010 by Intevation GmbH ingo@1115: * ingo@1115: * This program is free software under the LGPL (>=v2.1) ingo@1115: * Read the file LGPL.txt coming with the software for details ingo@1115: * or visit http://www.gnu.org/licenses/ if it does not exist. ingo@1115: */ ingo@1115: tim@597: package de.intevation.gnv.artifacts.services.requestobjects; tim@597: tim@597: import java.util.Collection; tim@606: import java.util.Iterator; tim@597: tim@597: /** ingo@792: * The default implementation of Fis. ingo@792: * sascha@780: * @author Tim Englich tim@597: * tim@597: */ tim@597: public class DefaultFIS implements FIS { tim@597: tim@826: /** tim@826: * The ID of the FIS tim@826: */ tim@597: private String id = null; sascha@778: tim@826: /** tim@826: * The Parameter which belongs to the FIS. tim@826: */ tim@597: private Collection parameter = null; tim@597: ingo@792: /** ingo@792: * Constructor sascha@803: * ingo@792: * @param id The id for this fis. ingo@792: */ tim@597: public DefaultFIS(String id){ tim@597: super(); tim@597: this.id = id; tim@597: } tim@597: /** tim@597: * Constructor ingo@792: * @param id The id for this fis. ingo@792: * @param parameter A collection of parameters. tim@597: */ tim@597: public DefaultFIS(String id, Collection parameter) { tim@597: this(id); tim@597: this.parameter = parameter; tim@597: } tim@597: tim@826: tim@597: public String getID() { tim@597: return this.id; tim@597: } tim@597: tim@597: public Collection getParameter() { tim@597: return this.parameter; tim@597: } tim@597: ingo@792: /** ingo@792: * Two objects are equal if they have the same id. ingo@792: * ingo@792: * @param arg0 Object which is checked for equality. ingo@792: * @return True, if both objects are equal, otherwise false. ingo@792: */ tim@597: @Override tim@597: public boolean equals(Object arg0) { tim@597: boolean returnValue = false; tim@597: if (arg0 instanceof FIS){ tim@597: returnValue = this.id.equals(((FIS)arg0).getID()); tim@597: } tim@597: return returnValue; tim@597: } ingo@792: tim@606: /** ingo@792: * Creates a hash code using the id and the given parameters. ingo@792: * ingo@792: * @return A hash code. ingo@792: */ ingo@792: @Override ingo@792: public int hashCode() { ingo@792: int hash = 7; ingo@792: hash = 47 * hash + (this.id != null ? this.id.hashCode() : 0); ingo@792: hash = 47 * hash + (this.parameter != null ? this.parameter.hashCode() : 0); ingo@792: return hash; ingo@792: } tim@826: ingo@792: /** ingo@792: * @param parameter Collection of parameters. tim@606: */ tim@606: public void addParameter(Collection parameter) { tim@606: if (this.parameter != null){ tim@606: Iterator it = parameter.iterator(); tim@606: while (it.hasNext()){ tim@606: Parameter tmpParameter = it.next(); tim@606: if (!this.parameter.contains(tmpParameter)){ tim@606: this.parameter.add(tmpParameter); tim@606: } tim@606: } tim@606: }else{ tim@606: this.parameter = parameter; tim@606: } tim@606: } tim@597: } sascha@836: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :