Example usage for java.lang Boolean booleanValue

List of usage examples for java.lang Boolean booleanValue

Introduction

In this page you can find the example usage for java.lang Boolean booleanValue.

Prototype

@HotSpotIntrinsicCandidate
public boolean booleanValue() 

Source Link

Document

Returns the value of this Boolean object as a boolean primitive.

Usage

From source file:eu.planets_project.tb.gui.backing.data.DigitalObjectBrowser.java

/** */
public static void toggleSelectAll(ValueChangeEvent event) {
    Boolean newValue = (Boolean) event.getNewValue();
    if (newValue.booleanValue() == true) {
        DigitalObjectBrowser.selectAll();
    } else {//from  w w  w  .  j  ava 2s  .  c  o m
        DigitalObjectBrowser.unselectAll();
    }
}

From source file:business.services.RequestService.java

final static String booleanToString(Boolean value) {
    if (value == null)
        return "";
    if (value.booleanValue()) {
        return "Yes";
    } else {//from  w w  w.  j  ava 2 s . com
        return "No";
    }
}

From source file:com.qmetry.qaf.automation.util.StringUtil.java

/**
 * This method will will consider:/*  ww w.j a va  2 s.c  o m*/
 * <ul>
 * <li>"true", "True", "T", "t", "Y", "Yes", "YES", "On", "ON", "oN" as
 * true.
 * <li>"0" is false, "1" as true ("0" or negative as false and non-zero
 * positive integer as true.)
 * </ul>
 * 
 * @param sVal
 *            string value
 * @param defaultValue
 *            value to be return if provided string is blank or null
 * @return boolean value for the string.
 */
public static boolean booleanValueOf(String sVal, Boolean defaultValue) {
    if (isBlank(sVal)) {
        return null == defaultValue ? false : defaultValue.booleanValue();
    }
    sVal = sVal.trim();
    boolean val = isNumeric(sVal) ? (Integer.parseInt(sVal) != 0)
            : Boolean.parseBoolean(sVal) || sVal.equalsIgnoreCase("T") || sVal.equalsIgnoreCase("Y")
                    || sVal.equalsIgnoreCase("YES") || sVal.equalsIgnoreCase("ON");

    return val;

}

From source file:com.evolveum.midpoint.provisioning.impl.mock.SynchornizationServiceMock.java

private static boolean isDryRun(Task task) {

    Validate.notNull(task, "Task must not be null.");

    if (task.getExtension() == null) {
        return false;
    }/*w w  w.j a va  2s  . c o  m*/

    PrismProperty<Boolean> item = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_DRY_RUN);
    if (item == null || item.isEmpty()) {
        return false;
    }

    if (item.getValues().size() > 1) {
        return false;
        //            throw new SchemaException("Unexpected number of values for option 'dry run'.");
    }

    Boolean dryRun = item.getValues().iterator().next().getValue();

    if (dryRun == null) {
        return false;
    }

    return dryRun.booleanValue();
}

From source file:com.p5solutions.trackstate.utils.TrackStateUtility.java

/**
 * Checks for any changes made on a specific {@link TrackState} proxy. If the
 * object has not been proxied, the values are checked for <code>null</code>,
 * if all values for the specific searching class type are null, then
 * <code>false</code> is returned, otherwise <code>true</code>.
 * /*w w  w.  j a v  a2 s . c  o  m*/
 * @param object
 *          The object in question.
 * @param forClazz
 *          The {@link Class} type to filter down the search to.
 * 
 * @return <code>true</code>, if the object should be persisted, otherwise
 *         <code>false</code>.
 */
public static boolean hasChangesOrIsNew(Object object, Class<?> forClazz) {
    Boolean hasChanged = hasChanges(object, forClazz);
    // if there are no changes, then its a new object
    if (hasChanged == null) {
        // if the values are all null then return false
        return !areValuesNull(object, forClazz);
    }
    return hasChanged.booleanValue();
}

