@Test public void testGetChildCategories() { final DetailCategory parent = new DetailCategory(null, "ab", "", false, null, null); final DetailCategory childA = new DetailCategory(parent, "a", "", true, null, null); final DetailCategory subParentB = new DetailCategory(parent, "b", "", false, null, null); final DetailCategory childB1 = new DetailCategory(subParentB, "b1", "", true, null, null); final DetailCategory childB2 = new DetailCategory(subParentB, "b2", "", true, null, null); final DetailCategory standalone = new DetailCategory(null, "c", "", true, null, null); this.model.addAll(Arrays.asList(parent, childA, subParentB, childB1, childB2, standalone)); Assert.assertEquals(Arrays.asList(parent, standalone), this.model.getChildCategories(null)); Assert.assertEquals(Arrays.asList(childA, subParentB), this.model.getChildCategories(parent)); Assert.assertEquals(Collections.emptyList(), this.model.getChildCategories(childA)); Assert.assertEquals(Arrays.asList(childB1, childB2), this.model.getChildCategories(subParentB)); Assert.assertEquals(Collections.emptyList(), this.model.getChildCategories(childB1)); Assert.assertEquals(Collections.emptyList(), this.model.getChildCategories(childB2)); Assert.assertEquals(Collections.emptyList(), this.model.getChildCategories(standalone)); }
public List<DetailCategory> getChildCategories(final DetailCategory parent) { final List<DetailCategory> children = new LinkedList<>(); for (final DetailCategory singleCategory : this.categoryByCode.values()) { if (ComparisonUtil.isNullAwareEqual(singleCategory.getParent(), parent)) { children.add(singleCategory); } } return children; }
MutableDetailCategoryModel implements IDetailCategoryProvider { public List<DetailCategory> getChildCategories(final DetailCategory parent) { final List<DetailCategory> children = new LinkedList<>(); for (final DetailCategory singleCategory : this.categoryByCode.values()) { if (ComparisonUtil.isNullAwareEqual(singleCategory.getParent(), parent)) { children.add(singleCategory); } } return children; } }
MutableDetailCategoryModel implements IDetailCategoryProvider { public List<DetailCategory> getChildCategories(final DetailCategory parent) { final List<DetailCategory> children = new LinkedList<>(); for (final DetailCategory singleCategory : this.categoryByCode.values()) { if (ComparisonUtil.isNullAwareEqual(singleCategory.getParent(), parent)) { children.add(singleCategory); } } return children; } MutableDetailCategoryModel(); }
MutableDetailCategoryModel implements IDetailCategoryProvider { public List<DetailCategory> getChildCategories(final DetailCategory parent) { final List<DetailCategory> children = new LinkedList<>(); for (final DetailCategory singleCategory : this.categoryByCode.values()) { if (ComparisonUtil.isNullAwareEqual(singleCategory.getParent(), parent)) { children.add(singleCategory); } } return children; } MutableDetailCategoryModel(); MutableDetailCategoryModel add(final DetailCategory category); MutableDetailCategoryModel addAll(final List<DetailCategory> categories); MutableDetailCategoryModel reset(final List<DetailCategory> categories); @Override List<DetailCategory> provide(); @Override List<DetailCategory> provideSelectables(); List<DetailCategory> getRootCategories(); List<DetailCategory> getChildCategories(final DetailCategory parent); DetailCategory getDetailByCode(final String detailCode); @Override int hashCode(); @Override boolean equals(final Object otherObject); }
MutableDetailCategoryModel implements IDetailCategoryProvider { public List<DetailCategory> getChildCategories(final DetailCategory parent) { final List<DetailCategory> children = new LinkedList<>(); for (final DetailCategory singleCategory : this.categoryByCode.values()) { if (ComparisonUtil.isNullAwareEqual(singleCategory.getParent(), parent)) { children.add(singleCategory); } } return children; } MutableDetailCategoryModel(); MutableDetailCategoryModel add(final DetailCategory category); MutableDetailCategoryModel addAll(final List<DetailCategory> categories); MutableDetailCategoryModel reset(final List<DetailCategory> categories); @Override List<DetailCategory> provide(); @Override List<DetailCategory> provideSelectables(); List<DetailCategory> getRootCategories(); List<DetailCategory> getChildCategories(final DetailCategory parent); DetailCategory getDetailByCode(final String detailCode); @Override int hashCode(); @Override boolean equals(final Object otherObject);  }