// Copyright (C) Stichting Deltares 2017. All rights reserved.
//
// This file is part of Ringtoets.
//
// Ringtoets is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System;
using Core.Common.Base;
using Core.Common.Base.Data;
using Ringtoets.Common.Data.Probability;
using Ringtoets.Piping.Data.Properties;
using Ringtoets.Piping.Primitives;
namespace Ringtoets.Piping.Data.SoilProfile
{
///
/// This class couples a to a probability of occurrence.
///
public class PipingStochasticSoilProfile : Observable
{
private double probability;
///
/// Creates a new instance of .
///
/// Probability of the stochastic soil profile.
/// The soil profile.
/// Thrown when is null.
/// Thrown when the
/// is outside the range [0, 1].
public PipingStochasticSoilProfile(double probability, PipingSoilProfile soilProfile)
{
if (soilProfile == null)
{
throw new ArgumentNullException(nameof(soilProfile));
}
Probability = probability;
SoilProfile = soilProfile;
}
///
/// Gets the probability of the stochastic soil profile.
///
/// Thrown when the is outside the range
/// [0, 1].
public double Probability
{
get
{
return probability;
}
private set
{
ProbabilityHelper.ValidateProbability(
value,
nameof(value),
Resources.StochasticSoilProfile_Probability_Should_be_in_range_0_);
probability = value;
}
}
///
/// Gets the .
///
public PipingSoilProfile SoilProfile { get; private set; }
///
/// Updates the with the properties
/// from .
///
/// The to
/// obtain the property values from.
/// Thrown when
/// is null.
public void Update(PipingStochasticSoilProfile fromProfile)
{
if (fromProfile == null)
{
throw new ArgumentNullException(nameof(fromProfile));
}
SoilProfile = fromProfile.SoilProfile;
Probability = fromProfile.Probability;
}
public override string ToString()
{
return SoilProfile.ToString();
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
if (obj.GetType() != GetType())
{
return false;
}
var other = obj as PipingStochasticSoilProfile;
return other != null && Equals(other);
}
public override int GetHashCode()
{
unchecked
{
int hashCode = Probability.GetHashCode();
hashCode = (hashCode * 397) ^ (SoilProfile?.GetHashCode() ?? 0);
return hashCode;
}
}
private bool Equals(PipingStochasticSoilProfile other)
{
return Probability.Equals(other.Probability)
&& Equals(SoilProfile, other.SoilProfile);
}
}
}