Tag: Object row TE serial throw null return HASHMAP substr
Java uses the reflection mechanism to determine whether an object's properties are empty:
map<string,string> Validatemap = new linkedhashmap<string, string> ();
Validatemap.put ("Serial", "number");
Validatemap.put ("Major", "professional");
public static <T> String validatefiledisnull (map<string,string> fileds,t obj) throws exception{
String ret = "";
For (String Key:fileds.keySet ()) {
String getmethodstr = "Get" + key.substring (0,1). toUpperCase () +key.substring (1);
Method m = Obj.getclass (). GetMethod (GETMETHODSTR);
Object value = m.invoke (obj);
if (Value==null | | value.tostring (). Trim (). Equals ("")) {
if (!validatestring (ret)) {
Ret=fileds.get (key);
}else{
ret+= "," +fileds.get (key);
}
}
}
return ret;
}
Java uses reflection mechanism to determine whether an object's properties are empty