001package org.nuxeo.box.api.marshalling.dao;
002
003import com.fasterxml.jackson.annotation.JsonProperty;
004import com.fasterxml.jackson.annotation.JsonTypeInfo;
005
006import java.util.Map;
007
008/**
009 * Comment.
010 */
011@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", defaultImpl = BoxComment.class)
012public class BoxComment extends BoxTypedObject {
013
014    public static final String FIELD_IS_REPLY_COMMENT = "is_reply_comment";
015
016    public static final String FIELD_MESSAGE = "message";
017
018    public static final String FIELD_CREATED_BY = "created_by";
019
020    public static final String FIELD_ITEM = "item";
021
022    /**
023     * Constructor.
024     */
025    public BoxComment() {
026        setType(BoxResourceType.COMMENT.toString());
027    }
028
029    /**
030     * Copy constructor, this does deep copy for all the fields.
031     *
032     * @param obj
033     */
034    public BoxComment(BoxComment obj) {
035        super(obj);
036    }
037
038    /**
039     * Instantiate the object from a map. Each entry in the map reflects to a field.
040     *
041     * @param map
042     */
043    public BoxComment(Map<String, Object> map) {
044        super(map);
045    }
046
047    /**
048     * Whether this is a comment replying another comment.
049     *
050     * @return Whether this is a comment replying another comment.
051     */
052    @JsonProperty(FIELD_IS_REPLY_COMMENT)
053    public Boolean isReplyComment() {
054        return (Boolean) getValue(FIELD_IS_REPLY_COMMENT);
055    }
056
057    /**
058     * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>}
059     *
060     * @param isReplyComment whether it's reply comment
061     */
062    @JsonProperty(FIELD_IS_REPLY_COMMENT)
063    private void setIsReplyComment(Boolean isReplyComment) {
064        put(FIELD_IS_REPLY_COMMENT, isReplyComment);
065    }
066
067    /**
068     * Get the comment String.
069     *
070     * @return The comment String.
071     */
072    @JsonProperty(FIELD_MESSAGE)
073    public String getMessage() {
074        return (String) getValue(FIELD_MESSAGE);
075    }
076
077    /**
078     * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>}
079     *
080     * @param message the comment String.
081     */
082    @JsonProperty(FIELD_MESSAGE)
083    private void setMessage(String message) {
084        put(FIELD_MESSAGE, message);
085    }
086
087    /**
088     * Get the user creating this comment.
089     *
090     * @return the user creating this comment
091     */
092    @JsonProperty(FIELD_CREATED_BY)
093    public BoxUser getCreatedBy() {
094        return (BoxUser) getValue(FIELD_CREATED_BY);
095    }
096
097    /**
098     * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>}
099     *
100     * @param createdBy user creating this comment
101     */
102    @JsonProperty(FIELD_CREATED_BY)
103    private void setCreatedBy(BoxUser createdBy) {
104        put(FIELD_CREATED_BY, createdBy);
105    }
106
107    /**
108     * Get the object being commented.
109     *
110     * @return the object being commented
111     */
112    @JsonProperty(FIELD_ITEM)
113    public BoxTypedObject getItem() {
114        return (BoxTypedObject) getValue(FIELD_ITEM);
115    }
116
117    /**
118     * Setter. This is only used by {@see <a href="http://jackson.codehaus .org">Jackson JSON processer</a>}
119     *
120     * @param item the object commented
121     */
122    @JsonProperty(FIELD_ITEM)
123    private void setItem(BoxTypedObject item) {
124        put(FIELD_ITEM, item);
125    }
126}