From source file:com.link_intersystems.lang.Conversions.java

/**
 * Unboxes the primitiveWrapper by calling the {@link PrimitiveCallback}.
 *
 * @param primitiveWrapper//from  w w w. j a v a2  s  . c om
 * @param primitiveCallback
 *
 * @see PrimitiveCallbackAdapter
 * @see PrimitiveArrayCallback
 * @since 1.0.0.0
 */
public static void unbox(Object primitiveWrapper, PrimitiveCallback primitiveCallback) {
    if (primitiveWrapper instanceof Boolean) {
        Boolean value = (Boolean) primitiveWrapper;
        primitiveCallback.primitive(value.booleanValue());
    } else if (primitiveWrapper instanceof Byte) {
        Byte value = (Byte) primitiveWrapper;
        primitiveCallback.primitive(value.byteValue());
    } else if (primitiveWrapper instanceof Character) {
        Character value = (Character) primitiveWrapper;
        primitiveCallback.primitive(value.charValue());
    } else if (primitiveWrapper instanceof Short) {
        Short value = (Short) primitiveWrapper;
        primitiveCallback.primitive(value.shortValue());
    } else if (primitiveWrapper instanceof Integer) {
        Integer value = (Integer) primitiveWrapper;
        primitiveCallback.primitive(value.intValue());
    } else if (primitiveWrapper instanceof Long) {
        Long value = (Long) primitiveWrapper;
        primitiveCallback.primitive(value.longValue());
    } else if (primitiveWrapper instanceof Float) {
        Float value = (Float) primitiveWrapper;
        primitiveCallback.primitive(value.floatValue());
    } else if (primitiveWrapper instanceof Double) {
        Double value = (Double) primitiveWrapper;
        primitiveCallback.primitive(value.doubleValue());
    } else {
        throw new IllegalArgumentException("primitiveWrapper is not a primitiveWrapper type");
    }
}

From source file:org.wso2.carbon.appmgt.gateway.utils.GatewayUtils.java

public static boolean shouldSkipSecurity(MessageContext messageContext) {

    Boolean shouldSkipSecurity = (Boolean) messageContext
            .getProperty(AppMConstants.MESSAGE_CONTEXT_PROPERTY_GATEWAY_SKIP_SECURITY);

    if (shouldSkipSecurity != null) {
        return shouldSkipSecurity.booleanValue();
    } else {// ww w  .jav a2 s . c o  m
        return false;
    }
}

From source file:net.roboconf.target.docker.internal.DockerUtils.java

/**
 * Handles Boolean values./*from   w w w .  j  ava 2 s . c o m*/
 * <p>
 * Docker-java 3.x annotates state methods with "@CheckNotNull".
 * So, we must verify the state attributes are not null (why Boolean instead of boolean?!).
 * </p>
 *
 * @param bool a Boolean value
 * @return the boolean value, or <code>false</code> if it was null
 */
public static boolean extractBoolean(Boolean bool) {
    return bool != null ? bool.booleanValue() : false;
}

From source file:net.jcreate.e3.table.html.HTMLTableHelper.java

