Example usage for java.lang Boolean TRUE

List of usage examples for java.lang Boolean TRUE

Introduction

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

Prototype

Boolean TRUE

To view the source code for java.lang Boolean TRUE.

Click Source Link

Document

The Boolean object corresponding to the primitive value true .

Usage

From source file:Main.java

public static boolean isNvl(Object obj) {
    if (null == obj || obj.equals("")) {
        return Boolean.TRUE;
    }//w w  w. j a  v a  2 s .  c  o m
    return Boolean.FALSE;
}

From source file:Main.java

public static <T> Boolean isEmptySafe(Iterable<T> iterable) {

    if (iterable == null) {
        return Boolean.TRUE;
    }//from   w w w  .  j  ava  2  s . c  o  m

    int size = Iterables.size(iterable);

    return size < 1;
}

From source file:Main.java

public static Boolean readBoolean(ByteArrayInputStream bais) {
    int b = bais.read();
    if (b == 0) {
        return Boolean.FALSE;
    } else {//  w w w.j av a  2  s  . com
        return Boolean.TRUE;
    }
}

From source file:com.mongodb.hadoop.examples.wordcount.split.WordCountSplitTest.java

public static void main(String[] args) throws Exception {
    boolean useQuery = false;
    boolean testSlaveOk = false;
    for (int i = 0; i < args.length; i++) {
        final String argi = args[i];
        if (argi.equals("--use-query"))
            useQuery = true;//from ww w.  j a  va 2s  .c  om
        else if (argi.equals("--test-slave-ok"))
            testSlaveOk = true;
        else {
            System.err.println("Unknown argument: " + argi);
            System.exit(1);
        }
    }
    boolean[] tf = { false, true };
    Boolean[] ntf = { null };
    if (testSlaveOk)
        ntf = new Boolean[] { null, Boolean.TRUE, Boolean.FALSE };
    for (boolean use_shards : tf)
        for (boolean use_chunks : tf)
            for (Boolean slaveok : ntf)
                test(use_shards, use_chunks, slaveok, useQuery);
}

From source file:Main.java

public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
    Map<Object, Boolean> seen = new ConcurrentHashMap<>();
    return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
}

From source file:Main.java

public static String object2Xml(Object obj) throws JAXBException {
    JAXBContext context = JAXBContext.newInstance(obj.getClass());
    Marshaller marshaller = context.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);

    StringWriter writer = new StringWriter();
    marshaller.marshal(new JAXBElement(new QName("xml"), obj.getClass(), obj), writer);

    return writer.toString();
}

From source file:Main.java

public static <T> Boolean isEmpty(T[] arr) {
    if (arr == null || arr.length < 1) {
        return Boolean.TRUE;
    }//  w  ww  . j  ava 2 s .  c o  m
    return Boolean.FALSE;
}

From source file:Main.java

public static <T> String toString(T xml) {
    JAXBContext jc;/*w  w w.  j a v a2s  .c o m*/
    try {
        jc = JAXBContext.newInstance(xml.getClass());
        Marshaller m = jc.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        StringWriter writer = new StringWriter();
        m.marshal(xml, writer);
        return writer.toString();
    } catch (JAXBException e) {
        return "";
    }
}

From source file:Main.java

public static void saveInstance(File outputFile, Object instance) throws JAXBException, IOException {
    Marshaller marshaller = JAXBContext.newInstance(instance.getClass()).createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    marshaller.marshal(instance, outputFile);
}

From source file:Main.java

public static int countTrue(String propertyName, Collection<?> collection) {

    int count = 0;
    for (Object o : collection) {
        BeanWrapper bw = new BeanWrapperImpl(o);
        Boolean propertyValue = (Boolean) bw.getPropertyValue(propertyName);
        if (Boolean.TRUE.equals(propertyValue)) {
            count++;/*from w w  w . j a  va 2 s .co m*/
        }
    }
    return count;
}