All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.TKnudsen.ComplexDataObject.model.io.parsers.objects.BooleanParser Maven / Gradle / Ivy

Go to download

A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.

There is a newer version: 0.2.13
Show newest version
package com.github.TKnudsen.ComplexDataObject.model.io.parsers.objects;

/**
 * 

* Title: BooleanParser *

* *

* Description: *

* *

* Copyright: Copyright (c) 2016 *

* * @author Juergen Bernard * @version 1.0 */ public class BooleanParser implements IObjectParser { @Override public Boolean apply(Object object) { final String stringRepresentation = String.valueOf(object).toLowerCase(); switch (stringRepresentation) { case "false": case "FALSE": case "nein": case "Nein": case "0": case "0.0": case "n": case "no": case "No": return Boolean.FALSE; case "true": case "TRUE": case "j": case "ja": case "Ja": case "1": case "1.0": case "y": case "yes": case "Yes": return Boolean.TRUE; default: System.out.println("Object" + object + " could not be parsed to Boolean"); return null; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy