mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-20 06:00:44 +00:00
Add good getFirstNonNull method
This commit is contained in:
@ -728,4 +728,29 @@ public class ValueUtils
|
||||
.with(ChronoField.NANO_OF_DAY, 0);
|
||||
return (startOfMonth.toInstant(zone.getRules().getOffset(computerTime)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Return the first argument that isn't null.
|
||||
** If all were null, return null.
|
||||
*******************************************************************************/
|
||||
public static <T> T getFirstNonNull(T... ts)
|
||||
{
|
||||
if(ts == null || ts.length == 0)
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
|
||||
for(T t : ts)
|
||||
{
|
||||
if(t != null)
|
||||
{
|
||||
return (t);
|
||||
}
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user