package com.atlassian.bitbucket.rest.content;

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

@JsonSerialize
@JsonSurrogate(Conflict.class)
public class RestConflict extends RestMapEntity {

    public RestConflict(Conflict conflict) {
        put("ourChange", new RestConflictChange(conflict.getOurChange()));
        put("theirChange", new RestConflictChange(conflict.getTheirChange()));
    }

    public static RestConflict fromConflict(Conflict conflict) {
        return conflict == null ? null : new RestConflict(conflict);
    }
}
