teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.artifacts.model.sq; ingo@3079: ingo@3079: import java.io.Serializable; ingo@3079: andre@8539: import java.util.Date; andre@8539: ingo@3079: teichmann@6780: /** Represents S/Q pairs. They are immutable! */ ingo@3079: public class SQ implements Serializable { ingo@3079: teichmann@6780: public interface Factory { andre@8539: SQ createSQ(double s, double q, Date d); teichmann@6780: } teichmann@6780: teichmann@6780: public static final Factory SQ_FACTORY = new Factory() { teichmann@6780: @Override andre@8539: public SQ createSQ(double s, double q, Date d) { andre@8539: return new SQ(s, q, d); teichmann@6780: } teichmann@6780: }; teichmann@6780: teichmann@6780: public interface View { teichmann@6780: double getS(SQ sq); teichmann@6780: double getQ(SQ sq); andre@8539: Date getDate(SQ sq); teichmann@6780: } teichmann@6780: teichmann@6780: public static final View SQ_VIEW = new View() { teichmann@6780: @Override teichmann@6780: public double getS(SQ sq) { teichmann@6780: return sq.getS(); teichmann@6780: } teichmann@6780: teichmann@6780: @Override teichmann@6780: public double getQ(SQ sq) { teichmann@6780: return sq.getQ(); teichmann@6780: } andre@8539: andre@8539: @Override andre@8539: public Date getDate(SQ sq) { andre@8539: return sq.getDate(); andre@8539: } teichmann@6780: }; teichmann@6780: ingo@3079: protected double s; ingo@3079: protected double q; andre@8539: protected Date d; ingo@3079: ingo@3079: public SQ() { ingo@3079: } ingo@3079: andre@8539: public SQ(double s, double q, Date d) { ingo@3079: this.s = s; ingo@3079: this.q = q; andre@8539: this.d = d; ingo@3079: } ingo@3079: ingo@3079: ingo@3079: public double getS() { ingo@3079: return s; ingo@3079: } ingo@3079: ingo@3079: public double getQ() { ingo@3079: return q; ingo@3079: } ingo@3079: andre@8539: public Date getDate() { andre@8539: return d; andre@8539: } andre@8539: sascha@3188: public boolean isValid() { sascha@3188: return !Double.isNaN(s) && !Double.isNaN(q); sascha@3188: } ingo@3079: } ingo@3079: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :