Skip to content

Commit 30af890

Browse files
committed
adding the suggestions.
1 parent 2eae18b commit 30af890

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

marklogic-client-api/src/main/java/com/marklogic/client/impl/DocumentWriteOperationImpl.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,23 @@ public class DocumentWriteOperationImpl implements DocumentWriteOperation,Compar
3030
public DocumentWriteOperationImpl(OperationType type, String uri,
3131
DocumentMetadataWriteHandle metadata, AbstractWriteHandle content)
3232
{
33-
this(uri, type, metadata, content);
34-
this.temporalDocumentURI = null;
33+
this(type, uri, metadata, content, null);
3534
}
3635

3736
public DocumentWriteOperationImpl(OperationType type, String uri,
3837
DocumentMetadataWriteHandle metadata, AbstractWriteHandle content, String temporalDocumentURI) {
39-
this(uri,type,metadata, content);
40-
this.temporalDocumentURI = temporalDocumentURI;
41-
}
42-
43-
private DocumentWriteOperationImpl(String uri, OperationType type,
44-
DocumentMetadataWriteHandle metadata, AbstractWriteHandle content) {
45-
46-
4738
if(type == OperationType.DOCUMENT_WRITE && uri == null) {
4839
throw new IllegalArgumentException("Uri cannot be null when Operation Type is DOCUMENT_WRITE.");
4940
}
50-
if(!(type == OperationType.DOCUMENT_WRITE) && uri != null) {
41+
if(type != OperationType.DOCUMENT_WRITE && uri != null) {
5142
throw new IllegalArgumentException("Operation Type should be DOCUMENT_WRITE when uri is not null");
5243
}
5344

5445
this.operationType = type;
5546
this.uri = uri;
5647
this.metadata = metadata;
5748
this.content = content;
49+
this.temporalDocumentURI = temporalDocumentURI;
5850
}
5951

6052
@Override
@@ -87,17 +79,23 @@ public int compareTo(DocumentWriteOperation o) {
8779
if(o == null)
8880
throw new NullPointerException("DocumentWriteOperation cannot be null");
8981

90-
if(this.getUri() instanceof String && o.getUri() instanceof String)
82+
if(this.getUri() != null && o.getUri() != null)
9183
return getUri().compareTo(o.getUri());
9284

93-
if(this.getUri() == null && o.getUri() instanceof String)
85+
if(this.getUri() == null && o.getUri() != null)
9486
return -1;
9587

96-
if(this.getUri() instanceof String && o.getUri()==null)
88+
if(this.getUri() != null && o.getUri()==null)
9789
return 1;
9890

9991
if(this.getUri() == null && o.getUri() == null)
100-
super.hashCode();
92+
{
93+
if(this.hashCode() > o.hashCode())
94+
return 1;
95+
else if (this.hashCode() < o.hashCode())
96+
return -1;
97+
return 0;
98+
}
10199
return 0;
102100
}
103101

@@ -110,8 +108,10 @@ public int hashCode() {
110108

111109
@Override
112110
public boolean equals(Object o){
113-
if(this.getUri()!=null)
114-
return this.getUri().equals(o);
115-
return super.equals(o);
111+
if(!(o instanceof DocumentWriteOperation))
112+
return false;
113+
if(this.getUri() == null)
114+
return super.equals(o);
115+
return this.getUri().equals(((DocumentWriteOperation) o).getUri());
116116
}
117117
}

marklogic-client-api/src/main/java/com/marklogic/client/impl/DocumentWriteSetImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ public <T> T[] toArray(T[] a) {
174174

175175
@Override
176176
public boolean add(DocumentWriteOperation documentWriteOperation) {
177-
System.out.println(operations);
178177
return operations.add(documentWriteOperation);
179178
}
180179

0 commit comments

Comments
 (0)