@@ -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}
0 commit comments