title: Modifying a list of objects in java
body: <p><strong>Requirement -</strong></p>
  <p>I have a list of objects as given below -</p>
  <pre><code>[
  TestObj{levelCode='123', operId='ABC', hrchyInd='S'},
  TestObj{levelCode='456', operId='DEF', hrchyInd='S'},
  TestObj{levelCode='123', operId='ABC', hrchyInd='M'}
  ]
  </code></pre>
  <p>My desired output is -</p>
  <pre><code>[
  TestObj{levelCode='123', operId='ABC', hrchyInd='B'},
  TestObj{levelCode='456', operId='DEF', hrchyInd='S'},
  ]
  </code></pre>
  <p>If two <code>TestObj</code> in the list are having the same <code>levelCode &amp;&amp; OperId</code> but different <code>hrchyInd</code> then we should include only one <code>TestObj</code> out of the two in the output list and modify the <code>hrchyInd</code> as <code>B</code>.</p>
  <pre><code>import lombok.AllArgsConstructor;
  import lombok.Builder;
  import lombok.Data;
  import lombok.ToString;
  
  @Data
  @AllArgsConstructor
  @ToString
  @Builder
  public class TestObj {
      private String levelCode;
      
      private String operId;
      
      private String hrchyInd;
  }
  </code></pre>
  <p><em><strong>Can anyone please help me to solve this problem in an optimal way.</strong></em></p>