package com.atlassian.bitbucket.internal.defaultreviewers.dao;

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.AutoIncrement;
import net.java.ao.schema.NotNull;
import net.java.ao.schema.PrimaryKey;
import net.java.ao.schema.Table;

import javax.annotation.Nullable;

@Table("DEFAULT_REVIEWER")
@Preload
public interface AoReviewer extends RawEntity<Integer> {
    String ID_COLUMN = "ENTITY_ID";
    String CONDITION_ACCESSOR_VALUE = "FK_RESTRICTED_";
    String CONDITION_COLUMN = CONDITION_ACCESSOR_VALUE + "ID";
    String USER_ID_COLUMN = "USER_ID";

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

    @NotNull
    @Accessor(CONDITION_ACCESSOR_VALUE)
    AoPullRequestCondition getCondition();

    @Mutator(CONDITION_ACCESSOR_VALUE)
    void setCondition(AoPullRequestCondition restriction);

    /**
     * @return the user the permission was granted to. Can be null.
     */
    @Accessor(USER_ID_COLUMN)
    @Nullable
    Integer getUserId();
}
