Java Boolean From toBoolean(Object o)

Here you can find the source of toBoolean(Object o)

Description

to Boolean

License

Mozilla Public License

Declaration

public static Boolean toBoolean(Object o) 

Method Source Code

//package com.java2s;
/* SpagoBI, the Open Source Business Intelligence suite
    /*from   ww w .  ja va  2 s .  c om*/
 * Copyright (C) 2012 Engineering Ingegneria Informatica S.p.A. - SpagoBI Competency Center
 * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0, without the "Incompatible With Secondary Licenses" notice. 
 * If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */

public class Main {
    public static Boolean toBoolean(Object o) {
        Boolean toReturn;

        assertNotNull(o, "Input object cannot be null");

        if (o instanceof Boolean) {
            toReturn = (Boolean) o;
        } else {
            toReturn = new Boolean(toString(o));
        }

        return toReturn;
    }

    private static void assertNotNull(Object o, String message) {
        if (o == null) {
            throw new IllegalArgumentException(message);
        }
    }

    public static String toString(Object o) {
        String toReturn;

        assertNotNull(o, "Input object cannot be null");

        toReturn = o.toString();

        return toReturn;
    }
}

Related

  1. toBoolean(Number value)
  2. toBoolean(Object anObj)
  3. toBoolean(Object bool)
  4. toBoolean(Object o)
  5. toBoolean(Object o)
  6. toBoolean(Object o)
  7. toBoolean(Object obj)
  8. toBoolean(Object obj)
  9. toBoolean(Object obj)