// Copyright (C) Stichting Deltares 2023. All rights reserved.
//
// This file is part of the application DAM - UI.
//
// DAM - UI 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.Collections.Generic;
using Deltares.Geotechnics.Soils;
using Deltares.Geotechnics.SurfaceLines;
using Deltares.Standard.Extensions;
namespace Deltares.Dam.Data;
public class EntityFactory
{
#region Private lookup tables (lists)
///
/// Holds a reference to the (concrete) Location list
///
private readonly IList locations = new List();
///
/// Holds a reference to the (concrete) Segment list
///
private readonly IList segments = new List();
///
/// Holds a reference to the (concrete) SoilProfile list
///
private readonly IList soilProfiles = new List();
///
/// Holds a reference to the (concrete) SurfaceLine list
///
private readonly IList surfaceLines = new List();
///
/// Holds a reference to the (concrete) pl1Line list
///
private readonly IList pl1Lines = new List();
private readonly IList gauges = new List();
#endregion
#region Constructors
public EntityFactory()
: this(null, null, null, null, null, null) {}
///
///
///
/// The surface lines look up table
public EntityFactory(IEnumerable surfaceLines)
: this(null, null, null, surfaceLines, null, null) {}
///
///
///
/// The segment look up table
/// The surface lines look up table
public EntityFactory(IEnumerable segments, IEnumerable surfaceLines)
: this(null, null, segments, surfaceLines, null, null) {}
///
///
///
/// A soil profiles
/// The location look up table
/// The segment look up table
public EntityFactory(IEnumerable locations, IEnumerable soilProfiles, IEnumerable segments)
: this(locations, soilProfiles, segments, null, null, null) {}
///
///
///
/// A soil profiles
/// The location look up table
/// The segment look up table
/// The surface lines look up table
/// The pl1Lines look up table
/// The gauges look up table
public EntityFactory(IEnumerable locations, IEnumerable soilProfiles, IEnumerable segments, IEnumerable surfaceLines,
IEnumerable pl1Lines, IEnumerable gauges)
{
if (soilProfiles != null)
{
this.soilProfiles = soilProfiles as IList;
if (this.soilProfiles == null)
{
this.soilProfiles = new List();
this.soilProfiles.AddRangeLeavingNullElementsOut(soilProfiles);
}
else
{
this.soilProfiles.RemoveNullElements();
}
}
if (segments != null)
{
this.segments = segments as IList;
if (this.segments == null)
{
this.segments = new List();
this.segments.AddRangeLeavingNullElementsOut(segments);
}
else
{
this.segments.RemoveNullElements();
}
}
if (locations != null)
{
this.locations = locations as IList;
if (this.locations == null)
{
this.locations = new List();
this.locations.AddRangeLeavingNullElementsOut(locations);
}
else
{
this.locations.RemoveNullElements();
}
}
if (surfaceLines != null)
{
this.surfaceLines = surfaceLines as IList;
if (this.surfaceLines == null)
{
this.surfaceLines = new List();
this.surfaceLines.AddRangeLeavingNullElementsOut(surfaceLines);
}
else
{
this.surfaceLines.RemoveNullElements();
}
}
if (pl1Lines != null)
{
this.pl1Lines = pl1Lines as IList;
if (this.pl1Lines == null)
{
this.pl1Lines = new List();
this.pl1Lines.AddRangeLeavingNullElementsOut(pl1Lines);
}
else
{
this.pl1Lines.RemoveNullElements();
}
}
if (gauges != null)
{
this.gauges = gauges as IList;
if (this.gauges == null)
{
this.gauges = new List();
this.gauges.AddRangeLeavingNullElementsOut(gauges);
}
else
{
this.gauges.RemoveNullElements();
}
}
}
#endregion
}