package com.atlassian.bitbucket.rest.task;

import com.atlassian.bitbucket.rest.annotation.JsonSurrogate;
import com.atlassian.bitbucket.rest.RestMapEntity;
import com.atlassian.bitbucket.task.TaskOperations;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import javax.annotation.Nullable;

@JsonSerialize
@JsonSurrogate(TaskOperations.class)
public class RestTaskOperations extends RestMapEntity {

    public static final String EDITABLE = "editable";
    public static final String DELETABLE = "deletable";
    public static final String TRANSITIONABLE = "transitionable";

    @SuppressWarnings("unused") //Required for Jersey
    public RestTaskOperations() {
    }

    public RestTaskOperations(TaskOperations taskOperations) {
        this(taskOperations.isDeletable(), taskOperations.isEditable(), taskOperations.isTransitionable());
    }

    public RestTaskOperations(@Nullable Boolean deletable, @Nullable Boolean editable, @Nullable Boolean transitionable) {
        putIfNotNull(DELETABLE, deletable);
        putIfNotNull(EDITABLE, editable);
        putIfNotNull(TRANSITIONABLE, transitionable);
    }
}
