﻿using System;

namespace Carbon.Data.Annotations
{
    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class KeyAttribute : Attribute
    {
        public KeyAttribute() { }

        public KeyAttribute(bool isIdentity)
        {
            if (isIdentity)
            {
                GeneratorType = ValueGeneratorType.Identity;
            }
        }

        public KeyAttribute(string sequenceName, long seed = 1, int increment = 1, int cacheSize = 1)
        {
            GeneratorType = ValueGeneratorType.Sequence;
            SequenceName  = sequenceName;
            Seed          = seed;
            Increment     = increment;
            CacheSize     = cacheSize;
        }

        public string SequenceName { get; }

        public long Seed { get; } = 1;

        public int Increment { get; } = 1;

        public int CacheSize { get; } = 1;

        public ValueGeneratorType GeneratorType { get; }
    }
}