luni, 27 aprilie 2015

[OmniFaces utilities (2.0)] Get the first non-null object of the argument list, or null if there is no such element


[OmniFaces utilities] The coalesce() method returns the first non-null object of the argument list, or null if there is no such element.

Method:
Usage:

import org.omnifaces.util.Utils;
...
Object object = null;
StringBuilder sb = null;
BigDecimal ten = BigDecimal.TEN;

// returns BigDecimal.TEN, 10
Object notNull = Utils.coalesce(object, sb, ten);

Niciun comentariu:

Trimiteți un comentariu