title: Organizing, implementing and querying data-structure classes in Java
body: <p>I am teaching my self to code in Java. I am a beginner but not totally clueless about programing. I have decided to make an application that tracks tickets, clients and devices for a computer repair shop. I have made a "lot" of code for that application, but as I said I am a beginner can I don know what is the "right way"(best, smartest and convenient) to implement the data-structure of the application.</p>
  
  <p>I decided to use custom data classes that are value objects in HashMap with integer keys, and that represent data tables that mirror data tables in databases. Am I doing it wrong?</p>
  
  <pre><code>public class Clients
  {
      private String firstName;
      private String lastName;
      private String primePhoneNum;
      private String secondPhoneNum;
      private String email;
      private String address;
      private MarketingTypes marketing;
  
     //getters and setters
  }
  
  public HashMap&lt;Integer,Clients&gt; clientsTable = new HashMap&lt;Integer, Clients&gt;();
  </code></pre>
  
  <p>I ran in to trouble when I tried to make search function that returns value object in a HashMap based on that object particular field value. For example:</p>
  
  <pre><code>public class SearchDeviceTypes
  {   
      private Map&lt;Integer, DeviceTypes&gt; deviceTypesTable;
  
      public SearchDeviceTypes(Map&lt;Integer, DeviceTypes&gt; deviceTypesTable)
      {
          this.deviceTypesTable = deviceTypesTable;
      }
  
      public boolean isNameTaken(String name)
      {
          return deviceTypesTable.entrySet().stream()
                  .anyMatch(deviceType-&gt;deviceType.getValue().getName().equals(name));
      }
  
      public DeviceTypes getByID(int id)
      {
          return deviceTypesTable.get(id);
      }
  
      public Map&lt;Integer, DeviceTypes&gt; filterByName(String text)
      {
          return  deviceTypesTable.entrySet().stream()
                  .filter(deviceType-&gt;deviceType.getValue().getName().contains(text))
                  .collect(Collectors.toMap(deviceType -&gt; deviceType.getKey(), deviceType -&gt; deviceType.getValue())); 
      }
  
      public DeviceTypes getByName(String name)
      {
          //How to implement this?
          return null;
      }
  }
  </code></pre>
  
  <p>I would like to help me to learn how to implement this kind of data structure. Thank you in advance!</p>