Permalink
Browse files

Created a constant for the _attachments property name in CouchDbDocum…

…ent and use it in the AttachmentsInOrderParser.
  • Loading branch information...
1 parent 47dfe83 commit c8a40164ed5fb9f433fe3903840938f7147e3e45 @dlvenable dlvenable committed Aug 29, 2012
@@ -20,8 +20,6 @@
*/
public class AttachmentsInOrderParser
{
- private static final String ATTACHMENTS_NAME = "_attachments";
-
/**
* Parses a CouchDB document in the form of a JsonParser to get the
* attachments order. It is important that the JsonParser come straight
@@ -38,7 +36,7 @@
JsonToken jsonToken;
while((jsonToken = documentJsonParser.nextToken()) != JsonToken.END_OBJECT)
{
- if(ATTACHMENTS_NAME.equals(documentJsonParser.getCurrentName()))
+ if(CouchDbDocument.ATTACHMENTS_NAME.equals(documentJsonParser.getCurrentName()))
{
return readAttachments(documentJsonParser);
}
@@ -66,7 +64,7 @@ else if(jsonToken == JsonToken.START_OBJECT)
jsonParser.nextToken();
if(jsonParser.getCurrentToken() != JsonToken.START_OBJECT)
{
- String message = ATTACHMENTS_NAME + " contains an invalid object.";
+ String message = CouchDbDocument.ATTACHMENTS_NAME + " contains an invalid object.";
throw new JsonParseException(message, jsonParser.getCurrentLocation());
}
@@ -17,6 +17,8 @@
@JsonSerialize(include = Inclusion.NON_NULL)
public class CouchDbDocument implements Serializable {
+ public static final String ATTACHMENTS_NAME = "_attachments";
+
private static final long serialVersionUID = 1L;
private String id;
private String revision;
@@ -60,12 +62,12 @@ public boolean isNew() {
return revision == null;
}
- @JsonProperty("_attachments")
+ @JsonProperty(ATTACHMENTS_NAME)
public Map<String, Attachment> getAttachments() {
return attachments;
}
- @JsonProperty("_attachments")
+ @JsonProperty(ATTACHMENTS_NAME)
void setAttachments(Map<String, Attachment> attachments) {
this.attachments = attachments;
}

0 comments on commit c8a4016

Please sign in to comment.