diff --git a/docs/release-notes.html b/docs/release-notes.html index 120ece2aa..4a06bba04 100644 --- a/docs/release-notes.html +++ b/docs/release-notes.html @@ -45,6 +45,12 @@

Version 7.0.2



+
  • + Added a SubtreeAccessibilityState.isMoreRestrictiveThan method that can be used + to determine whether one state is more restrictive than another. +

    +
  • +
  • Updated the documentation to include the latest revisions of draft-coretta-ldap-subnf-01, draft-coretta-oiddir-radit, diff --git a/src/com/unboundid/ldap/sdk/unboundidds/extensions/SubtreeAccessibilityState.java b/src/com/unboundid/ldap/sdk/unboundidds/extensions/SubtreeAccessibilityState.java index 2ad8b95fe..2d85007bd 100644 --- a/src/com/unboundid/ldap/sdk/unboundidds/extensions/SubtreeAccessibilityState.java +++ b/src/com/unboundid/ldap/sdk/unboundidds/extensions/SubtreeAccessibilityState.java @@ -219,6 +219,56 @@ public boolean isToBeDeleted() + /** + * Indicates whether this subtree accessibility state is considered more + * restrictive than the provided state. States will be considered in the + * following descending order of restrictiveness: + *
      + *
    1. {@code TO_BE_DELETED}
    2. + *
    3. {@code HIDDEN}
    4. + *
    5. {@code READ_ONLY_BIND_DENIED}
    6. + *
    7. {@code READ_ONLY_BIND_ALLOWED}
    8. + *
    9. {@code ACCESSIBLE}
    10. + *
    + * + * @param state The accessibility state to compare against this one. It + * must not be {@code null}. + * + * @return {@code true} if this state is more restrictive than the provided + * state, or {@code false} if this state is the same as or less + * restrictive than the provided state. + */ + public boolean isMoreRestrictiveThan( + @NotNull final SubtreeAccessibilityState state) + { + switch (this) + { + case TO_BE_DELETED: + return (state != SubtreeAccessibilityState.TO_BE_DELETED); + + case HIDDEN: + return ((state != SubtreeAccessibilityState.TO_BE_DELETED) && + (state != SubtreeAccessibilityState.HIDDEN)); + + case READ_ONLY_BIND_DENIED: + return ((state != SubtreeAccessibilityState.TO_BE_DELETED) && + (state != SubtreeAccessibilityState.HIDDEN) && + (state != SubtreeAccessibilityState.READ_ONLY_BIND_DENIED)); + + case READ_ONLY_BIND_ALLOWED: + return ((state != SubtreeAccessibilityState.TO_BE_DELETED) && + (state != SubtreeAccessibilityState.HIDDEN) && + (state != SubtreeAccessibilityState.READ_ONLY_BIND_DENIED) && + (state != SubtreeAccessibilityState.READ_ONLY_BIND_ALLOWED)); + + case ACCESSIBLE: + default: + return false; + } + } + + + /** * Retrieves the subtree accessibility state with the specified integer value. * diff --git a/tests/unit/src/com/unboundid/ldap/sdk/unboundidds/extensions/SubtreeAccessibilityStateTestCase.java b/tests/unit/src/com/unboundid/ldap/sdk/unboundidds/extensions/SubtreeAccessibilityStateTestCase.java index 241d7aeed..03b23355a 100644 --- a/tests/unit/src/com/unboundid/ldap/sdk/unboundidds/extensions/SubtreeAccessibilityStateTestCase.java +++ b/tests/unit/src/com/unboundid/ldap/sdk/unboundidds/extensions/SubtreeAccessibilityStateTestCase.java @@ -195,6 +195,83 @@ public void testIsStateMethods() + /** + * Tests the behavior of the {@code isMoreRestrictiveThan} method. + * + * @throws Exception If an unexpected problem occurs. + */ + @Test() + public void testIsMoreRestrictiveThan() + throws Exception + { + assertFalse(SubtreeAccessibilityState.TO_BE_DELETED.isMoreRestrictiveThan( + SubtreeAccessibilityState.TO_BE_DELETED)); + assertTrue(SubtreeAccessibilityState.TO_BE_DELETED.isMoreRestrictiveThan( + SubtreeAccessibilityState.HIDDEN)); + assertTrue(SubtreeAccessibilityState.TO_BE_DELETED.isMoreRestrictiveThan( + SubtreeAccessibilityState.READ_ONLY_BIND_DENIED)); + assertTrue(SubtreeAccessibilityState.TO_BE_DELETED.isMoreRestrictiveThan( + SubtreeAccessibilityState.READ_ONLY_BIND_ALLOWED)); + assertTrue(SubtreeAccessibilityState.TO_BE_DELETED.isMoreRestrictiveThan( + SubtreeAccessibilityState.ACCESSIBLE)); + + assertFalse(SubtreeAccessibilityState.HIDDEN.isMoreRestrictiveThan( + SubtreeAccessibilityState.TO_BE_DELETED)); + assertFalse(SubtreeAccessibilityState.HIDDEN.isMoreRestrictiveThan( + SubtreeAccessibilityState.HIDDEN)); + assertTrue(SubtreeAccessibilityState.HIDDEN.isMoreRestrictiveThan( + SubtreeAccessibilityState.READ_ONLY_BIND_DENIED)); + assertTrue(SubtreeAccessibilityState.HIDDEN.isMoreRestrictiveThan( + SubtreeAccessibilityState.READ_ONLY_BIND_ALLOWED)); + assertTrue(SubtreeAccessibilityState.HIDDEN.isMoreRestrictiveThan( + SubtreeAccessibilityState.ACCESSIBLE)); + + assertFalse( + SubtreeAccessibilityState.READ_ONLY_BIND_DENIED.isMoreRestrictiveThan( + SubtreeAccessibilityState.TO_BE_DELETED)); + assertFalse( + SubtreeAccessibilityState.READ_ONLY_BIND_DENIED.isMoreRestrictiveThan( + SubtreeAccessibilityState.HIDDEN)); + assertFalse( + SubtreeAccessibilityState.READ_ONLY_BIND_DENIED.isMoreRestrictiveThan( + SubtreeAccessibilityState.READ_ONLY_BIND_DENIED)); + assertTrue( + SubtreeAccessibilityState.READ_ONLY_BIND_DENIED.isMoreRestrictiveThan( + SubtreeAccessibilityState.READ_ONLY_BIND_ALLOWED)); + assertTrue( + SubtreeAccessibilityState.READ_ONLY_BIND_DENIED.isMoreRestrictiveThan( + SubtreeAccessibilityState.ACCESSIBLE)); + + assertFalse( + SubtreeAccessibilityState.READ_ONLY_BIND_ALLOWED.isMoreRestrictiveThan( + SubtreeAccessibilityState.TO_BE_DELETED)); + assertFalse( + SubtreeAccessibilityState.READ_ONLY_BIND_ALLOWED.isMoreRestrictiveThan( + SubtreeAccessibilityState.HIDDEN)); + assertFalse( + SubtreeAccessibilityState.READ_ONLY_BIND_ALLOWED.isMoreRestrictiveThan( + SubtreeAccessibilityState.READ_ONLY_BIND_DENIED)); + assertFalse( + SubtreeAccessibilityState.READ_ONLY_BIND_ALLOWED.isMoreRestrictiveThan( + SubtreeAccessibilityState.READ_ONLY_BIND_ALLOWED)); + assertTrue( + SubtreeAccessibilityState.READ_ONLY_BIND_ALLOWED.isMoreRestrictiveThan( + SubtreeAccessibilityState.ACCESSIBLE)); + + assertFalse(SubtreeAccessibilityState.ACCESSIBLE.isMoreRestrictiveThan( + SubtreeAccessibilityState.TO_BE_DELETED)); + assertFalse(SubtreeAccessibilityState.ACCESSIBLE.isMoreRestrictiveThan( + SubtreeAccessibilityState.HIDDEN)); + assertFalse(SubtreeAccessibilityState.ACCESSIBLE.isMoreRestrictiveThan( + SubtreeAccessibilityState.READ_ONLY_BIND_DENIED)); + assertFalse(SubtreeAccessibilityState.ACCESSIBLE.isMoreRestrictiveThan( + SubtreeAccessibilityState.READ_ONLY_BIND_ALLOWED)); + assertFalse(SubtreeAccessibilityState.ACCESSIBLE.isMoreRestrictiveThan( + SubtreeAccessibilityState.ACCESSIBLE)); + } + + + /** * Tests the {@code forName} method with automated tests based on the actual * name of the enum values.