Java Code Examples for org.springframework.core.CollectionFactory#createStringAdaptingProperties()

The following examples show how to use org.springframework.core.CollectionFactory#createStringAdaptingProperties() . 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: YamlProcessor.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private boolean process(Map<String, Object> map, MatchCallback callback) {
	Properties properties = CollectionFactory.createStringAdaptingProperties();
	properties.putAll(getFlattenedMap(map));

	if (this.documentMatchers.isEmpty()) {
		if (logger.isDebugEnabled()) {
			logger.debug("Merging document (no matchers set): " + map);
		}
		callback.process(properties, map);
		return true;
	}

	MatchStatus result = MatchStatus.ABSTAIN;
	for (DocumentMatcher matcher : this.documentMatchers) {
		MatchStatus match = matcher.matches(properties);
		result = MatchStatus.getMostSpecific(match, result);
		if (match == MatchStatus.FOUND) {
			if (logger.isDebugEnabled()) {
				logger.debug("Matched document with document matcher: " + properties);
			}
			callback.process(properties, map);
			return true;
		}
	}

	if (result == MatchStatus.ABSTAIN && this.matchDefault) {
		if (logger.isDebugEnabled()) {
			logger.debug("Matched document with default matcher: " + map);
		}
		callback.process(properties, map);
		return true;
	}

	if (logger.isDebugEnabled()) {
		logger.debug("Unmatched document: " + map);
	}
	return false;
}
 
Example 2
Source File: YamlProcessor.java    From java-technology-stack with MIT License 5 votes vote down vote up
private boolean process(Map<String, Object> map, MatchCallback callback) {
	Properties properties = CollectionFactory.createStringAdaptingProperties();
	properties.putAll(getFlattenedMap(map));

	if (this.documentMatchers.isEmpty()) {
		if (logger.isDebugEnabled()) {
			logger.debug("Merging document (no matchers set): " + map);
		}
		callback.process(properties, map);
		return true;
	}

	MatchStatus result = MatchStatus.ABSTAIN;
	for (DocumentMatcher matcher : this.documentMatchers) {
		MatchStatus match = matcher.matches(properties);
		result = MatchStatus.getMostSpecific(match, result);
		if (match == MatchStatus.FOUND) {
			if (logger.isDebugEnabled()) {
				logger.debug("Matched document with document matcher: " + properties);
			}
			callback.process(properties, map);
			return true;
		}
	}

	if (result == MatchStatus.ABSTAIN && this.matchDefault) {
		if (logger.isDebugEnabled()) {
			logger.debug("Matched document with default matcher: " + map);
		}
		callback.process(properties, map);
		return true;
	}

	if (logger.isDebugEnabled()) {
		logger.debug("Unmatched document: " + map);
	}
	return false;
}
 
Example 3
Source File: YamlProcessor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private boolean process(Map<String, Object> map, MatchCallback callback) {
	Properties properties = CollectionFactory.createStringAdaptingProperties();
	properties.putAll(getFlattenedMap(map));

	if (this.documentMatchers.isEmpty()) {
		if (logger.isDebugEnabled()) {
			logger.debug("Merging document (no matchers set): " + map);
		}
		callback.process(properties, map);
		return true;
	}

	MatchStatus result = MatchStatus.ABSTAIN;
	for (DocumentMatcher matcher : this.documentMatchers) {
		MatchStatus match = matcher.matches(properties);
		result = MatchStatus.getMostSpecific(match, result);
		if (match == MatchStatus.FOUND) {
			if (logger.isDebugEnabled()) {
				logger.debug("Matched document with document matcher: " + properties);
			}
			callback.process(properties, map);
			return true;
		}
	}

	if (result == MatchStatus.ABSTAIN && this.matchDefault) {
		if (logger.isDebugEnabled()) {
			logger.debug("Matched document with default matcher: " + map);
		}
		callback.process(properties, map);
		return true;
	}

	if (logger.isDebugEnabled()) {
		logger.debug("Unmatched document: " + map);
	}
	return false;
}
 
Example 4
Source File: YamlPropertiesFactoryBean.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Template method that subclasses may override to construct the object
 * returned by this factory. The default implementation returns a
 * properties with the content of all resources.
 * <p>Invoked lazily the first time {@link #getObject()} is invoked in
 * case of a shared singleton; else, on each {@link #getObject()} call.
 * @return the object returned by this factory
 * @see #process(MatchCallback) ()
 */
protected Properties createProperties() {
	final Properties result = CollectionFactory.createStringAdaptingProperties();
	process(new MatchCallback() {
		@Override
		public void process(Properties properties, Map<String, Object> map) {
			result.putAll(properties);
		}
	});
	return result;
}
 
Example 5
Source File: YamlPropertiesProcessor.java    From moon-api-gateway with MIT License 4 votes vote down vote up
public Properties createProperties() throws IOException {
    final Properties result = CollectionFactory.createStringAdaptingProperties();
    process((properties, map) -> result.putAll(properties));
    return result;
}
 
Example 6
Source File: YamlPropertiesFactoryBean.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Template method that subclasses may override to construct the object
 * returned by this factory. The default implementation returns a
 * properties with the content of all resources.
 * <p>Invoked lazily the first time {@link #getObject()} is invoked in
 * case of a shared singleton; else, on each {@link #getObject()} call.
 * @return the object returned by this factory
 * @see #process(MatchCallback) ()
 */
protected Properties createProperties() {
	Properties result = CollectionFactory.createStringAdaptingProperties();
	process((properties, map) -> result.putAll(properties));
	return result;
}
 
Example 7
Source File: YamlPropertiesFactoryBean.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Template method that subclasses may override to construct the object
 * returned by this factory. The default implementation returns a
 * properties with the content of all resources.
 * <p>Invoked lazily the first time {@link #getObject()} is invoked in
 * case of a shared singleton; else, on each {@link #getObject()} call.
 * @return the object returned by this factory
 * @see #process(MatchCallback) ()
 */
protected Properties createProperties() {
	Properties result = CollectionFactory.createStringAdaptingProperties();
	process((properties, map) -> result.putAll(properties));
	return result;
}