Example usage for org.apache.commons.lang BooleanUtils isFalse

List of usage examples for org.apache.commons.lang BooleanUtils isFalse

Introduction

In this page you can find the example usage for org.apache.commons.lang BooleanUtils isFalse.

Prototype

public static boolean isFalse(Boolean bool) 

Source Link

Document

Checks if a Boolean value is false, handling null by returning false.

 BooleanUtils.isFalse(Boolean.TRUE)  = false BooleanUtils.isFalse(Boolean.FALSE) = true BooleanUtils.isFalse(null)          = false 

Usage

From source file:org.devgateway.ocds.web.spring.ScheduledExcelImportService.java

public void excelImportService() {

    AdminSettings settings = settingsUtils.getSettings();

    if (BooleanUtils.isFalse(settings.getEnableDailyAutomatedImport())) {
        return;/*  w  ww.  ja  va  2 s . c  o m*/
    }

    ImportResult result = null;
    //result = excelImportService.importAllSheets();

    if (!result.getSuccess()) {
        sendEmailService.sendEmail("Excel import failed!", result.getMsgBuffer().toString(),
                settings.getAdminEmail());
    }
}

From source file:org.efaps.ui.wicket.components.search.DimValuePanel.java

/**
 * Instantiates a new dim value panel.//from  www  . j a v a 2 s .  com
 *
 * @param _id the id
 * @param _model the model
 */
public DimValuePanel(final String _id, final IModel<DimTreeNode> _model) {
    super(_id, _model);
    final WebMarkupContainer cont = new WebMarkupContainer("triStateDiv");
    cont.setOutputMarkupId(true);

    if (_model.getObject().getStatus() != null) {
        cont.add(new AttributeAppender("class", _model.getObject().getStatus() ? "on" : "off", " "));
    }

    add(cont);

    final AjaxButton btn = new AjaxButton("triStateBtn") {
        /** The Constant serialVersionUID. */
        private static final long serialVersionUID = 1L;

        @Override
        protected void updateAjaxAttributes(final AjaxRequestAttributes _attributes) {
            super.updateAjaxAttributes(_attributes);
            final AjaxCallListener lstnr = new AjaxCallListener();
            lstnr.onBefore(getJavaScript());
            _attributes.getAjaxCallListeners().add(lstnr);
        }
    };
    cont.add(btn);

    cont.add(new Label("label", _model.getObject().getLabel()));
    cont.add(new Label("value", String.valueOf(((DimValue) _model.getObject().getValue()).getValue())));

    cont.add(new HiddenField<Boolean>("triStateValue", PropertyModel.of(_model.getObject(), "status")) {

        /** The Constant serialVersionUID. */
        private static final long serialVersionUID = 1L;

        @Override
        public boolean isInputNullable() {
            return true;
        };

        @Override
        protected String getModelValue() {
            final Boolean val = (Boolean) getDefaultModelObject();
            final String ret;
            if (BooleanUtils.isFalse(val)) {
                ret = "off";
            } else if (BooleanUtils.isTrue(val)) {
                ret = "on";
            } else {
                ret = "";
            }
            return ret;
        };

    }.setOutputMarkupId(true));
}

From source file:org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil.java

/**
 * Returns true if the value of the "skipPasswordExpirationCheck" thread local variable is false, else false
 * //from   w  w w  . j  a  va 2  s  . c o  m
 * @return true/false
 */
public static Boolean doPasswordExpirationCheck() {
    return BooleanUtils.isFalse(skipPasswordExpirationCheck.get());
}

From source file:org.onehippo.forge.channelmanager.pagesupport.document.management.impl.DocumentWorkflowDocumentManagementService.java

