troubleshooting Question

Java if condition check for empty and null values

Avatar of yescobar01
yescobar01 asked on
3 Comments1 Solution341 ViewsLast Modified:
How can I write a condition in java for a webservice request, In my webservice request I am passing an element that has `SpeedInfo`. In `SpeedInfo` element there is two sub elements `Bandwidth` and `AccessSpeed`.

This is my Request In SoapUI:

            <ns:Bandwidth xmlns:ns="">4000000</ns:Bandwidth>
            <ns:AccessSpeed xmlns:ns="">4000000</ns:AccessSpeed>
My Java condition:

			if (request.getSpeedInfo() == null || (request.getSpeedInfo() == null && request.getSpeedInfo().getBandwidth() == null)){
				throw new Exception(" SpeedInfo Bandwidth must be passed in the request ");

I need my condition to check for 3 scenarios:
     1. if <speedInfo> itself is not present

     2. <sch:SpeedInfo> is present, but bandwidth not present:
          <ns:AccessSpeed xmlns:ns="">40000000</ns:AccessSpeed>

     3. Bandwidth is present but no value  
          <ns:Bandwidth xmlns:ns=""></ns:Bandwidth>
          <ns:AccessSpeed xmlns:ns="">40000000</ns:AccessSpeed>
IT Business Systems Analyst / Software Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2015

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
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 3 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