首页 > 编程知识 正文

判断map是否为空和null,stringutils源码

时间:2023-05-03 21:06:16 阅读:160046 作者:639

stringutils是目标和目标中的映射列表为空的公共类映射列表空(if ) objinstanceofstringobj.tostring ).trim ).length )==0) thrownewillegalargumentexception )消息' m usage ) h ) obj )==0) thrownewillegalargumentexception )消息' must bion } 物件注解((collection ) obj ).isEmpty )传递消息' mustbespeper ' 对象偏移映射(map ) obj (.isempty ) )消息传递,映射if(obj==null ) {result=true; 返回结果; } objinstanceofstringobj.tostring (.trim ).length )==0) {result=true; 返回结果; } if (obj.getclass.isarray ) ) array.getlength(obj )==0) ) {result=true; 返回结果; }if(objinstanceofcollection () obj ).isEmpty ) ) {result=true; 返回结果; }if(objinstanceofmap () map (obj ).isEmpty ) ) {result=true; 返回结果; }return result; } publicstaticvoidisnullandthrowexp (string [ ] msg,Object. o ) string buffer buffer=new string buffer ); if(msg.Length1!=o.length (thrownewillegalargumentexception (strs ' slengthisnotequlaschecknames ' s length ); for(intI=1; i o.length; I ) ({ //student.getmap ) )的值为nullif ) isnull(o ) I ) ) buffer.append ) msg(I-1 ) ','); }if(buffer.tostring ) ).endsWith ),) ) buffer.deletecharat ) buffer.length(-1 ); buffer.append(mustbespecified ); thrownewillegalargumentexception (buffer.tostring ); } publicstaticvoidmain (string [ ] args ) Throwsexception ) studentstudent=newstudent ); sudent.setage(11; student.setNameString (' ); student.setPeople(true; arraylistobjectlist=newarraylistobject (; list.add (' ); sudent.setlist(list; MapObject,Object map=new HashMapObject,Object (; //map.put (',''); sudent.setmap(map; isnullandthrowexp (new string [ ] { ' age ',' nameString ',' isPeople ',' list ',' map ' ),student,student.getAge }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。