@Override
public boolean depublishDocument(String documentLocation) {
    log.debug("##### depublishDocument('{}')", documentLocation);

    if (StringUtils.isBlank(documentLocation)) {
        throw new IllegalArgumentException("Invalid document location: '" + documentLocation + "'.");
    }/*w  w w .ja va  2 s.com*/

    boolean depublished = false;

    try {
        if (!getSession().nodeExists(documentLocation)) {
            throw new IllegalArgumentException("Document doesn't exist at '" + documentLocation + "'.");
        }

        Node documentHandleNode = HippoWorkflowUtils
                .getHippoDocumentHandle(getSession().getNode(documentLocation));

        if (documentHandleNode == null) {
            throw new IllegalArgumentException("Document handle is not found at '" + documentLocation + "'.");
        }

        DocumentWorkflow documentWorkflow = getDocumentWorkflow(documentHandleNode);

        Boolean isLive = (Boolean) documentWorkflow.hints().get("isLive");

        if (BooleanUtils.isFalse(isLive)) {
            // already offline, so just return true
            depublished = true;
        } else {
            Boolean depublish = (Boolean) documentWorkflow.hints().get("depublish");

            if (!BooleanUtils.isTrue(depublish)) {
                throw new IllegalStateException(
                        "Document at '" + documentLocation + "' doesn't have depublish action.");
            }

            documentWorkflow.depublish();
            depublished = true;
        }
    } catch (RepositoryException | WorkflowException | RemoteException e) {
        log.error("Failed to depublish document at '{}'.", documentLocation, e);
        throw new RuntimeException("Failed to depublish document at '" + documentLocation + "'. " + e);
    }

    return depublished;
}

From source file:org.onehippo.forge.content.exim.core.impl.WorkflowDocumentManagerImpl.java

/**
 * {@inheritDoc}/*from  ww  w  . ja  v  a 2 s. co m*/
 */
@Override
public boolean depublishDocument(String documentLocation) throws DocumentManagerException {
    getLogger().debug("##### depublishDocument('{}')", documentLocation);

    if (StringUtils.isBlank(documentLocation)) {
        throw new IllegalArgumentException("Invalid document location: '" + documentLocation + "'.");
    }

    boolean depublished = false;

    try {
        final Node documentHandleNode = getExistingDocumentHandleNode(documentLocation);
        DocumentWorkflow documentWorkflow = getDocumentWorkflow(documentHandleNode);
        Boolean isLive = (Boolean) documentWorkflow.hints().get("isLive");

        if (BooleanUtils.isFalse(isLive)) {
            // already offline, so just return true
            depublished = true;
        } else {
            Boolean depublish = (Boolean) documentWorkflow.hints().get("depublish");

            if (!BooleanUtils.isTrue(depublish)) {
                throw new IllegalStateException(
                        "Document at '" + documentLocation + "' doesn't have depublish action.");
            }

            documentWorkflow.depublish();
            depublished = true;
        }
    } catch (RepositoryException | WorkflowException | RemoteException e) {
        getLogger().error("Failed to depublish document at '{}'.", documentLocation, e);
        throw new DocumentManagerException("Failed to depublish document at '" + documentLocation + "'. " + e,
                e);
    }

    return depublished;
}

From source file:org.optaplanner.core.config.heuristic.selector.entity.pillar.PillarSelectorConfig.java

/**
 * @param configPolicy never null// ww  w. j a  v  a2 s . com
 * @param minimumCacheType never null, If caching is used (different from {@link SelectionCacheType#JUST_IN_TIME}),
 * then it should be at least this {@link SelectionCacheType} because an ancestor already uses such caching
 * and less would be pointless.
 * @param inheritedSelectionOrder never null
 * @return never null
 */
