package com.atlassian.bitbucket.comment;

import com.atlassian.bitbucket.property.PropertySupport;
import com.atlassian.bitbucket.task.Task;
import com.atlassian.bitbucket.task.TaskAnchor;
import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.bitbucket.validation.annotation.RequiredString;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Date;
import java.util.List;
import java.util.function.Function;

/**
 * A comment on a pull request or commit.
 */
public interface Comment extends PropertySupport, TaskAnchor {

    /**
     * @deprecated in 4.0 for removal in 5.0. With Java 8, {@code Comment::getId} can be used instead.
     */
    @Deprecated
    Function<Comment, Long> TO_ID = Comment::getId;

    /**
     * @return the author of the comment
     */
    @Nonnull
    ApplicationUser getAuthor();

    /**
     * @return the direct replies to the comment, or an empty list of there are none
     */
    @Nonnull
    List<Comment> getComments();

    /**
     * @return the date when the comment was originally created
     * @see #getUpdatedDate()
     */
    @Nonnull
    Date getCreatedDate();

    /**
     * @return the comment's ID, which is globally unique
     */
    long getId();

    /**
     * @return the tasks attached to this comment, or an empty list if there are none
     */
    @Nonnull
    List<Task> getTasks();

    /**
     * @return the raw text of the comment (limited to 32k)
     */
    @Nonnull
    @RequiredString(size = 32768) //32k
    String getText();

    /**
     * @return the date of the last update
     * @see #getCreatedDate()
     */
    @Nonnull
    Date getUpdatedDate();

    /**
     * @return the current version of the comment
     * @see #getUpdatedDate()
     */
    int getVersion();

    /**
     * @return the operations allowed by the current user or {@code null} if none are permitted
     */
    @Nullable
    CommentOperations getPermittedOperations();
}
