OSDN Git Service

add Address class to Account class
authorsuccessli <successli@outlook.com>
Wed, 30 May 2018 08:56:22 +0000 (16:56 +0800)
committersuccessli <successli@outlook.com>
Wed, 30 May 2018 08:56:22 +0000 (16:56 +0800)
src/main/java/io/bytom/api/Account.java
src/main/java/io/bytom/api/Address.java [deleted file]
src/test/java/io/bytom/integration/AccountTest.java
src/test/java/io/bytom/integration/AssetTest.java
src/test/java/io/bytom/integration/MessageTest.java

index 943515d..bb141dc 100644 (file)
@@ -198,6 +198,54 @@ public class Account {
     }
 
     /**
+     * Address Class
+     */
+    public static class Address {
+        @SerializedName("account_alias")
+        public String accountAlias;
+
+        @SerializedName("account_id")
+        public String accountId;
+
+        @SerializedName("address")
+        public String address;
+
+        @SerializedName("change")
+        public Boolean change;
+
+        @SerializedName("vaild")
+        public Boolean vaild;
+
+        @SerializedName("is_local")
+        public Boolean is_local;
+
+        /**
+         * Serializes the Address into a form that is safe to transfer over the wire.
+         *
+         * @return the JSON-serialized representation of the Receiver object
+         */
+        public String toJson() {
+            return Utils.serializer.toJson(this);
+        }
+
+        /**
+         * Deserializes a Address from JSON.
+         *
+         * @param json a JSON-serialized Receiver object
+         * @return the deserialized Receiver object
+         * @throws JSONException Raised if the provided string is not valid JSON.
+         */
+        public static Address fromJson(String json) throws JSONException {
+            try {
+                return Utils.serializer.fromJson(json, Address.class);
+            } catch (IllegalStateException e) {
+                throw new JSONException("Unable to parse serialized receiver: " + e.getMessage());
+            }
+        }
+
+    }
+
+    /**
      * Use this class to create a {@link Address} under an account.
      */
     public static class AddressBuilder {
diff --git a/src/main/java/io/bytom/api/Address.java b/src/main/java/io/bytom/api/Address.java
deleted file mode 100644 (file)
index 76fd985..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-package io.bytom.api;
-
-import com.google.gson.annotations.SerializedName;
-import io.bytom.common.Utils;
-import io.bytom.exception.JSONException;
-
-public class Address {
-    @SerializedName("account_alias")
-    public String accountAlias;
-
-    @SerializedName("account_id")
-    public String accountId;
-
-    @SerializedName("address")
-    public String address;
-
-    @SerializedName("change")
-    public Boolean change;
-
-    @SerializedName("vaild")
-    public Boolean vaild;
-
-    @SerializedName("is_local")
-    public Boolean is_local;
-
-    /**
-     * Serializes the Address into a form that is safe to transfer over the wire.
-     *
-     * @return the JSON-serialized representation of the Receiver object
-     */
-    public String toJson() {
-        return Utils.serializer.toJson(this);
-    }
-
-    /**
-     * Deserializes a Address from JSON.
-     *
-     * @param json a JSON-serialized Receiver object
-     * @return the deserialized Receiver object
-     * @throws JSONException Raised if the provided string is not valid JSON.
-     */
-    public static Address fromJson(String json) throws JSONException {
-        try {
-            return Utils.serializer.fromJson(json, Address.class);
-        } catch (IllegalStateException e) {
-            throw new JSONException("Unable to parse serialized receiver: " + e.getMessage());
-        }
-    }
-
-}
index 081106f..d8314f2 100644 (file)
@@ -2,7 +2,6 @@ package io.bytom.integration;
 
 import io.bytom.TestUtils;
 import io.bytom.api.Account;
-import io.bytom.api.Address;
 import io.bytom.api.Receiver;
 import io.bytom.http.Client;
 import org.junit.Test;
@@ -75,7 +74,7 @@ public class AccountTest {
         String id = accountList.get(accountList.size()-1).id;
 
         Account.AddressBuilder addressBuilder = new Account.AddressBuilder().setAccountId(id).setAccountAlias(alias);
-        List<Address> addressList = addressBuilder.list(client);
+        List<Account.Address> addressList = addressBuilder.list(client);
 
         assertNotNull(addressList);
     }
@@ -89,9 +88,9 @@ public class AccountTest {
         String id = accountList.get(accountList.size()-1).id;
 
         Account.AddressBuilder addressBuilder = new Account.AddressBuilder().setAccountId(id).setAccountAlias(alias);
-        List<Address> addressList = addressBuilder.list(client);
+        List<Account.Address> addressList = addressBuilder.list(client);
 
-        Address address = addressBuilder.validate(client, addressList.get(0).address);
+        Account.Address address = addressBuilder.validate(client, addressList.get(0).address);
         assertEquals(true, address.is_local);
     }
 
index a35a0a6..2971275 100644 (file)
@@ -2,13 +2,10 @@ package io.bytom.integration;
 
 import io.bytom.TestUtils;
 import io.bytom.api.Account;
-import io.bytom.api.Address;
 import io.bytom.api.Asset;
-import io.bytom.api.Receiver;
 import io.bytom.http.Client;
 import org.junit.Test;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import static org.junit.Assert.assertEquals;
index 8f30c6e..bd7fc1f 100644 (file)
@@ -1,17 +1,12 @@
 package io.bytom.integration;
 
 import io.bytom.TestUtils;
-import io.bytom.api.Account;
-import io.bytom.api.Address;
 import io.bytom.api.Message;
-import io.bytom.api.Wallet;
 import io.bytom.exception.BytomException;
 import io.bytom.http.Client;
 import org.junit.Assert;
 import org.junit.Test;
 
-import java.util.List;
-
 public class MessageTest {
 
     static Client client;