// Copyright © WireMock.Net
using System;
using System.Collections.Generic;
namespace WireMock.Models;
///
/// A structure defining an (optional) Id and a Text.
///
public readonly struct IdOrTexts
{
///
/// The Id [optional].
///
public string? Id { get; }
///
/// The Text.
///
public IReadOnlyList Texts { get; }
///
/// Create a IdOrText
///
/// The Id [optional]
/// The Text.
public IdOrTexts(string? id, string text) : this(id, [text])
{
}
///
/// Create a IdOrText
///
/// The Id [optional]
/// The Texts.
public IdOrTexts(string? id, IReadOnlyList texts)
{
Id = id;
Texts = texts;
}
///
/// When Id is defined, return process the Id, else process the Texts.
///
/// Callback to process the id.
/// Callback to process the texts.
public void Value(Action id, Action> texts)
{
if (Id != null)
{
id(Id);
}
else
{
texts(Texts);
}
}
}