Java Code Examples for org.apache.commons.configuration2.Configuration#subset()
The following examples show how to use
org.apache.commons.configuration2.Configuration#subset() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DbMergeInfo.java From obevo with Apache License 2.0 | 5 votes |
public static RichIterable<DbMergeInfo> parseFromProperties(Configuration config) { MutableSet<String> dbs = CollectionAdapter.wrapSet(config.getList(String.class, "instances", Lists.mutable.<String>empty())); MutableList<String> exceptions = Lists.mutable.empty(); MutableList<DbMergeInfo> dbMergeInfos = Lists.mutable.empty(); for (String db : dbs) { Configuration subset = config.subset(db); if (subset.containsKey("inputDir")) { File inputDir = new File(subset.getString("inputDir")); if (!inputDir.canRead()) { if (inputDir.getPath().contains("\r")) { exceptions.add("Could not find " + db + "." + "inputDir file (use forward-slash instead of back-slash in path): " + inputDir.getPath().replaceAll("\r", "")); } else { exceptions.add("Could not find " + db + "." + "inputDir file: " + inputDir); } } DbMergeInfo mergeInfo = new DbMergeInfo(db, inputDir); if (subset.containsKey("driverClassName")) { mergeInfo.setDriverClassName(subset.getString("driverClassName")); mergeInfo.setUrl(subset.getString("url")); mergeInfo.setUsername(subset.getString("username")); mergeInfo.setPassword(subset.getString("password")); mergeInfo.setPhysicalSchema(subset.getString("physicalSchema")); } dbMergeInfos.add(mergeInfo); } } if (exceptions.notEmpty()) { throw new IllegalArgumentException("Invalid properties found in configuration:\n" + exceptions.collect(new Function<String, String>() { @Override public String valueOf(String it) { return "* " + it; } }).makeString("\n")); } return dbMergeInfos; }
Example 2
Source File: Schema2MarkupConfigBuilder.java From swagger2markup with Apache License 2.0 | 4 votes |
public Schema2MarkupConfigBuilder(final Class<T> selfClass, C config, Schema2MarkupProperties schema2MarkupProperties, Configuration configuration) { this.self = selfClass.cast(this); this.config = config; config.listDelimiterEnabled = schema2MarkupProperties.getBoolean(LIST_DELIMITER_ENABLED, false); config.listDelimiter = schema2MarkupProperties.getString(LIST_DELIMITER, ",").charAt(0); if (config.listDelimiterEnabled && configuration instanceof AbstractConfiguration) { ((AbstractConfiguration) configuration).setListDelimiterHandler(new DefaultListDelimiterHandler(config.listDelimiter)); } config.requestExamplesFormat = schema2MarkupProperties.getRequiredString(REQUEST_EXAMPLES_FORMAT); config.requestExamplesSourceFormat = schema2MarkupProperties.getRequiredString(REQUEST_EXAMPLES_SOURCE_FORMAT); config.requestExamplesHost = schema2MarkupProperties.getRequiredString(REQUEST_EXAMPLES_HOST); config.requestExamplesSchema = schema2MarkupProperties.getRequiredString(REQUEST_EXAMPLES_SCHEMA); config.requestExamplesHideBasePath = schema2MarkupProperties.getRequiredBoolean(REQUEST_EXAMPLES_HIDE_BASE_PATH); config.requestExamplesQueryArrayStyle = schema2MarkupProperties.getRequiredString(REQUEST_EXAMPLES_QUERY_ARRAY_STYLE); config.requestExamplesIncludeAllQueryParams = schema2MarkupProperties.getRequiredBoolean(REQUEST_EXAMPLES_INCLUDE_ALL_QUERY_PARAMS); config.markupLanguage = schema2MarkupProperties.getRequiredMarkupLanguage(MARKUP_LANGUAGE); config.schemaMarkupLanguage = schema2MarkupProperties.getRequiredMarkupLanguage(SWAGGER_MARKUP_LANGUAGE); config.generatedExamplesEnabled = schema2MarkupProperties.getRequiredBoolean(GENERATED_EXAMPLES_ENABLED); config.hostnameEnabled = schema2MarkupProperties.getRequiredBoolean(HOSTNAME_ENABLED); config.basePathPrefixEnabled = schema2MarkupProperties.getRequiredBoolean(BASE_PATH_PREFIX_ENABLED); config.separatedDefinitionsEnabled = schema2MarkupProperties.getRequiredBoolean(SEPARATED_DEFINITIONS_ENABLED); config.separatedOperationsEnabled = schema2MarkupProperties.getRequiredBoolean(SEPARATED_OPERATIONS_ENABLED); config.pathsGroupedBy = schema2MarkupProperties.getGroupBy(PATHS_GROUPED_BY); config.language = schema2MarkupProperties.getLanguage(OUTPUT_LANGUAGE); config.inlineSchemaEnabled = schema2MarkupProperties.getRequiredBoolean(INLINE_SCHEMA_ENABLED); config.interDocumentCrossReferencesEnabled = schema2MarkupProperties.getRequiredBoolean(INTER_DOCUMENT_CROSS_REFERENCES_ENABLED); config.interDocumentCrossReferencesPrefix = schema2MarkupProperties.getString(INTER_DOCUMENT_CROSS_REFERENCES_PREFIX, null); config.flatBodyEnabled = schema2MarkupProperties.getRequiredBoolean(FLAT_BODY_ENABLED); config.pathSecuritySectionEnabled = schema2MarkupProperties.getRequiredBoolean(PATH_SECURITY_SECTION_ENABLED); config.anchorPrefix = schema2MarkupProperties.getString(ANCHOR_PREFIX, null); config.overviewDocument = schema2MarkupProperties.getRequiredString(OVERVIEW_DOCUMENT); config.pathsDocument = schema2MarkupProperties.getRequiredString(PATHS_DOCUMENT); config.definitionsDocument = schema2MarkupProperties.getRequiredString(DEFINITIONS_DOCUMENT); config.securityDocument = schema2MarkupProperties.getRequiredString(SECURITY_DOCUMENT); config.separatedOperationsFolder = schema2MarkupProperties.getRequiredString(SEPARATED_OPERATIONS_FOLDER); config.separatedDefinitionsFolder = schema2MarkupProperties.getRequiredString(SEPARATED_DEFINITIONS_FOLDER); config.tagOrderBy = schema2MarkupProperties.getOrderBy(TAG_ORDER_BY); config.operationOrderBy = schema2MarkupProperties.getOrderBy(OPERATION_ORDER_BY); config.definitionOrderBy = schema2MarkupProperties.getOrderBy(DEFINITION_ORDER_BY); config.parameterOrderBy = schema2MarkupProperties.getOrderBy(PARAMETER_ORDER_BY); config.propertyOrderBy = schema2MarkupProperties.getOrderBy(PROPERTY_ORDER_BY); config.responseOrderBy = schema2MarkupProperties.getOrderBy(RESPONSE_ORDER_BY); Optional<String> lineSeparator = schema2MarkupProperties.getString(LINE_SEPARATOR); if (lineSeparator.isPresent() && StringUtils.isNoneBlank(lineSeparator.get())) { config.lineSeparator = LineSeparator.valueOf(lineSeparator.get()); } config.pageBreakLocations = schema2MarkupProperties.getPageBreakLocations(PAGE_BREAK_LOCATIONS); Optional<Pattern> headerPattern = schema2MarkupProperties.getHeaderPattern(HEADER_REGEX); config.headerPattern = headerPattern.orElse(null); Configuration swagger2markupConfiguration = schema2MarkupProperties.getConfiguration().subset(PROPERTIES_PREFIX); Configuration extensionsConfiguration = swagger2markupConfiguration.subset(EXTENSION_PREFIX); config.extensionsProperties = new Schema2MarkupProperties(extensionsConfiguration); config.asciidocPegdownTimeoutMillis = schema2MarkupProperties.getRequiredInt(ASCIIDOC_PEGDOWN_TIMEOUT); }