ProductAttributeEnum extends ProductAttribute { public void restrictItemsTo(List<String> enumValues) { items = items.stream().filter(item -> enumValues.contains(item.getValue())).collect(Collectors.toList()); }  void addItem(ProductAttributeEnumItem item); @Override void mergeWith(ProductAttribute newAttribute); @Override String getName(); void restrictItemsTo(List<String> enumValues);  }
@Test public void testRestrictItemsTo() { ProductAttributeEnum attributeEnum = new ProductAttributeEnum(); attributeEnum.addItem(new ProductAttributeEnumItem("value", "label")); attributeEnum.addItem(new ProductAttributeEnumItem("value2", "label2")); attributeEnum.restrictItemsTo(Arrays.asList("value")); assertEquals("Size", 1, attributeEnum.getItems().size()); assertEquals("Size", "value", attributeEnum.getItems().get(0).getValue()); }