Java String to Boolean asBoolean(String flag)

Here you can find the source of asBoolean(String flag)

Description

Converts the given string into a Boolean flag of either true, false or null.

License

Open Source License

Declaration

public static Boolean asBoolean(String flag) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static final String YES_AS_STRING = "Y";

    /**//www.j av  a2s  . c  o  m
     * Converts the given string into a Boolean flag of either true, false or
     * null.
     */
    public static Boolean asBoolean(String flag) {
        return flag == null ? null : flag.equals(YES_AS_STRING);
    }
}

Related

  1. asBoolean(String name, boolean value)
  2. asBoolean(String s)
  3. asBoolean(String str)
  4. asBoolean(String string)