sunclf

Untitled

Dec 7th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. public static List<BagRule> bagsThatCanHoldBag(String sentColor, String sentAttribute, List<BagRule> sentList) {
  2.         List<BagRule> list = new ArrayList<>();
  3.  
  4.         for (BagRule bag : sentList) {
  5.             BidiMap<String, String> map = bag.getContentsColorAttributeMap();
  6.             String color = map.getKey(sentAttribute);
  7.             String attr = null;
  8.  
  9.             if (color != null) {
  10.                 attr = map.get(color);
  11.             }
  12.  
  13.             if (color == null || attr == null) {
  14.                 continue;
  15.             } else if (!color.equals(sentColor) || !attr.equals(sentAttribute)) {
  16.                 continue;
  17.             } else {
  18.                 list.add(bag);
  19.             }
  20.         }
  21.  
  22.         return list;
  23.     }
Add Comment
Please, Sign In to add comment