001/* Copyright (C) 2013 TU Dortmund
002 * This file is part of AutomataLib, http://www.automatalib.net/.
003 * 
004 * AutomataLib is free software; you can redistribute it and/or
005 * modify it under the terms of the GNU Lesser General Public
006 * License version 3.0 as published by the Free Software Foundation.
007 * 
008 * AutomataLib is distributed in the hope that it will be useful,
009 * but WITHOUT ANY WARRANTY; without even the implied warranty of
010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
011 * Lesser General Public License for more details.
012 * 
013 * You should have received a copy of the GNU Lesser General Public
014 * License along with AutomataLib; if not, see
015 * http://www.gnu.de/documents/lgpl.en.html.
016 */
017package net.automatalib.automata.transout.probabilistic;
018
019import java.util.Objects;
020
021public final class ProbabilisticOutput<O> {
022        
023        private final float probability;
024        private final O output;
025
026        public ProbabilisticOutput(float probability, O output) {
027                this.probability = probability;
028                this.output = output;
029        }
030        
031        public float getProbability() {
032                return probability;
033        }
034        
035        public O getOutput() {
036                return output;
037        }
038
039        /* (non-Javadoc)
040         * @see java.lang.Object#hashCode()
041         */
042        @Override
043        public int hashCode() {
044                final int prime = 31;
045                int result = 1;
046                result = prime * result + Objects.hashCode(output);
047                result = prime * result + Float.floatToIntBits(probability);
048                return result;
049        }
050
051        /* (non-Javadoc)
052         * @see java.lang.Object#equals(java.lang.Object)
053         */
054        @Override
055        public boolean equals(Object obj) {
056                if (this == obj)
057                        return true;
058                if (obj == null)
059                        return false;
060                if (obj.getClass() != ProbabilisticOutput.class)
061                        return false;
062                ProbabilisticOutput<?> other = (ProbabilisticOutput<?>)obj;
063                if(!Objects.equals(output, other.output))
064                        return false;
065                return (probability == other.probability);
066        }
067        
068        
069
070}