You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bs...@apache.org on 2018/01/22 16:33:24 UTC

[geode] branch feature/GEODE-4315 created (now 6af6170)

This is an automated email from the ASF dual-hosted git repository.

bschuchardt pushed a change to branch feature/GEODE-4315
in repository https://gitbox.apache.org/repos/asf/geode.git.


      at 6af6170  GEODE-4315 Convert JSONWrapper to an interface

This branch includes the following new commits:

     new 6af6170  GEODE-4315 Convert JSONWrapper to an interface

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
bschuchardt@apache.org.

[geode] 01/01: GEODE-4315 Convert JSONWrapper to an interface

Posted by bs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bschuchardt pushed a commit to branch feature/GEODE-4315
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 6af617091b7e3da1bf1813e33b5c40f1806cd8b6
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Fri Jan 19 15:09:41 2018 -0800

    GEODE-4315 Convert JSONWrapper to an interface
    
    JSONWrapper is now an interface.  JSONWrapperImpl is what will be returned
    by the experimental driver but it will accept anything implementing
    JSONWrapper as input.
---
 .../geode/experimental/driver/JSONWrapper.java     | 59 ++++++++++++----------
 .../geode/experimental/driver/ValueEncoder.java    |  2 +-
 2 files changed, 34 insertions(+), 27 deletions(-)

diff --git a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/JSONWrapper.java b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/JSONWrapper.java
index 8a88c3d..79527fe 100644
--- a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/JSONWrapper.java
+++ b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/JSONWrapper.java
@@ -33,44 +33,51 @@ import org.apache.geode.annotations.Experimental;
  *
  */
 @Experimental
-public class JSONWrapper implements Comparable<JSONWrapper> {
-
-  protected final String jsonDocument;
+public interface JSONWrapper extends Comparable<JSONWrapper> {
 
   public static JSONWrapper wrapJSON(String jsonDocument) {
     if (jsonDocument == null) {
       throw new IllegalArgumentException("wrapped document may not be null");
     }
-    return new JSONWrapper(jsonDocument);
+    return new JSONWrapperImpl(jsonDocument);
   }
 
-  private JSONWrapper(String jsonDocument) {
-    this.jsonDocument = jsonDocument;
-  }
+  public String getJSON();
 
-  public String getJSON() {
-    return jsonDocument;
-  }
 
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) {
-      return true;
+  static class JSONWrapperImpl implements JSONWrapper {
+
+
+    protected final String jsonDocument;
+
+    private JSONWrapperImpl(String jsonDocument) {
+      this.jsonDocument = jsonDocument;
     }
-    if (!(o instanceof JSONWrapper)) {
-      return false;
+
+    public String getJSON() {
+      return jsonDocument;
     }
-    JSONWrapper that = (JSONWrapper) o;
-    return jsonDocument.equals(that.jsonDocument);
-  }
 
-  @Override
-  public int hashCode() {
-    return Objects.hash(jsonDocument);
-  }
+    @Override
+    public boolean equals(Object o) {
+      if (this == o) {
+        return true;
+      }
+      if (!(o instanceof JSONWrapper)) {
+        return false;
+      }
+      JSONWrapper that = (JSONWrapper) o;
+      return jsonDocument.equals(that.getJSON());
+    }
 
-  @Override
-  public int compareTo(JSONWrapper o) {
-    return jsonDocument.compareTo(o.jsonDocument);
+    @Override
+    public int hashCode() {
+      return Objects.hash(jsonDocument);
+    }
+
+    @Override
+    public int compareTo(JSONWrapper o) {
+      return jsonDocument.compareTo(o.getJSON());
+    }
   }
 }
diff --git a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ValueEncoder.java b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ValueEncoder.java
index 7912373..9c9b656 100644
--- a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ValueEncoder.java
+++ b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ValueEncoder.java
@@ -53,7 +53,7 @@ class ValueEncoder {
       builder.setBooleanResult((Boolean) unencodedValue);
     } else if (String.class.equals(unencodedValue.getClass())) {
       builder.setStringResult((String) unencodedValue);
-    } else if (JSONWrapper.class == unencodedValue.getClass()) {
+    } else if (JSONWrapper.class.isAssignableFrom(unencodedValue.getClass())) {
       builder.setJsonObjectResult(((JSONWrapper) unencodedValue).getJSON());
     } else {
       throw new IllegalStateException("We don't know how to handle an object of type "

-- 
To stop receiving notification emails like this one, please contact
bschuchardt@apache.org.