コード例 #1
0
  /** @since 3.7 */
  public Map<Category, Map<SubCategory, Collection<PropertyDefinition>>> propertiesByCategory(
      @Nullable String qualifier) {
    Map<Category, Map<SubCategory, Collection<PropertyDefinition>>> byCategory =
        new HashMap<Category, Map<SubCategory, Collection<PropertyDefinition>>>();
    if (qualifier == null) {
      // Special categories on global page
      Map<SubCategory, Collection<PropertyDefinition>> emailSubCategories =
          new HashMap<SubCategory, Collection<PropertyDefinition>>();
      emailSubCategories.put(new SubCategory("email", true), new ArrayList<PropertyDefinition>());
      byCategory.put(new Category(CoreProperties.CATEGORY_GENERAL, false), emailSubCategories);

      HashMap<SubCategory, Collection<PropertyDefinition>> licenseSubCategories =
          new HashMap<SubCategory, Collection<PropertyDefinition>>();
      licenseSubCategories.put(
          new SubCategory("server_id", true), new ArrayList<PropertyDefinition>());
      byCategory.put(new Category(CoreProperties.CATEGORY_LICENSES, false), licenseSubCategories);

      HashMap<SubCategory, Collection<PropertyDefinition>> encryptionSubCategories =
          new HashMap<SubCategory, Collection<PropertyDefinition>>();
      encryptionSubCategories.put(
          new SubCategory("encryption", true), new ArrayList<PropertyDefinition>());
      byCategory.put(
          new Category(CoreProperties.CATEGORY_SECURITY, false), encryptionSubCategories);
    }
    for (PropertyDefinition definition : getAll()) {
      if (qualifier == null ? definition.global() : definition.qualifiers().contains(qualifier)) {
        Category category = categories.get(definition.key());
        if (!byCategory.containsKey(category)) {
          byCategory.put(category, new HashMap<SubCategory, Collection<PropertyDefinition>>());
        }
        SubCategory subCategory = subcategories.get(definition.key());
        if (!byCategory.get(category).containsKey(subCategory)) {
          byCategory.get(category).put(subCategory, new ArrayList<PropertyDefinition>());
        }
        byCategory.get(category).get(subCategory).add(definition);
      }
    }
    return byCategory;
  }
コード例 #2
0
 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;
 }