using System.Linq.Expressions;
using ZB.MOM.WW.CBDD.Core.Indexing;

namespace ZB.MOM.WW.CBDD.Core.Metadata;

public class ModelBuilder
{
    private readonly Dictionary<Type, object> _entityBuilders = new();

    /// <summary>
    /// Gets or creates the entity builder for the specified entity type.
    /// </summary>
    /// <typeparam name="T">The entity type.</typeparam>
    /// <returns>The entity builder for <typeparamref name="T"/>.</returns>
    public EntityTypeBuilder<T> Entity<T>() where T : class
    {
        if (!_entityBuilders.TryGetValue(typeof(T), out var builder))
        {
            builder = new EntityTypeBuilder<T>();
            _entityBuilders[typeof(T)] = builder;
        }
        return (EntityTypeBuilder<T>)builder;
    }

    /// <summary>
    /// Gets all registered entity builders.
    /// </summary>
    /// <returns>A read-only dictionary of entity builders keyed by entity type.</returns>
    public IReadOnlyDictionary<Type, object> GetEntityBuilders() => _entityBuilders;
}
