class DefaultAcl {

  public static DefaultAcl fromConfiguration(IndexingService indexingService) {
    checkState(Configuration.isInitialized(), "Configuration not initialized");
    DefaultAclMode aclMode =
        Configuration.getValue(DEFAULT_ACL_MODE, DefaultAclMode.NONE, DEFAULT_ACL_MODE_PARSER)
            .get();
    boolean defaultAclPublic = Configuration.getBoolean(DEFAULT_ACL_PUBLIC, false).get();
    List<Principal> readerUsers =
        Configuration.getMultiValue(
                DEFAULT_ACL_READERS_USERS, Collections.emptyList(), Acl.USER_PARSER)
            .get();
    List<Principal> readerGroups =
        Configuration.getMultiValue(
                DEFAULT_ACL_READERS_GROUPS, Collections.emptyList(), Acl.GROUP_PARSER)
            .get();
    List<Principal> deniedReaderUsers =
        Configuration.getMultiValue(
                DEFAULT_ACL_DENIED_USERS, Collections.emptyList(), Acl.USER_PARSER)
            .get();
    List<Principal> deniedReaderGroups =
        Configuration.getMultiValue(
                DEFAULT_ACL_DENIED_GROUPS, Collections.emptyList(), Acl.GROUP_PARSER)
            .get();
    String defaultAclName =
        Configuration.getString(DEFAULT_ACL_NAME, DEFAULT_ACL_NAME_DEFAULT)
            .get();
    return new DefaultAcl.Builder()
        .setMode(aclMode)
        .setIsPublic(defaultAclPublic)
        .setReaderUsers(readerUsers)
        .setReaderGroups(readerGroups)
        .setDeniedReaderUsers(deniedReaderUsers)
        .setDeniedReaderGroups(deniedReaderGroups)
        .setIndexingService(indexingService)
        .setDefaultAclName(defaultAclName)
        .build();
  }

  private  DefaultAcl(Builder builder);

}