All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.peterbecker.configuration.storage.PropertiesStore Maven / Gradle / Ivy

There is a newer version: 1.1
Show newest version
package com.github.peterbecker.configuration.storage;

import lombok.Data;
import lombok.NonNull;

import java.util.Optional;
import java.util.Properties;
import java.util.stream.Collectors;

/**
 * A Store implemented through a Properties object.
 */
@Data
public class PropertiesStore implements Store {
    private final
    @NonNull
    Properties properties;

    @Override
    public Optional getValue(Key key) {
        String propKey;
        if (key.getContext().isEmpty()) {
            propKey = key.getOptionName();
        } else {
            propKey = key.getContext().stream().collect(Collectors.joining(".")) +
                    "." +
                    key.getOptionName();
        }
        return Optional.ofNullable(properties.getProperty(propKey));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy