Java-需要从hashmap中添加和删除比较值而不是匹配键的逻辑

Java-需要从hashmap中添加和删除比较值而不是匹配键的逻辑,java,hashmap,Java,Hashmap,我的UI中有两个下拉列表,选择其中一个将为从下拉列表中选择的特定值配置另一组复选框。每次我在所选值和复选框中的值之间添加一些连接时,它应该保存在某个位置并正确标识元素,以便我可以删除它,仍然保留以前的价值观 --用户界面-- Select box <button style="display: none;" type="submit" id="selected" name="_eventId_getid"></button> <la

我的UI中有两个下拉列表,选择其中一个将为从下拉列表中选择的特定值配置另一组复选框。每次我在所选值和复选框中的值之间添加一些连接时,它应该保存在某个位置并正确标识元素,以便我可以删除它,仍然保留以前的价值观

--用户界面--

Select box
        <button style="display: none;" type="submit" id="selected" name="_eventId_getid"></button> 
        <label for="name" >Product</label> 
        <form:select path="selectedProduct" disabled="${isDisabled}" onchange="simulateClick('selected');">
            <form:option value="0">Select...</form:option>
            <form:options items="${createProject.product}" itemLabel="name" itemValue="id" />
        </form:select>
    checkbox, depending upon slectbox   
  <button style="display:none;" type="submit" id="selectCopyType" name="_eventId_submit"> </button>
        <c:if test="${not empty createProject.elementType}">    

                <button style="display: none;" type="submit" id="copy" name="_eventId_getId2"></button> 
                    <input class="checkAllCheckbox" id="selectall"  name="selectall" type="checkbox"/>
                    <span style="display:inline; margin-left:auto;">Select All</span>
                    <!-- id must be the same as listId above -->
                    <div class="CFbox" id="id"  >
                    <form:checkboxes items="${ProjectCommand.ElementType}" onclick="simulateClick('copy')" path="CopyType" cssClass="case" itemValue="id" itemLabel="name"  name="case"/>                   </div>
              </div> 

      Class Command
      private String seelctedProduct;
      private List<Integer> CopyType;
      private List<Class1> class1


  Class Class1


      private Integer seq = 0;
      private String product;
     private String ElementName

      public void getSelectedCopy(Command command)
      {
        Map<Integer,String[]>map= new HashMap<Integer,String[]>();
        if (command.CopyType() != null && command.getCopyType().size() > 0)
        {
          List<Class1> copyList = new ArrayList<Class1>();

          Integer Seq = 0;
         if (command.getClass1() != null && command.getClass1().size() <= command.getCopyType.size())
          {
            //Max CfSeq is stored in the variable -1 . 
           Seq = command.getClass1().get(command.getClass1.size() - 1).getSeq();    
          }

         for ( int copytype : command.getCopyType())
          {

           if (command.getCopyType().size() >1)
            { 
             if (copyType <= Seq)
              {
               copyList.add(command.getClass1().get(Seq - 1));
                continue;
              }
            }
            cfSeq++;

            map.put(Seq,new String[]{command.getseelctedProduct(),"copyType"});
            System.out.println("map"+map);
            Class1 objclass1= new Class1();
            objclass1.setProduct(command.getseelctedProduct());
            objclass1.setElementName(copyType + "");
            objclass1.setSeq(Seq);
            copyList.add(objclass1);

          }
          command.setClass1(copyList);
        }
        else
        {
          command.setClass1(null);
        }
      }

现在我没有得到正确的序号,我无法从地图中删除正确的成员。。希望你们能明白我的意思!!谢谢你的帮助。如果你有其他正确显示序列而不是每次清除对象的建议,我想我需要从hashmap中添加和删除比较值而不是匹配键的逻辑。。请建议

如果您的问题真的是要进行值->键查找,您应该查看番石榴或Commons系列

番石榴:

Commons collections bidimap:


Commons集合是一种古老而稳定的集合,而guava使用泛型提供了许多新的范例和类型安全性

你能发布你的实际代码吗。您的两个类都不是有效代码。