package com.atlassian.stash.internal.repository.ref.restriction.dao.v0;

import com.atlassian.bitbucket.repository.Repository;
import net.java.ao.Accessor;
import net.java.ao.Mutator;
import net.java.ao.Preload;
import net.java.ao.RawEntity;
import net.java.ao.schema.*;

@Table("RESTRICTED_REF")
@Preload
public interface AoRestrictedRefV0 extends RawEntity<Integer> {
    String ID_COLUMN = "REF_ID";
    String REPOSITORY_ID_COLUMN = "REPOSITORY_ID";
    String TYPE_COLUMN = "REF_TYPE";
    String VALUE_COLUMN = "REF_VALUE";
    int MAX_REF_VALUE_LENGTH = StringLength.MAX_LENGTH;

    @AutoIncrement
    @NotNull
    @PrimaryKey(ID_COLUMN)
    Integer getId();

    /**
     * @return the id of the {@link Repository repository} containing the {@link #getValue branch} the permission
     * was granted on.
     */
    @NotNull
    @Accessor(REPOSITORY_ID_COLUMN)
    @Indexed
    Integer getRepositoryId();

    @NotNull
    @Accessor(TYPE_COLUMN)
    @Indexed
    String getType();

    /**
     * @return the value of the restriction. Either the fully qualified branch name or a regular expression
     */
    @NotNull
    @Accessor(VALUE_COLUMN)
    @Indexed
    @StringLength(MAX_REF_VALUE_LENGTH)
    String getValue();

    @Mutator(VALUE_COLUMN)
    void setValue(String value);
}
