How to check for null values

This entry is part of the Maximo Java Development series.

A very common doubt when extending MBOs is what value returns the Mbo.getString() method when the target field has a null value. The answer is: It returns an empty string “”.
Thus to check if the DESCRIPTION of an Mbo is empty or null you can use two basic approaches.

getString("DESCRIPTION").equals("")

or

getString("DESCRIPTION").length()==0

If you need do distinguish between null values and empty string you can use the Mbo.getMboValueData() method.
Thus to check if the DESCRIPTION of an Mbo is null use this code snippet.

getMboValueData("DESCRIPTION").isNull()

If you are in an Mbo class you can perform the same check as follows:

isNull("DESCRIPTION")
How to check for null values

3 thoughts on “How to check for null values

  1. Utility-class psdi.util.StringUtility gives you isEmpty() method that checks if string is empty or null:

    if (!psdi.util.StringUtility.isEmpty(getString("DESCRIPTION"))) {

    }

    PS: check also com.ibm.tivoli.maximo.util.StringUtil

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top