troubleshooting Question

Checking a map for a null value

Avatar of jkteater
jkteaterFlag for United States of America asked on
Java
8 Comments1 Solution233 ViewsLast Modified:
I have a method today that preforms a check to see if a value exist

//////////////////////////////////////////////////////////////////////////
   //                      prlvalueCheck()                                 //
   //////////////////////////////////////////////////////////////////////////
   public boolean prlValueCheck() {
      boolean prlValue = true;
       
      boolean matrixDest = dscheck;
          
      for (int i = 0; i < rds.size(); i++)  {
          try {
             String value = rds.get(i).rev.getRelatedComponent("IMAN_master_form_rev").getStringProperty("PRL");
             String value1 = rds.get(i).valuePRL;
             
             
             if ((value == null || value.trim().isEmpty()) && matrixDest == true) { 
                prlValue = false;
                break;
             }          
             
             if ((value == null || value.trim().isEmpty()) && value1.trim().isEmpty()) { 
                prlValue = false;
                break;
             }
          }
          catch (TCException e) {
             e.printStackTrace();
         }
      }
      return prlValue;
   }// end prlValueCheck()

What has changed

String value1 = rds.get(i).valuePRL;

Will now be checked from a map.  I understand that if the key is not created there is not a value - so something like

if(pmap.get(rds.get(row).rev) != null), 
could be used in place of String value 1

How should I address the logic for
 
 if ((value == null || value.trim().isEmpty()) && value1.trim().isEmpty()) { 

Something Like

value 1 = pmap.get(rds.get(row).rev)

then
 
 if ((value == null || value.trim().isEmpty()) && value1 == null)) { 
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros