From 4b67e2dd6492c14f833d10532de211382dc04efc Mon Sep 17 00:00:00 2001 From: Bartek Nowotarski Date: Fri, 9 Sep 2016 18:30:24 +0200 Subject: [PATCH] AccountFlag --- .../java/org/stellar/sdk/AccountFlag.java | 32 +++++++++++++++++++ .../org/stellar/sdk/SetOptionsOperation.java | 2 ++ .../java/org/stellar/sdk/AccountFlagTest.java | 14 ++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/main/java/org/stellar/sdk/AccountFlag.java create mode 100644 src/test/java/org/stellar/sdk/AccountFlagTest.java diff --git a/src/main/java/org/stellar/sdk/AccountFlag.java b/src/main/java/org/stellar/sdk/AccountFlag.java new file mode 100644 index 000000000..16c941e83 --- /dev/null +++ b/src/main/java/org/stellar/sdk/AccountFlag.java @@ -0,0 +1,32 @@ +package org.stellar.sdk; + +import org.stellar.sdk.xdr.AccountFlags; + +/** + * AccountFlag is the enum that can be used in {@link SetOptionsOperation}. + * @see Account Flags + */ +public enum AccountFlag { + /** + * Authorization required (0x1): Requires the issuing account to give other accounts permission before they can hold the issuing account’s credit. + */ + AUTH_REQUIRED_FLAG(AccountFlags.AUTH_REQUIRED_FLAG.getValue()), + /** + * Authorization revocable (0x2): Allows the issuing account to revoke its credit held by other accounts. + */ + AUTH_REVOCABLE_FLAG(AccountFlags.AUTH_REVOCABLE_FLAG.getValue()), + /** + * Authorization immutable (0x4): If this is set then none of the authorization flags can be set and the account can never be deleted. + */ + AUTH_IMMUTABLE_FLAG(AccountFlags.AUTH_IMMUTABLE_FLAG.getValue()), + ; + + private final int value; + AccountFlag(int value) { + this.value = value; + } + + public int getValue() { + return value; + } +} diff --git a/src/main/java/org/stellar/sdk/SetOptionsOperation.java b/src/main/java/org/stellar/sdk/SetOptionsOperation.java index a58c8c273..0e47baee2 100644 --- a/src/main/java/org/stellar/sdk/SetOptionsOperation.java +++ b/src/main/java/org/stellar/sdk/SetOptionsOperation.java @@ -48,6 +48,7 @@ public KeyPair getInflationDestination() { /** * Indicates which flags to clear. For details about the flags, please refer to the accounts doc. + * You can also use {@link AccountFlag} enum. */ public Integer getClearFlags() { return clearFlags; @@ -55,6 +56,7 @@ public Integer getClearFlags() { /** * Indicates which flags to set. For details about the flags, please refer to the accounts doc. + * You can also use {@link AccountFlag} enum. */ public Integer getSetFlags() { return setFlags; diff --git a/src/test/java/org/stellar/sdk/AccountFlagTest.java b/src/test/java/org/stellar/sdk/AccountFlagTest.java new file mode 100644 index 000000000..5710eac2c --- /dev/null +++ b/src/test/java/org/stellar/sdk/AccountFlagTest.java @@ -0,0 +1,14 @@ +package org.stellar.sdk; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class AccountFlagTest { + @Test + public void testValues() { + assertEquals(1, AccountFlag.AUTH_REQUIRED_FLAG.getValue()); + assertEquals(2, AccountFlag.AUTH_REVOCABLE_FLAG.getValue()); + assertEquals(4, AccountFlag.AUTH_IMMUTABLE_FLAG.getValue()); + } +}