Class ObjectTool


  • public class ObjectTool
    extends org.apache.commons.lang3.ObjectUtils
    Miscellaneous methods around objects, including checks for null.
    Since:
    12.1
    Version:
    $Id: 3e395cbe897279a595557f7a7481908866d2ed66 $
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.apache.commons.lang3.ObjectUtils

        org.apache.commons.lang3.ObjectUtils.Null
    • Field Summary

      • Fields inherited from class org.apache.commons.lang3.ObjectUtils

        NULL
    • Constructor Summary

      Constructors 
      Constructor Description
      ObjectTool()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Object getNull()
      Convenience method since Velocity doesn't have a way to create a null object.
      boolean isNotNull​(Object object)  
      boolean isNull​(Object object)
      It's not always easy with Velocity to check for null.
      • Methods inherited from class org.apache.commons.lang3.ObjectUtils

        allNotNull, allNull, anyNotNull, anyNull, clone, cloneIfPossible, compare, compare, CONST, CONST, CONST, CONST, CONST, CONST, CONST, CONST, CONST, CONST_BYTE, CONST_SHORT, defaultIfNull, equals, firstNonNull, getFirstNonNull, getIfNull, hashCode, hashCodeMulti, identityToString, identityToString, identityToString, identityToString, identityToString, isEmpty, isNotEmpty, max, median, median, min, mode, notEqual, requireNonEmpty, requireNonEmpty, toString, toString, toString, wait
    • Constructor Detail

      • ObjectTool

        public ObjectTool()
    • Method Detail

      • isNull

        public boolean isNull​(Object object)
        It's not always easy with Velocity to check for null. You can use some tricks such as #if ($variable == $NULL) or #if (!$variable). However Velocity performs some conversions, calling methods such as getAsBoolean() or getAsString(). There are cases when you don't want them to be called as they can clash with your own implementation (note: this is the case for JsonObject from gson for ex). If you need to check only for null, this method is probably the best for that.
        Parameters:
        object - the object to test for null
        Returns:
        true if the object is null or false otherwise
      • isNotNull

        public boolean isNotNull​(Object object)
        Parameters:
        object - the object to test for not null
        Returns:
        true if the object is not null or false otherwise
        See Also:
        isNull(Object)
      • getNull

        public Object getNull()
        Convenience method since Velocity doesn't have a way to create a null object.
        Returns:
        a null object