emailSubCategories.put(new SubCategory("email", true), new ArrayList<PropertyDefinition>()); byCategory.put(new Category(CoreProperties.CATEGORY_GENERAL, false), emailSubCategories); licenseSubCategories.put(new SubCategory("server_id", true), new ArrayList<PropertyDefinition>()); byCategory.put(new Category(CoreProperties.CATEGORY_LICENSES, false), licenseSubCategories); encryptionSubCategories.put(new SubCategory("encryption", true), new ArrayList<PropertyDefinition>()); byCategory.put(new Category(CoreProperties.CATEGORY_SECURITY, false), encryptionSubCategories);
public String getSubCategory(String key) { return subcategories.get(validKey(key)).toString(); }
@Test public void should_return_special_categories() { PropertyDefinitions def = new PropertyDefinitions(); assertThat(def.propertiesByCategory(null).get(new Category("general")).keySet()).containsOnly(new SubCategory("email")); assertThat(def.propertiesByCategory(null).get(new Category("general")).keySet().iterator().next().isSpecial()).isTrue(); assertThat(def.propertiesByCategory(null).get(new Category("security")).keySet()).containsOnly(new SubCategory("encryption")); assertThat(def.propertiesByCategory(null).get(new Category("security")).keySet().iterator().next().isSpecial()).isTrue(); assertThat(def.propertiesByCategory(null).get(new Category("licenses")).keySet()).containsOnly(new SubCategory("server_id")); assertThat(def.propertiesByCategory(null).get(new Category("licenses")).keySet().iterator().next().isSpecial()).isTrue(); }
public SubCategory createSubcategory(String name){ SubCategory m = new SubCategory(); m.setParent(Category.this); m.setName(name); return m; }
String response = RequestManager.makeRequest(); StringBuilder sbResponse = new StringBuilder(); try { JSONArray jsonArray = new JSONArray(response); for (int i = 0; i < jsonArray.length(); i++) { Category c=new Category(); JSONObject jsonObject = jsonArray.getJSONObject(i); c.setTitle(jsonObject.getString("title")); JSONArray nestedArray = jsonObject.getJSONArray("subs"); for (int j = 0; j < nestedArray.length(); j++) { SubCategory s=new SubCategory(); JSONObject nestedObject= nestedArray.getJSONObject(i); s.setId(nestedObject.getString("id")); s.setTitle(nestedObject.getString("title")); } c.setSubCategory(s); } Log.d(LOG_TAG, sbResponse.toString()); } catch (JSONException e) { e.printStackTrace(); }
private PropertyDefinitions add(PropertyDefinition definition, String defaultCategory) { if (!definitions.containsKey(definition.key())) { definitions.put(definition.key(), definition); String category = StringUtils.defaultIfBlank(definition.category(), defaultCategory); categories.put(definition.key(), new Category(category)); String subcategory = StringUtils.defaultIfBlank(definition.subCategory(), category); subcategories.put(definition.key(), new SubCategory(subcategory)); if (!StringUtils.isEmpty(definition.deprecatedKey()) && !definition.deprecatedKey().equals(definition.key())) { deprecatedKeys.put(definition.deprecatedKey(), definition.key()); } } return this; }
public String getSubCategory(String key) { return subcategories.get(validKey(key)).toString(); }
@Test public void defaultSubCategoryShouldEqualParentCategory() { assertThat(new Category("general")).isEqualTo(new SubCategory("general")); }
public String getSubCategory(String key) { return subcategories.get(validKey(key)).toString(); }
@Test public void should_group_by_subcategory() { PropertyDefinitions def = new PropertyDefinitions( PropertyDefinition.builder("global1").name("Global1").category("catGlobal1").subCategory("sub1").build(), PropertyDefinition.builder("global2").name("Global2").category("catGlobal1").subCategory("sub2").build(), PropertyDefinition.builder("global3").name("Global3").category("catGlobal1").build(), PropertyDefinition.builder("global4").name("Global4").category("catGlobal2").build()); assertThat(def.propertiesByCategory(null).get(new Category("catGlobal1")).keySet()).containsOnly(new SubCategory("catGlobal1"), new SubCategory("sub1"), new SubCategory("sub2")); assertThat(def.propertiesByCategory(null).get(new Category("catGlobal2")).keySet()).containsOnly(new SubCategory("catGlobal2")); }
public class SecuritySensor extends CategoryBase { public SecuritySensor(int ranking, String name) { super(ranking, name, new SubCategory(1, "Door Sensor"), new SubCategory(2, "Leak Sensor"), new SubCategory(3, "Motion Sensor")); } }
subcatList.add(new SubCategory()); adapter.notifyDataSetChanged();
public SubCategory createSubcategory(String name){ return new SubCategory(this, name); }
emailSubCategories.put(new SubCategory("email", true), new ArrayList<PropertyDefinition>()); byCategory.put(new Category(CoreProperties.CATEGORY_GENERAL, false), emailSubCategories); licenseSubCategories.put(new SubCategory("server_id", true), new ArrayList<PropertyDefinition>()); byCategory.put(new Category(CoreProperties.CATEGORY_LICENSES, false), licenseSubCategories); encryptionSubCategories.put(new SubCategory("encryption", true), new ArrayList<PropertyDefinition>()); byCategory.put(new Category(CoreProperties.CATEGORY_SECURITY, false), encryptionSubCategories);
emailSubCategories.put(new SubCategory("email", true), new ArrayList<PropertyDefinition>()); byCategory.put(new Category(CoreProperties.CATEGORY_GENERAL, false), emailSubCategories); licenseSubCategories.put(new SubCategory("server_id", true), new ArrayList<PropertyDefinition>()); byCategory.put(new Category(CoreProperties.CATEGORY_LICENSES, false), licenseSubCategories); encryptionSubCategories.put(new SubCategory("encryption", true), new ArrayList<PropertyDefinition>()); byCategory.put(new Category(CoreProperties.CATEGORY_SECURITY, false), encryptionSubCategories);
private PropertyDefinitions add(PropertyDefinition definition, String defaultCategory) { if (!definitions.containsKey(definition.key())) { definitions.put(definition.key(), definition); String category = StringUtils.defaultIfBlank(definition.category(), defaultCategory); categories.put(definition.key(), new Category(category)); String subcategory = StringUtils.defaultIfBlank(definition.subCategory(), category); subcategories.put(definition.key(), new SubCategory(subcategory)); if (!Strings.isNullOrEmpty(definition.deprecatedKey()) && !definition.deprecatedKey().equals(definition.key())) { deprecatedKeys.put(definition.deprecatedKey(), definition.key()); } } return this; }
private PropertyDefinitions add(PropertyDefinition definition, String defaultCategory) { if (!definitions.containsKey(definition.key())) { definitions.put(definition.key(), definition); String category = StringUtils.defaultIfBlank(definition.category(), defaultCategory); categories.put(definition.key(), new Category(category)); String subcategory = StringUtils.defaultIfBlank(definition.subCategory(), category); subcategories.put(definition.key(), new SubCategory(subcategory)); if (!StringUtils.isEmpty(definition.deprecatedKey()) && !definition.deprecatedKey().equals(definition.key())) { deprecatedKeys.put(definition.deprecatedKey(), definition.key()); } } return this; }