Java Null Value Convert null2Boolean(Object expression, boolean defValue)

Here you can find the source of null2Boolean(Object expression, boolean defValue)

Description

null Boolean

License

Apache License

Declaration

public static boolean null2Boolean(Object expression, boolean defValue) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static boolean null2Boolean(Object expression, boolean defValue) {
        try {//w  ww.  j a  va2 s  .c om
            return Boolean.parseBoolean(null2String(expression));
        } catch (Exception e) {
            return defValue;
        }
    }

    public static String null2String(Object s) {
        return s == null ? "" : s.toString().trim();
    }
}

Related

  1. convertNullToSolrValue(String fieldName)
  2. convertNullToString(final String str)
  3. convertNullValue(final Class convertType)
  4. null2blank(String prnStr)
  5. null2blank(String source)
  6. null2Boolean(Object s)
  7. null2default(final String str, final String def)
  8. null2dots(Object s)
  9. null2Double(Object s)