Asset.Builder utilizes the builder pattern to create Asset objects. The following attributes are required to be set: #rootXpubs, #quorum.
| 173 | * The following attributes are required to be set: {@link #rootXpubs}, {@link #quorum}. |
| 174 | */ |
| 175 | public static class Builder { |
| 176 | /** |
| 177 | * User specified, unique identifier. |
| 178 | */ |
| 179 | public String alias; |
| 180 | |
| 181 | /** |
| 182 | * User-specified, arbitrary/unstructured data visible across blockchain networks.<br> |
| 183 | * Version 1 assets specify the definition in their issuance programs, rendering the definition immutable. |
| 184 | */ |
| 185 | public Map<String, Object> definition; |
| 186 | |
| 187 | /** |
| 188 | * User-specified, arbitrary/unstructured data local to the asset's originating core. |
| 189 | */ |
| 190 | public Map<String, Object> tags; |
| 191 | |
| 192 | /** |
| 193 | * The list of keys used to create the issuance program for the asset.<br> |
| 194 | * Signatures from these keys are required for issuing units of the asset.<br> |
| 195 | * <strong>Must set with {@link #addRootXpub(String)} or {@link #setRootXpubs(List)} before calling {@link #create(Client)}.</strong> |
| 196 | */ |
| 197 | @SerializedName("root_xpubs") |
| 198 | public List<String> rootXpubs; |
| 199 | |
| 200 | /** |
| 201 | * The number of keys required to sign an issuance of the asset.<br> |
| 202 | * <strong>Must set with {@link #setQuorum(int)} before calling {@link #create(Client)}.</strong> |
| 203 | */ |
| 204 | public int quorum; |
| 205 | |
| 206 | /** |
| 207 | * Unique identifier used for request idempotence. |
| 208 | */ |
| 209 | @SerializedName("client_token") |
| 210 | private String clientToken; |
| 211 | |
| 212 | /** |
| 213 | * Default constructor initializes the list of keys. |
| 214 | */ |
| 215 | public Builder() { |
| 216 | this.rootXpubs = new ArrayList<>(); |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Creates an asset object. |
| 221 | * @param client client object that makes request to the core |
| 222 | * @return an asset object |
| 223 | * @throws APIException This exception is raised if the api returns errors while creating the asset. |
| 224 | * @throws BadURLException This exception wraps java.net.MalformedURLException. |
| 225 | * @throws ConnectivityException This exception is raised if there are connectivity issues with the server. |
| 226 | * @throws HTTPException This exception is raised when errors occur making http requests. |
| 227 | * @throws JSONException This exception is raised due to malformed json requests or responses. |
| 228 | */ |
| 229 | public Asset create(Client client) throws ChainException { |
| 230 | return client.singletonBatchRequest( |
| 231 | "create-asset", Arrays.asList(this), Asset.class, APIException.class); |
| 232 | } |
nothing calls this directly
no outgoing calls
no test coverage detected