Example usage for org.springframework.core CollectionFactory createStringAdaptingProperties

List of usage examples for org.springframework.core CollectionFactory createStringAdaptingProperties

Introduction

In this page you can find the example usage for org.springframework.core CollectionFactory createStringAdaptingProperties.

Prototype

@SuppressWarnings("serial")
public static Properties createStringAdaptingProperties() 

Source Link

Document

Create a variant of java.util.Properties that automatically adapts non-String values to String representations in Properties#getProperty .

Usage

From source file:org.springframework.beans.factory.config.YamlProcessor.java

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);
        }//  w  w  w .jav a 2 s  .co m
        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;
}