java - Is it Possible to Check Received fields are Empty or Null Without If -


i receiving list of fields. near 60 fields.

from have check 50 fields null or empty, if not ll have add them in db table.

right doing manually using if condition. thinking so, not implemented still yet.

is there better option ?

my code :

if(validatedata.checkisnullorempty(command.getsubscriptionstartyear())){  } if(validatedata.checkisnullorempty(command.getsubscriptionperiod())){  } if(validatedata.checkisnullorempty(command.getexpectedarrivaltimeofissues())){  } ..... .....  if(validatedata.checkisnullorempty(command.getmaxnoofclaims())){  } 

here command class receives data source.

here validatedata class :

it's method definition :

public static boolean checkisnullorempty(integer arg){     if(arg != null) return true;     return false; }  public static boolean checkisnullorempty(string arg){      if(!arg.trim().equals("") || !arg.trim().equals(" ") || arg.trim() != null) return true;      return false; } 

if guide me or suggest me there better option available ??

create function this:

public static bool allnull(object... something) {     for(var v :something)        if(v!=null){          if(v instanceof integer)            // integer validation        }else          //err msg } 

then call this:

if (allnull(obj1, obj2, obj3, obj4, obj5, obj6)) {     // ... } 

if want specific, separate strings , integers , make separate function 1 each type need

edit

as understod comment, u don't know varargs

varargs useful method needs deal indeterminate number of objects. 1 example string.format.


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -