mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
03.50.2014 8433427527214c83f56c533259efd7f56a1863b3
AutoRefactored:
- work with null checked expressions first
- revert conditions
- collapse if statements
- push negations down
- invert equals()

Manually used ternary operators
44 files modified
463 ■■■■■ changed files
opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java 22 ●●●● patch | view | raw | blame | history
opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java 6 ●●●● patch | view | raw | blame | history
opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java 4 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/AggregationPropertyDefinition.java 43 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/DNPropertyDefinition.java 8 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/DurationPropertyDefinition.java 39 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/DurationUnit.java 32 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/IntegerPropertyDefinition.java 8 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectDefinitionI18NResource.java 5 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectPath.java 6 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/PropertyDefinition.java 8 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/SizePropertyDefinition.java 8 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/SizeUnit.java 48 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPDriver.java 13 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/AbstractManagedObject.java 6 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/PropertySet.java 5 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/CreateSubCommandHandler.java 6 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/PropertyValueEditor.java 11 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/server/ServerManagementContext.java 8 ●●●● patch | view | raw | blame | history
opendj-config/src/test/java/org/forgerock/opendj/config/ConfigurationMock.java 6 ●●●● patch | view | raw | blame | history
opendj-config/src/test/java/org/forgerock/opendj/config/server/AdminTestCaseUtils.java 5 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/com/forgerock/opendj/util/StaticUtils.java 6 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/Entries.java 6 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/Filter.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/requests/DigestMD5SASLBindRequestImpl.java 9 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/requests/GSSAPISASLBindRequestImpl.java 5 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/requests/GenericBindRequestImpl.java 5 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/responses/AbstractResultImpl.java 14 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AttributeType.java 7 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/NameAndOptionalUIDSyntaxImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/NumericStringSyntaxImpl.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java 8 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/spi/SearchResultLdapPromiseImpl.java 11 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateFile.java 6 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateTag.java 14 ●●●●● patch | view | raw | blame | history
opendj-core/src/test/java/com/forgerock/opendj/util/OperatingSystemTestCase.java 6 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/com/forgerock/opendj/util/StaticUtilsTestCase.java 12 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/requests/BindRequestTestCase.java 4 ●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Controls.java 8 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java 6 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UpdateGroup.java 13 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ModRate.java 12 ●●●● patch | view | raw | blame | history
opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Context.java 2 ●●● patch | view | raw | blame | history
opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/ListenerSettings.java 6 ●●●● patch | view | raw | blame | history
opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
@@ -751,10 +751,10 @@
        if (allowsTrailingArguments) {
            buffer.append(" ");
            if (trailingArgsDisplayName == null) {
                buffer.append(INFO_ARGPARSER_USAGE_TRAILINGARGS.get());
            } else {
            if (trailingArgsDisplayName != null) {
                buffer.append(trailingArgsDisplayName);
            } else {
                buffer.append(INFO_ARGPARSER_USAGE_TRAILINGARGS.get());
            }
        }
        buffer.append(EOL);
@@ -963,13 +963,6 @@
                        // version information.
                        usageOrVersionDisplayed = true;
                        versionPresent = true;
                        try {
                            // TODO
                            // DirectoryServer.printVersion(usageOutputStream);
                        } catch (final Exception e) {
                            // Ignored.
                        }
                        return;
                    } else {
                        // There is no such argument registered.
@@ -1046,16 +1039,9 @@
                            && !shortIDMap.containsKey(OPTION_SHORT_PRODUCT_VERSION)) {
                        // "-V" will always be interpreted as requesting
                        // version information except if it's already defined
                        // (e.g
                        // in ldap tools).
                        // (e.g in ldap tools).
                        usageOrVersionDisplayed = true;
                        versionPresent = true;
                        try {
                            // TODO
                            // DirectoryServer.printVersion(usageOutputStream);
                        } catch (final Exception e) {
                            // Ignored.
                        }
                        return;
                    } else {
                        // There is no such argument registered.
opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java
@@ -1251,10 +1251,10 @@
        String value;
        if (a.needsValue()) {
            LocalizableMessage pHolder = a.getValuePlaceholder();
            if (pHolder == null) {
                value = " {value}";
            } else {
            if (pHolder != null) {
                value = " " + pHolder;
            } else {
                value = " {value}";
            }
        } else {
            value = "";
opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
@@ -401,14 +401,14 @@
    }
    /**
     * Checks that the java version.
     * Checks the java version.
     *
     * @throws ClientException
     *             If the java version we are running on is not compatible.
     */
    public static void checkJavaVersion() throws ClientException {
        final String version = System.getProperty("java.specification.version");
        if (!(Float.valueOf(version) >= 1.6)) {
        if (Float.valueOf(version) < 1.6) {
            final String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
            throw new ClientException(ReturnCode.JAVA_VERSION_INCOMPATIBLE, ERR_INCOMPATIBLE_JAVA_VERSION.get("1.6",
                    version, javaBin), null);
opendj-config/src/main/java/org/forgerock/opendj/config/AggregationPropertyDefinition.java
@@ -523,14 +523,13 @@
                }
                // Make sure the reference managed object is enabled.
                if (needsEnabling) {
                    if (!targetIsEnabledCondition.evaluate(context, ref)) {
                if (needsEnabling
                        && !targetIsEnabledCondition.evaluate(context, ref)) {
                        LocalizableMessage msg = ERR_CLIENT_REFINT_TARGET_DISABLED.get(ufn, name, getName());
                        unacceptableReasons.add(msg);
                        isAcceptable = false;
                    }
                }
            }
            return isAcceptable;
        }
@@ -559,18 +558,14 @@
            // constraint violation.
            boolean isAcceptable = true;
            for (ManagedObject<?> mo : findReferences(context, getManagedObjectDefinition(), path.getName())) {
                String name = mo.getManagedObjectPath().getName();
                if (name == null) {
                    LocalizableMessage msg =
                        ERR_CLIENT_REFINT_CANNOT_DELETE_WITHOUT_NAME.get(getName(), mo.getManagedObjectDefinition()
                            .getUserFriendlyName(), getManagedObjectDefinition().getUserFriendlyName());
                final LocalizableMessage uName1 = mo.getManagedObjectDefinition().getUserFriendlyName();
                final LocalizableMessage uName2 = getManagedObjectDefinition().getUserFriendlyName();
                final String moName = mo.getManagedObjectPath().getName();
                final LocalizableMessage msg = moName != null
                    ? ERR_CLIENT_REFINT_CANNOT_DELETE_WITH_NAME.get(getName(), uName1, moName, uName2)
                    : ERR_CLIENT_REFINT_CANNOT_DELETE_WITHOUT_NAME.get(getName(), uName1, uName2);
                    unacceptableReasons.add(msg);
                } else {
                    LocalizableMessage msg =
                        ERR_CLIENT_REFINT_CANNOT_DELETE_WITH_NAME.get(getName(), mo.getManagedObjectDefinition()
                            .getUserFriendlyName(), name, getManagedObjectDefinition().getUserFriendlyName());
                    unacceptableReasons.add(msg);
                }
                isAcceptable = false;
            }
            return isAcceptable;
@@ -592,20 +587,14 @@
            for (ManagedObject<?> mo : findReferences(context, getManagedObjectDefinition(), managedObject
                .getManagedObjectPath().getName())) {
                if (targetNeedsEnablingCondition.evaluate(context, mo)) {
                    String name = mo.getManagedObjectPath().getName();
                    if (name == null) {
                        LocalizableMessage msg =
                            ERR_CLIENT_REFINT_CANNOT_DISABLE_WITHOUT_NAME.get(managedObject
                                .getManagedObjectDefinition().getUserFriendlyName(), getName(), mo
                                .getManagedObjectDefinition().getUserFriendlyName());
                    final LocalizableMessage uName1 = managedObject.getManagedObjectDefinition().getUserFriendlyName();
                    final LocalizableMessage uName2 = mo.getManagedObjectDefinition().getUserFriendlyName();
                    final String moName = mo.getManagedObjectPath().getName();
                    final LocalizableMessage msg = moName != null
                        ? ERR_CLIENT_REFINT_CANNOT_DISABLE_WITH_NAME.get(uName1, getName(), uName2, moName)
                        : ERR_CLIENT_REFINT_CANNOT_DISABLE_WITHOUT_NAME.get(uName1, getName(), uName2);
                        unacceptableReasons.add(msg);
                    } else {
                        LocalizableMessage msg =
                            ERR_CLIENT_REFINT_CANNOT_DISABLE_WITH_NAME.get(
                                managedObject.getManagedObjectDefinition().getUserFriendlyName(), getName(),
                                mo.getManagedObjectDefinition().getUserFriendlyName(), name);
                        unacceptableReasons.add(msg);
                    }
                    isAcceptable = false;
                }
            }
opendj-config/src/main/java/org/forgerock/opendj/config/DNPropertyDefinition.java
@@ -68,13 +68,7 @@
         *             representation.
         */
        public void setBaseDN(String baseDN) {
            if (baseDN == null) {
                setBaseDN((DN) null);
            } else {
                // TODO: is it correct to replace server DN.decode by SDK
                // valueOf ?
                setBaseDN(DN.valueOf(baseDN));
            }
            setBaseDN(baseDN != null ? DN.valueOf(baseDN) : null);
        }
        /**
opendj-config/src/main/java/org/forgerock/opendj/config/DurationPropertyDefinition.java
@@ -143,13 +143,10 @@
        public final void setBaseUnit(DurationUnit unit) {
            Reject.ifNull(unit);
            // Make sure that the base unit is not bigger than the maximum
            // unit.
            if (maximumUnit != null) {
                if (unit.getDuration() > maximumUnit.getDuration()) {
            // Make sure that the base unit is not bigger than the maximum unit.
            if (maximumUnit != null && unit.getDuration() > maximumUnit.getDuration()) {
                    throw new IllegalArgumentException("Base unit greater than maximum unit");
                }
            }
            this.baseUnit = unit;
        }
@@ -167,11 +164,7 @@
         *             base unit.
         */
        public final void setMaximumUnit(String unit) {
            if (unit == null) {
                setMaximumUnit((DurationUnit) null);
            } else {
                setMaximumUnit(DurationUnit.getUnit(unit));
            }
            setMaximumUnit(unit != null ? DurationUnit.getUnit(unit) : null);
        }
        /**
@@ -186,13 +179,10 @@
         *             unit.
         */
        public final void setMaximumUnit(DurationUnit unit) {
            if (unit != null) {
                // Make sure that the maximum unit is not smaller than the
                // base unit.
                if (unit.getDuration() < baseUnit.getDuration()) {
            // Make sure that the maximum unit is not smaller than the base unit.
            if (unit != null && unit.getDuration() < baseUnit.getDuration()) {
                    throw new IllegalArgumentException("Maximum unit smaller than base unit");
                }
            }
            this.maximumUnit = unit;
        }
@@ -276,11 +266,7 @@
         *             limit is greater than the upper limit.
         */
        public final void setUpperLimit(String upperLimit) {
            if (upperLimit == null) {
                setUpperLimit((Long) null);
            } else {
                setUpperLimit(DurationUnit.parseValue(upperLimit, baseUnit));
            }
            setUpperLimit(upperLimit != null ? DurationUnit.parseValue(upperLimit, baseUnit) : null);
        }
        /**
@@ -413,13 +399,10 @@
    public String encodeValue(Long value) {
        Reject.ifNull(value);
        // Make sure that we correctly encode negative values as
        // "unlimited".
        if (allowUnlimited) {
            if (value < 0) {
        // Make sure that we correctly encode negative values as "unlimited".
        if (allowUnlimited && value < 0) {
                return UNLIMITED;
            }
        }
        // Encode the size value using the base unit.
        StringBuilder builder = new StringBuilder();
@@ -435,11 +418,9 @@
        Reject.ifNull(value);
        // First check for the special "unlimited" value when necessary.
        if (allowUnlimited) {
            if (value.trim().equalsIgnoreCase(UNLIMITED)) {
        if (allowUnlimited && UNLIMITED.equalsIgnoreCase(value.trim())) {
                return -1L;
            }
        }
        // Parse the string representation.
        long ms;
@@ -459,10 +440,10 @@
        Long i = (long) baseUnit.fromMilliSeconds(ms);
        try {
            validateValue(i);
            return i;
        } catch (PropertyException e) {
            throw PropertyException.illegalPropertyValueException(this, value);
        }
        return i;
    }
    /** {@inheritDoc} */
opendj-config/src/main/java/org/forgerock/opendj/config/DurationUnit.java
@@ -35,35 +35,23 @@
 */
public enum DurationUnit {
    /**
     * A day unit.
     */
    DAYS((long) 24 * 60 * 60 * 1000, "d", "days"),
    /** A day unit. */
    DAYS(24 * 60 * 60 * 1000, "d", "days"),
    /**
     * An hour unit.
     */
    HOURS((long) 60 * 60 * 1000, "h", "hours"),
    /** An hour unit. */
    HOURS(60 * 60 * 1000, "h", "hours"),
    /**
     * A millisecond unit.
     */
    /** A millisecond unit. */
    MILLI_SECONDS(1L, "ms", "milliseconds"),
    /**
     * A minute unit.
     */
    MINUTES((long) 60 * 1000, "m", "minutes"),
    /** A minute unit. */
    MINUTES(60 * 1000, "m", "minutes"),
    /**
     * A second unit.
     */
    /** A second unit. */
    SECONDS(1000L, "s", "seconds"),
    /**
     * A week unit.
     */
    WEEKS((long) 7 * 24 * 60 * 60 * 1000, "w", "weeks");
    /** A week unit. */
    WEEKS(7 * 24 * 60 * 60 * 1000, "w", "weeks");
    /** A lookup table for resolving a unit from its name. */
    private static final Map<String, DurationUnit> NAME_TO_UNIT;
opendj-config/src/main/java/org/forgerock/opendj/config/IntegerPropertyDefinition.java
@@ -250,11 +250,9 @@
        Reject.ifNull(value);
        // Make sure that we correctly encode negative values as "unlimited".
        if (allowUnlimited) {
            if (value < 0) {
        if (allowUnlimited && value < 0) {
                return UNLIMITED;
            }
        }
        return value.toString();
    }
@@ -264,11 +262,9 @@
    public Integer decodeValue(String value) {
        Reject.ifNull(value);
        if (allowUnlimited) {
            if (value.trim().equalsIgnoreCase(UNLIMITED)) {
        if (allowUnlimited && UNLIMITED.equalsIgnoreCase(value.trim())) {
                return -1;
            }
        }
        Integer i;
        try {
opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectDefinitionI18NResource.java
@@ -158,11 +158,10 @@
        ResourceBundle resource = getResourceBundle(d, locale);
        // TODO: use message framework directly
        if (args == null) {
            return LocalizableMessage.raw(resource.getString(key));
        } else {
        if (args != null) {
            return LocalizableMessage.raw(resource.getString(key), (Object[]) args);
        }
        return LocalizableMessage.raw(resource.getString(key));
    }
    /**
opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectPath.java
@@ -564,10 +564,10 @@
            lastElement.getManagedObjectDefinition());
    }
    // Decode an element.
    // @Checkstyle:ignore
    private static <C extends ConfigurationClient, S extends Configuration> Element<? extends C, ? extends S> createElement(
        RelationDefinition<C, S> r, String path, String element, String type, String name) {
    /** Decode an element. */
    private static <C extends ConfigurationClient, S extends Configuration> Element<? extends C, ? extends S>
    createElement(RelationDefinition<C, S> r, String path, String element, String type, String name) {
        // First determine the managed object definition.
        AbstractManagedObjectDefinition<? extends C, ? extends S> d = null;
opendj-config/src/main/java/org/forgerock/opendj/config/PropertyDefinition.java
@@ -367,12 +367,8 @@
            return true;
        } else if (o instanceof PropertyDefinition) {
            PropertyDefinition<?> other = (PropertyDefinition<?>) o;
            if (propertyName.equals(other.propertyName)) {
                if (theClass.equals(other.theClass)) {
                    return true;
                }
            }
            return false;
            return propertyName.equals(other.propertyName)
                    && theClass.equals(other.theClass);
        } else {
            return false;
        }
opendj-config/src/main/java/org/forgerock/opendj/config/SizePropertyDefinition.java
@@ -251,11 +251,9 @@
        Reject.ifNull(value);
        // Make sure that we correctly encode negative values as "unlimited".
        if (allowUnlimited) {
            if (value < 0) {
        if (allowUnlimited && value < 0) {
                return UNLIMITED;
            }
        }
        // Encode the size value using the best-fit unit.
        StringBuilder builder = new StringBuilder();
@@ -275,11 +273,9 @@
        Reject.ifNull(value);
        // First check for the special "unlimited" value when necessary.
        if (allowUnlimited) {
            if (value.trim().equalsIgnoreCase(UNLIMITED)) {
        if (allowUnlimited && UNLIMITED.equalsIgnoreCase(value.trim())) {
                return -1L;
            }
        }
        // Decode the value.
        Long i;
opendj-config/src/main/java/org/forgerock/opendj/config/SizeUnit.java
@@ -35,50 +35,32 @@
 */
public enum SizeUnit {
    /**
     * A byte unit.
     */
    /** A byte unit. */
    BYTES(1L, "b", "bytes"),
    /**
     * A gibi-byte unit.
     */
    GIBI_BYTES((long) 1024 * 1024 * 1024, "gib", "gibibytes"),
    /** A gibi-byte unit. */
    GIBI_BYTES(1024 * 1024 * 1024, "gib", "gibibytes"),
    /**
     * A giga-byte unit.
     */
    GIGA_BYTES((long) 1000 * 1000 * 1000, "gb", "gigabytes"),
    /** A giga-byte unit. */
    GIGA_BYTES(1000 * 1000 * 1000, "gb", "gigabytes"),
    /**
     * A kibi-byte unit.
     */
    /** A kibi-byte unit. */
    KIBI_BYTES(1024L, "kib", "kibibytes"),
    /**
     * A kilo-byte unit.
     */
    /** A kilo-byte unit. */
    KILO_BYTES(1000L, "kb", "kilobytes"),
    /**
     * A mebi-byte unit.
     */
    MEBI_BYTES((long) 1024 * 1024, "mib", "mebibytes"),
    /** A mebi-byte unit. */
    MEBI_BYTES(1024 * 1024, "mib", "mebibytes"),
    /**
     * A mega-byte unit.
     */
    MEGA_BYTES((long) 1000 * 1000, "mb", "megabytes"),
    /** A mega-byte unit. */
    MEGA_BYTES(1000 * 1000, "mb", "megabytes"),
    /**
     * A tebi-byte unit.
     */
    TEBI_BYTES((long) 1024 * 1024 * 1024 * 1024, "tib", "tebibytes"),
    /** A tebi-byte unit. */
    TEBI_BYTES(1024L * 1024 * 1024 * 1024, "tib", "tebibytes"),
    /**
     * A tera-byte unit.
     */
    TERA_BYTES((long) 1000 * 1000 * 1000 * 1000, "tb", "terabytes");
    /** A tera-byte unit. */
    TERA_BYTES(1000L * 1000 * 1000 * 1000, "tb", "terabytes");
    /** A lookup table for resolving a unit from its name. */
    private static final Map<String, SizeUnit> NAME_TO_UNIT;
opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPDriver.java
@@ -486,22 +486,21 @@
        newProperties.addProperty(propertyDef, defaultValues, activeValues);
        if (activeValues.isEmpty() && defaultValues.isEmpty() && propertyDef.hasOption(PropertyOption.MANDATORY)) {
            // The active values maybe empty because of a previous
            // exception.
            if (exception == null) {
        if (activeValues.isEmpty()
                && defaultValues.isEmpty()
                && propertyDef.hasOption(PropertyOption.MANDATORY)
                && exception == null) {
            // The active values maybe empty because of a previous exception.
                exception = PropertyException.propertyIsMandatoryException(propertyDef);
            }
        }
        if (exception != null) {
            throw exception;
        }
    }
    // Determine the type of managed object associated with the named
    // entry.
    // @Checkstyle:off
    /** Determine the type of managed object associated with the named entry. */
    private <C extends ConfigurationClient, S extends Configuration> ManagedObjectDefinition<? extends C, ? extends S>
        getEntryDefinition(AbstractManagedObjectDefinition<C, S> d, DN dn) throws LdapException,
        DefinitionDecodingException {
opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/AbstractManagedObject.java
@@ -586,10 +586,10 @@
    /** {@inheritDoc} */
    @Override
    public final <P> void setPropertyValue(PropertyDefinition<P> pd, P value) {
        if (value == null) {
            setPropertyValues(pd, Collections.<P> emptySet());
        } else {
        if (value != null) {
            setPropertyValues(pd, Collections.singleton(value));
        } else {
            setPropertyValues(pd, Collections.<P> emptySet());
        }
    }
opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/PropertySet.java
@@ -277,12 +277,9 @@
            throw PropertyException.propertyIsSingleValuedException(d);
        }
        if (values.isEmpty() && d.hasOption(PropertyOption.MANDATORY)) {
            // But only if there are no default values.
            if (property.getDefaultValues().isEmpty()) {
        if (values.isEmpty() && d.hasOption(PropertyOption.MANDATORY) && property.getDefaultValues().isEmpty()) {
                throw PropertyException.propertyIsMandatoryException(d);
            }
        }
        // Validate each value.
        for (T e : values) {
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/CreateSubCommandHandler.java
@@ -177,11 +177,11 @@
        @SuppressWarnings("unchecked")
        public <T> Collection<T> getPropertyValues(PropertyDefinition<T> d) {
            Collection<T> values = (Collection<T>) properties.get(d);
            if (values == null) {
                return Collections.emptySet();
            }
            if (values != null) {
            return values;
        }
            return Collections.emptySet();
        }
        /** Add a single property value. */
        @SuppressWarnings("unchecked")
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/PropertyValueEditor.java
@@ -1117,9 +1117,8 @@
            builder.setPrompt(INFO_EDITOR_PROMPT_MODIFY_MENU.get(d.getName()));
            // First option is for leaving the property unchanged or
            // applying changes, but only if the state of the property is
            // valid.
            if (!(d.hasOption(PropertyOption.MANDATORY) && currentValues.isEmpty())) {
            // applying changes, but only if the state of the property is valid.
            if (!d.hasOption(PropertyOption.MANDATORY) || !currentValues.isEmpty()) {
                MenuResult<Boolean> result;
                if (!oldValues.equals(currentValues)) {
                    result = MenuResult.success(true);
@@ -1313,10 +1312,10 @@
                // properties should apply here.
                DefaultBehaviorQuery<T> query = DefaultBehaviorQuery.query(pd);
                LocalizableMessage aliasDescription = query.getAliasDescription();
                if (aliasDescription == null) {
                    app.println(INFO_EDITOR_HEADING_READ_ONLY_ALIAS_UNDEFINED.get(pd.getName()));
                } else {
                if (aliasDescription != null) {
                    app.println(INFO_EDITOR_HEADING_READ_ONLY_ALIAS.get(pd.getName(), aliasDescription));
                } else {
                    app.println(INFO_EDITOR_HEADING_READ_ONLY_ALIAS_UNDEFINED.get(pd.getName()));
                }
                break;
            case 1:
opendj-config/src/main/java/org/forgerock/opendj/config/server/ServerManagementContext.java
@@ -709,18 +709,14 @@
            pvalues.add(value);
        }
        if (pvalues.isEmpty() && propertyDef.hasOption(PropertyOption.MANDATORY)) {
            // The values maybe empty because of a previous exception.
            if (exception == null) {
        if (pvalues.isEmpty() && propertyDef.hasOption(PropertyOption.MANDATORY) && exception == null) {
                exception = PropertyException.propertyIsMandatoryException(propertyDef);
            }
        }
        if (exception != null) {
            throw exception;
        } else {
            return pvalues;
        }
        return pvalues;
    }
    /** Gets the attribute values associated with a property from a ConfigEntry. */
opendj-config/src/test/java/org/forgerock/opendj/config/ConfigurationMock.java
@@ -97,10 +97,10 @@
                Method getPropertyDefMethod = getPropertyDefinitionMethod(definitionClass, invokedMethodName);
                Class<?> propertyReturnType = getPropertyReturnType(getPropertyDefMethod);
                Object defaultValue = getDefaultValue(definition, getPropertyDefMethod, propertyReturnType);
                if (defaultValue == null) {
                    return answerFromDefaultMockitoBehavior(invocation);
                }
                if (defaultValue != null) {
                return defaultValue;
                }
                return answerFromDefaultMockitoBehavior(invocation);
            } catch (Exception e) {
                return answerFromDefaultMockitoBehavior(invocation);
            }
opendj-config/src/test/java/org/forgerock/opendj/config/server/AdminTestCaseUtils.java
@@ -98,11 +98,10 @@
            LDAPProfile.Wrapper profile = new LDAPProfile.Wrapper() {
                @Override
                public String getRelationRDNSequence(RelationDefinition<?, ?> r) {
                    if (r.getName().equals(DUMMY_TEST_RELATION)) {
                    if (DUMMY_TEST_RELATION.equals(r.getName())) {
                        return "cn=dummy configuration,cn=config";
                    } else {
                        return null;
                    }
                    return null;
                }
            };
opendj-core/src/main/java/com/forgerock/opendj/util/StaticUtils.java
@@ -1785,10 +1785,10 @@
    public static <P extends Provider> P getProvider(final Class<P> providerClass, final String requestedProvider,
            final ClassLoader classLoader) {
        ServiceLoader<P> loader = null;
        if (classLoader == null) {
            loader = ServiceLoader.load(providerClass);
        } else {
        if (classLoader != null) {
            loader = ServiceLoader.load(providerClass, classLoader);
        } else {
            loader = ServiceLoader.load(providerClass);
        }
        StringBuilder providersFound = new StringBuilder();
        for (P provider : loader) {
opendj-core/src/main/java/org/forgerock/opendj/ldap/Entries.java
@@ -853,13 +853,11 @@
                continue;
            }
            if (objectClass.getObjectClassType() == ObjectClassType.STRUCTURAL) {
                if (structuralObjectClass == null
                        || objectClass.isDescendantOf(structuralObjectClass)) {
            if (objectClass.getObjectClassType() == ObjectClassType.STRUCTURAL
                    && (structuralObjectClass == null || objectClass.isDescendantOf(structuralObjectClass))) {
                    structuralObjectClass = objectClass;
                }
            }
        }
        return structuralObjectClass;
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/Filter.java
@@ -797,7 +797,7 @@
     */
    public static Filter present(final String attributeDescription) {
        Reject.ifNull(attributeDescription);
        if (toLowerCase(attributeDescription).equals("objectclass")) {
        if ("objectclass".equals(toLowerCase(attributeDescription))) {
            return OBJECT_CLASS_PRESENT;
        }
        return new Filter(new PresentImpl(attributeDescription));
opendj-core/src/main/java/org/forgerock/opendj/ldap/requests/DigestMD5SASLBindRequestImpl.java
@@ -170,9 +170,8 @@
            final String qop = (String) saslClient.getNegotiatedProperty(Sasl.QOP);
            if (qop.equalsIgnoreCase("auth-int") || qop.equalsIgnoreCase("auth-conf")) {
                return this;
            } else {
                return null;
            }
            return null;
        }
        @Override
@@ -209,11 +208,7 @@
        @Override
        void handle(final RealmCallback callback) throws UnsupportedCallbackException {
            if (realm == null) {
                callback.setText(callback.getDefaultText());
            } else {
                callback.setText(realm);
            }
            callback.setText(realm != null ? realm : callback.getDefaultText());
        }
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/requests/GSSAPISASLBindRequestImpl.java
@@ -262,11 +262,10 @@
        @Override
        public ConnectionSecurityLayer getConnectionSecurityLayer() {
            final String qop = (String) saslClient.getNegotiatedProperty(Sasl.QOP);
            if (qop.equalsIgnoreCase("auth-int") || qop.equalsIgnoreCase("auth-conf")) {
            if ("auth-int".equalsIgnoreCase(qop) || "auth-conf".equalsIgnoreCase(qop)) {
                return this;
            } else {
                return null;
            }
            return null;
        }
        @Override
opendj-core/src/main/java/org/forgerock/opendj/ldap/requests/GenericBindRequestImpl.java
@@ -73,11 +73,10 @@
    @Override
    public BindClient createBindClient(final String serverName) throws LdapException {
        if (bindClient == null) {
            return new BindClientImpl(this).setNextAuthenticationValue(authenticationValue);
        } else {
        if (bindClient != null) {
            return bindClient;
        }
        return new BindClientImpl(this).setNextAuthenticationValue(authenticationValue);
    }
    @Override
opendj-core/src/main/java/org/forgerock/opendj/ldap/responses/AbstractResultImpl.java
@@ -115,23 +115,13 @@
    @Override
    public final S setDiagnosticMessage(final String message) {
        if (message == null) {
            this.diagnosticMessage = "";
        } else {
            this.diagnosticMessage = message;
        }
        this.diagnosticMessage = message != null ? message : "";
        return getThis();
    }
    @Override
    public final S setMatchedDN(final String dn) {
        if (dn == null) {
            this.matchedDN = "";
        } else {
            this.matchedDN = dn;
        }
        this.matchedDN = dn != null ? dn : "";
        return getThis();
    }
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AttributeType.java
@@ -682,16 +682,13 @@
                return false;
            }
            if (superiorType.isCollective() != isCollective()) {
                if (!isCollective()) {
                    LocalizableMessage message =
                            WARN_ATTR_SYNTAX_ATTRTYPE_NONCOLLECTIVE_FROM_COLLECTIVE.get(
            if (superiorType.isCollective() != isCollective() && !isCollective()) {
                LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_NONCOLLECTIVE_FROM_COLLECTIVE.get(
                                    getNameOrOID(), superiorType.getNameOrOID());
                    failValidation(invalidSchemaElements, warnings, message);
                    return false;
                }
            }
        }
        if (syntaxOID != null) {
            if (!schema.hasSyntax(syntaxOID)) {
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/NameAndOptionalUIDSyntaxImpl.java
@@ -109,7 +109,7 @@
            final int endPos = valueLength - 2;
            for (int i = sharpPos + 2; i < endPos; i++) {
                final char c = valueString.charAt(i);
                if (!(c == '0' || c == '1')) {
                if (c != '0' && c != '1') {
                    invalidReason.append(ERR_ATTR_SYNTAX_NAMEANDUID_ILLEGAL_BINARY_DIGIT.get(
                            valueString, String.valueOf(c), i));
                    return false;
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/NumericStringSyntaxImpl.java
@@ -96,7 +96,7 @@
        // or spaces.
        for (int i = 0; i < length; i++) {
            final char c = valueString.charAt(i);
            if (!(isDigit(c) || c == ' ')) {
            if (!isDigit(c) && c != ' ') {
                invalidReason.append(WARN_ATTR_SYNTAX_NUMERIC_STRING_ILLEGAL_CHAR.get(valueString,
                        String.valueOf(c), i));
                return false;
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java
@@ -2158,12 +2158,12 @@
                    if (!isAllowed) {
                        if (errorMessages != null) {
                            final LocalizableMessage message;
                            if (ditContentRule == null) {
                                message = ERR_ENTRY_SCHEMA_OC_DISALLOWED_ATTRIBUTES.get(
                                        entry.getName(), t.getNameOrOID());
                            } else {
                            if (ditContentRule != null) {
                                message = ERR_ENTRY_SCHEMA_DCR_DISALLOWED_ATTRIBUTES.get(
                                        entry.getName(), t.getNameOrOID(), ditContentRule.getNameOrOID());
                            } else {
                                message = ERR_ENTRY_SCHEMA_OC_DISALLOWED_ATTRIBUTES.get(
                                        entry.getName(), t.getNameOrOID());
                            }
                            errorMessages.add(message);
                        }
opendj-core/src/main/java/org/forgerock/opendj/ldap/spi/SearchResultLdapPromiseImpl.java
@@ -66,12 +66,10 @@
        // the synchronizer.
        if (!isDone()) {
            updateTimestamp();
            if (searchResultHandler != null) {
                if (!searchResultHandler.handleEntry(entry)) {
            if (searchResultHandler != null && !searchResultHandler.handleEntry(entry)) {
                    searchResultHandler = null;
                }
            }
        }
        return true;
    }
@@ -84,20 +82,17 @@
        // the synchronizer.
        if (!isDone()) {
            updateTimestamp();
            if (searchResultHandler != null) {
                if (!searchResultHandler.handleReference(reference)) {
            if (searchResultHandler != null && !searchResultHandler.handleReference(reference)) {
                    searchResultHandler = null;
                }
            }
        }
        return true;
    }
    @Override
    Result newErrorResult(final ResultCode resultCode, final String diagnosticMessage,
            final Throwable cause) {
        return Responses.newResult(resultCode).setDiagnosticMessage(diagnosticMessage).setCause(
                cause);
        return Responses.newResult(resultCode).setDiagnosticMessage(diagnosticMessage).setCause(cause);
    }
    @Override
opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateFile.java
@@ -1144,10 +1144,10 @@
        final String[] arguments = args.toArray(new String[args.size()]);
        final AttributeValueTag tag = new AttributeValueTag();
        if (branch == null) {
            tag.initializeForTemplate(schema, this, template, arguments, lineNumber, warnings);
        } else {
        if (branch != null) {
            tag.initializeForBranch(schema, this, branch, arguments, lineNumber, warnings);
        } else {
            tag.initializeForTemplate(schema, this, template, arguments, lineNumber, warnings);
        }
        return tag;
    }
opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateTag.java
@@ -1228,11 +1228,11 @@
                break;
            case NUMERIC:
                long randomValue = ((random.nextLong() & 0x7FFFFFFFFFFFFFFFL) % valueRange) + minValue;
                if (decimalFormat == null) {
                    templateValue.append(randomValue);
                } else {
                long randomValue = (random.nextLong() & 0x7FFFFFFFFFFFFFFFL) % valueRange + minValue;
                if (decimalFormat != null) {
                    templateValue.append(decimalFormat.format(randomValue));
                } else {
                    templateValue.append(randomValue);
                }
                break;
@@ -1303,12 +1303,10 @@
        @Override
        TagResult generateValue(TemplateEntry templateEntry, TemplateValue templateValue) {
            DN dn = templateEntry.getDN();
            if (dn == null || dn.isRootDN()) {
                return TagResult.SUCCESS;
            } else {
            if (dn != null && !dn.isRootDN()) {
                templateValue.append(dn.rdn());
                return TagResult.SUCCESS;
            }
            return TagResult.SUCCESS;
        }
    }
opendj-core/src/test/java/com/forgerock/opendj/util/OperatingSystemTestCase.java
@@ -71,10 +71,10 @@
    public void testOperatingSystems(String value) throws Exception {
        String orig = System.getProperty("os.name");
        try {
            if (value == null) {
                System.clearProperty("os.name");
            } else {
            if (value != null) {
                System.setProperty("os.name", value);
            } else {
                System.clearProperty("os.name");
            }
            run();
        } finally {
opendj-core/src/test/java/com/forgerock/opendj/util/StaticUtilsTestCase.java
@@ -179,10 +179,10 @@
    @Test(dataProvider = "dataForToLowerCase")
    public void testToLowerCaseString(final String s, final String expected) {
        final String actual = toLowerCase(s);
        if (expected == null) {
            Assert.assertSame(actual, s);
        } else {
        if (expected != null) {
            Assert.assertEquals(actual, expected);
        } else {
            Assert.assertSame(actual, s);
        }
    }
@@ -190,10 +190,10 @@
    public void testToLowerCaseStringBuilder(final String s, final String expected) {
        final StringBuilder builder = new StringBuilder();
        final String actual = toLowerCase(s, builder).toString();
        if (expected == null) {
            Assert.assertEquals(actual, s);
        } else {
        if (expected != null) {
            Assert.assertEquals(actual, expected);
        } else {
            Assert.assertEquals(actual, s);
        }
    }
opendj-core/src/test/java/org/forgerock/opendj/ldap/requests/BindRequestTestCase.java
@@ -41,9 +41,7 @@
    @Test(dataProvider = "createModifiableInstance")
    public void testAuthType(final BindRequest request) throws Exception {
        final byte b = request.getAuthenticationType();
        if (!(b == LDAP.TYPE_AUTHENTICATION_SASL || b == LDAP.TYPE_AUTHENTICATION_SIMPLE)) {
            throw new Exception("Invalid bind type");
        }
        assertThat(b).isIn(LDAP.TYPE_AUTHENTICATION_SASL, LDAP.TYPE_AUTHENTICATION_SIMPLE);
    }
    @Test(dataProvider = "createModifiableInstance")
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Controls.java
@@ -475,7 +475,7 @@
                    final PasswordExpiredResponseControl control =
                            result.getControl(PasswordExpiredResponseControl.DECODER,
                                    new DecodeOptions());
                    if (!(control == null) && control.hasValue()) {
                    if (control != null && control.hasValue()) {
                        System.out.println("Password expired for " + dn);
                    }
                } catch (final DecodeException de) {
@@ -513,7 +513,7 @@
                final PasswordExpiringResponseControl control =
                        result.getControl(PasswordExpiringResponseControl.DECODER,
                                new DecodeOptions());
                if (!(control == null) && control.hasValue()) {
                if (control != null && control.hasValue()) {
                    System.out.println("Password for " + dn + " expires in "
                            + control.getSecondsUntilExpiration() + " seconds.");
                }
@@ -553,7 +553,7 @@
                final PasswordPolicyResponseControl control =
                        result.getControl(PasswordPolicyResponseControl.DECODER,
                                new DecodeOptions());
                if (!(control == null) && !(control.getWarningType() == null)) {
                if (control != null && control.getWarningType() != null) {
                    System.out.println("Password policy warning "
                            + control.getWarningType() + ", value "
                            + control.getWarningValue() + " for " + dn);
@@ -564,7 +564,7 @@
                    final PasswordPolicyResponseControl control =
                            result.getControl(PasswordPolicyResponseControl.DECODER,
                                    new DecodeOptions());
                    if (!(control == null)) {
                    if (control != null) {
                        System.out.println("Password policy error "
                                + control.getErrorType() + " for " + dn);
                    }
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java
@@ -126,9 +126,9 @@
        port = Integer.parseInt(args[1]);
        infoType = args[2];
        final String infoTypeLc = infoType.toLowerCase();
        if (!("all".equals(infoTypeLc)
                || "controls".equals(infoTypeLc)
                || "extops".equals(infoTypeLc))) {
        if (!"all".equals(infoTypeLc)
                && !"controls".equals(infoTypeLc)
                && !"extops".equals(infoTypeLc)) {
            giveUp();
        }
    }
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UpdateGroup.java
@@ -118,8 +118,8 @@
                        Requests.newCompareRequest(groupDN, "member", memberDN);
                CompareResult result = connection.compare(request);
                if (modType == ModificationType.ADD) {
                    if (result.getResultCode() == ResultCode.COMPARE_FALSE) {
                if (modType == ModificationType.ADD
                        && result.getResultCode() == ResultCode.COMPARE_FALSE) {
                        System.out.println("Member does not yet belong to group."
                                + " Adding it...");
                        final ModifyRequest addMember =
@@ -127,10 +127,9 @@
                                    .addModification(modType, "member", memberDN);
                        connection.modify(addMember);
                    }
                }
                if (modType == ModificationType.DELETE) {
                    if (result.getResultCode() == ResultCode.COMPARE_TRUE) {
                if (modType == ModificationType.DELETE
                        && result.getResultCode() == ResultCode.COMPARE_TRUE) {
                        System.out.println("Member belongs to group."
                                + " Removing it...");
                        final ModifyRequest delMember =
@@ -138,9 +137,7 @@
                                    .addModification(modType, "member", memberDN);
                        connection.modify(delMember);
                    }
                }
                // --- JCite without permissive ---
            }
            String op = (modType == ModificationType.ADD) ? "added to" : "deleted from";
@@ -164,7 +161,7 @@
     */
    private static ModificationType getModificationType(String operation) {
        final boolean isAdd = "add".equalsIgnoreCase(operation);
        if (!(isAdd || "del".equalsIgnoreCase(operation))) {
        if (!isAdd && !"del".equalsIgnoreCase(operation)) {
            printUsage();
        }
        return isAdd ? ModificationType.ADD : ModificationType.DELETE;
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ModRate.java
@@ -81,16 +81,16 @@
                String formattedString;
                int colonPos;
                ModifyRequest mr;
                if (data == null) {
                    mr = Requests.newModifyRequest(baseDN);
                } else {
                if (data != null) {
                    mr = Requests.newModifyRequest(String.format(baseDN, data));
                } else {
                    mr = Requests.newModifyRequest(baseDN);
                }
                for (final String modString : modStrings) {
                    if (data == null) {
                        formattedString = modString;
                    } else {
                    if (data != null) {
                        formattedString = String.format(modString, data);
                    } else {
                        formattedString = modString;
                    }
                    colonPos = formattedString.indexOf(':');
                    if (colonPos > 0) {
opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Context.java
@@ -421,7 +421,7 @@
                    synchronized (cachedReads) {
                        cachedReads.put(request.getName(), pendingCachedRead);
                    }
                    final LdapPromise<Result> promise = (LdapPromise<Result>) connection
                    final LdapPromise<Result> promise = connection
                            .searchAsync(withControls(request), intermediateResponseHandler, pendingCachedRead)
                            .onSuccess(pendingCachedRead).onFailure(pendingCachedRead);
                    pendingCachedRead.setPromise(promise);
opendj-server/src/main/java/org/forgerock/opendj/server/setup/model/ListenerSettings.java
@@ -290,11 +290,11 @@
     * @return The password linked to this root user DN.
     */
    public String getPassword() {
        if (password == null) {
            return null;
        }
        if (password != null) {
        return String.valueOf(password);
    }
        return null;
    }
    /**
     * Sets the user root's password.