public static NavRequest getNavRequest(String pTableID, WebContext pWebContext, int pPageSize) {

    Boolean enableStateManager = (Boolean) pWebContext
            .getSessionAttribute(TableConstants.ENABLED_STATE_MANAGER_PREFIX + pTableID);
    String start = pWebContext.getParameter(TableConstants.START_PARAM + "_" + pTableID);
    if (start == null) {//???????.
        if (enableStateManager != null) {
            if (enableStateManager.booleanValue() == true) {
                NavRequest result = getNavRequestFromState(pTableID, pWebContext);
                if (result != null) {
                    return result;
                }//  www.j a va2 s . com
            }
        }
    }
    NavRequest result = new NavRequest();
    //?
    if (logger.isDebugEnabled()) {
        Map params = pWebContext.getParameterMap();
        java.util.Iterator paramKeys = params.keySet().iterator();
        while (paramKeys.hasNext()) {
            Object key = paramKeys.next();
            if (key instanceof String == false) {
                continue;
            }
            Object value = params.get(key);

            if (value instanceof String[] == false) {
                continue;
            }
            //?
            logger.debug((String) (key) + "=" + ((String[]) value)[0]);
        }
    }
    String pageSize = pWebContext.getParameter(TableConstants.PAGE_SIZE_PARAM + "_" + pTableID);
    String sortColumn = pWebContext.getParameter(TableConstants.SORT_PROPERTY_PARAM + "_" + pTableID);
    String sortName = pWebContext.getParameter(TableConstants.SORT_NAME_PARAM + "_" + pTableID);
    String sortDir = pWebContext.getParameter(TableConstants.SORT_DIR_PARAM + "_" + pTableID);

    if (start == null) {
        result.setStart(0);
        result.setPageSize(pPageSize);
    } else {
        result.setStart(Integer.parseInt(start));
        result.setPageSize(Integer.parseInt(pageSize));
    }

    result.setSortProperty(sortColumn);
    result.setSortDir(sortDir);
    result.setSortName(sortName);
    return result;

}

From source file:com.qmetry.qaf.automation.util.StringUtil.java

public static boolean seleniumEquals(String expectedPattern, String actual) {

    if ((expectedPattern == null) || (actual == null)) {
        return expectedPattern == actual;
    }/* w  w w. j a v a 2s  .com*/
    if (actual.startsWith("regexp:") || actual.startsWith("regex:") || actual.startsWith("regexpi:")
            || actual.startsWith("regexi:") || actual.startsWith("start:") || actual.startsWith("end:")
            || actual.startsWith("in:")) {
        // swap 'em
        String tmp = actual;
        actual = expectedPattern;
        expectedPattern = tmp;
    }
    if (expectedPattern.startsWith("start:")) {
        return actual.startsWith(expectedPattern.replaceFirst("start:", ""));
    }
    if (expectedPattern.startsWith("end:")) {
        return actual.endsWith(expectedPattern.replaceFirst("end:", ""));
    }
    if (expectedPattern.startsWith("in:")) {
        return actual.contains(expectedPattern.replaceFirst("in:", ""));
    }
    Boolean b;
    b = handleRegex("regexp:", expectedPattern, actual, 0);
    if (b != null) {
        return b.booleanValue();
    }
    b = handleRegex("regex:", expectedPattern, actual, 0);
    if (b != null) {
        return b.booleanValue();
    }
    b = handleRegex("regexpi:", expectedPattern, actual, Pattern.CASE_INSENSITIVE);
    if (b != null) {
        return b.booleanValue();
    }
    b = handleRegex("regexi:", expectedPattern, actual, Pattern.CASE_INSENSITIVE);
    if (b != null) {
        return b.booleanValue();
    }

    if (expectedPattern.startsWith("exact:")) {
        String expectedExact = expectedPattern.replaceFirst("exact:", "");
        if (!expectedExact.equals(actual)) {
            System.out.println("expected " + actual + " to match " + expectedPattern);
            return false;
        }
        return true;
    }

    String expectedGlob = expectedPattern.replaceFirst("glob:", "");
    expectedGlob = expectedGlob.replaceAll("([\\]\\[\\\\{\\}$\\(\\)\\|\\^\\+.])", "\\\\$1");

    expectedGlob = expectedGlob.replaceAll("\\*", ".*");
    expectedGlob = expectedGlob.replaceAll("\\?", ".");
    if (!Pattern.compile(expectedGlob, Pattern.DOTALL).matcher(actual).matches()) {
        System.out.println("expected \"" + actual + "\" to match glob \"" + expectedPattern
                + "\" (had transformed the glob into regexp \"" + expectedGlob + "\"");
        return false;
    }
    return true;
}