title: Firebase Rest Api reading data from my model classes return null
body: <p>I am trying to run a Get method in java Restful API. I have tried naming my model classes similar to my real-time firebase that wasn't the issue.</p>
  <p><a href="https://i.stack.imgur.com/Gu3qF.png" rel="nofollow noreferrer">This is my real-time firebase. reference is Devices/Lamp/Ambient  </a></p>
  <p>Here is my model class</p>
  <pre><code> private String LightSwitch;
      private String DoorSwitch;
  
      // empty COnstructor
      public DeviceTest() { }
  
      public DeviceTest(String lightSwitch, String doorSwitch) {
          LightSwitch = lightSwitch;
          DoorSwitch = doorSwitch;
      }
  
      public String getLightSwitch() {
          return LightSwitch;
      }
  
      public void setLightSwitch(String lightSwitch) {
          LightSwitch = lightSwitch;
      }
  
      public String getDoorSwitch() {
          return DoorSwitch;
      }
  
      public void setDoorSwitch(String doorSwitch) {
          DoorSwitch = doorSwitch;
      }
  }
  
  </code></pre>
  <p>Here is my readFirebase Method</p>
  <pre><code>public static List&lt;DeviceTest&gt; handleLight() {
          FireBaseService fbs = null;
          fbs = new FireBaseService();
        device = new DeviceTest();
          mylist = new ArrayList&lt;&gt;();
          DatabaseReference ref = fbs.getDb()
                  .getReference(&quot;/Devices/Lamp&quot;);
          ref.child(&quot;Ambient&quot;)
                  .addValueEventListener(new ValueEventListener() {
                      @Override
                      public void onDataChange(DataSnapshot dataSnapshot) {
                          device = dataSnapshot.getValue(DeviceTest.class);
                          mylist = new ArrayList&lt;&gt;();
                          for (DataSnapshot unit : dataSnapshot.getChildren()) {
                              DeviceTest value = unit.getValue(DeviceTest.class);
                              mylist.add(value);
  
                          }
                      }
  
                      @Override
                      public void onCancelled(DatabaseError databaseError) {
  
                      }
                  });
  //mylist.add(device);
          return mylist;
      }
  </code></pre>
  <p>Here is the GET method</p>
  <pre><code>@Path(&quot;/devices&quot;)
  public class DeviceResource {
      
      DeviceService deviceService = new DeviceService();
  
      @GET
      @Produces(MediaType.APPLICATION_JSON)
      public List&lt;DeviceTest&gt; getCustomers(){
          return FireBaseService.handleLight();
      }
  
  </code></pre>
  <p><a href="https://i.stack.imgur.com/l5zSZ.png" rel="nofollow noreferrer">Here is the null value in my postman</a></p>