public PillarSelector buildPillarSelector(HeuristicConfigPolicy configPolicy,
        SelectionCacheType minimumCacheType, SelectionOrder inheritedSelectionOrder) {
    if (minimumCacheType.compareTo(SelectionCacheType.STEP) > 0) {
        throw new IllegalArgumentException("The pillarSelectorConfig (" + this + ")'s minimumCacheType ("
                + minimumCacheType + ") must not be higher than " + SelectionCacheType.STEP
                + " because the pillars change every step.");
    }
    // EntitySelector uses SelectionOrder.ORIGINAL because a DefaultPillarSelector STEP caches the values
    EntitySelectorConfig entitySelectorConfig_ = entitySelectorConfig == null ? new EntitySelectorConfig()
            : entitySelectorConfig;
    EntitySelector entitySelector = entitySelectorConfig_.buildEntitySelector(configPolicy, minimumCacheType,
            SelectionOrder.ORIGINAL);
    Collection<GenuineVariableDescriptor> variableDescriptors = entitySelector.getEntityDescriptor()
            .getGenuineVariableDescriptors();
    if (BooleanUtils.isFalse(subPillarEnabled)
            && (minimumSubPillarSize != null || maximumSubPillarSize != null)) {
        throw new IllegalArgumentException("The pillarSelectorConfig (" + this
                + ") must not have subPillarEnabled (" + subPillarEnabled + ") with minimumSubPillarSize ("
                + minimumSubPillarSize + ") and maximumSubPillarSize (" + maximumSubPillarSize + ").");
    }
    return new DefaultPillarSelector(entitySelector, variableDescriptors,
            inheritedSelectionOrder.toRandomSelectionBoolean(),
            subPillarEnabled == null ? true : subPillarEnabled,
            minimumSubPillarSize == null ? 1 : minimumSubPillarSize,
            maximumSubPillarSize == null ? Integer.MAX_VALUE : maximumSubPillarSize);
}

From source file:org.sonar.java.checks.BadMethodName_S00100_Check.java

private static boolean isNotOverriden(MethodTree methodTree) {
    return BooleanUtils.isFalse(((MethodTreeImpl) methodTree).isOverriding());
}

From source file:org.sonar.java.checks.ConfusingOverloadCheck.java

@Override
public void visitNode(Tree tree) {
    if (!hasSemantic()) {
        return;//from  w  w  w .  j  a v a2 s  . co m
    }
    MethodTreeImpl methodTree = (MethodTreeImpl) tree;
    if (BooleanUtils.isFalse(methodTree.isOverriding())) {
        MethodSymbol methodSymbol = methodTree.symbol();
        TypeSymbol owner = (TypeSymbol) methodSymbol.owner();
        Type superClass = owner.superClass();
        if (superClass != null && !SERIALIZATION_METHOD_NAME.contains(methodSymbol.name())) {
            boolean reportStaticIssue = checkMethod(methodTree.simpleName(), methodSymbol, superClass);
            superClass = superClass.symbol().superClass();
            while (superClass != null && !reportStaticIssue) {
                reportStaticIssue = checkStaticMethod(methodTree.simpleName(), methodSymbol, superClass);
                superClass = superClass.symbol().superClass();
            }
        }
    }
}

From source file:org.sonar.java.checks.ConstantMethodCheck.java

@Override
public void visitNode(Tree tree) {
    MethodTreeImpl methodTree = (MethodTreeImpl) tree;
    BlockTree body = methodTree.block();
    if (!methodTree.modifiers().annotations().isEmpty()
            || ModifiersUtils.hasModifier(methodTree.modifiers(), Modifier.DEFAULT)) {
        return;//from w ww.j  ava  2 s.  c o m
    }
    if (BooleanUtils.isFalse(methodTree.isOverriding()) && body != null && body.body().size() == 1) {
        StatementTree uniqueStatement = body.body().get(0);
        if (uniqueStatement.is(Kind.RETURN_STATEMENT)) {
            ExpressionTree returnedExpression = ((ReturnStatementTree) uniqueStatement).expression();
            if (isConstant(returnedExpression)) {
                reportIssue(returnedExpression, "Remove this method and declare a constant for this value.");
            }
        }
    }
}

From source file:org.sonar.java.checks.ForLoopFalseConditionCheck.java

private static boolean isAlwaysFalseCondition(ExpressionTree expression) {
    if (expression.is(Tree.Kind.BOOLEAN_LITERAL)) {
        return BooleanUtils.isFalse(booleanLiteralValue(expression));
    }//www.  j  a va  2 s .  co m
    if (expression.is(Tree.Kind.LOGICAL_COMPLEMENT)) {
        ExpressionTree subExpression = ((UnaryExpressionTree) expression).expression();
        return BooleanUtils.isTrue(booleanLiteralValue(subExpression));
    }
    return false;
}