
com.github.robtimus.maven.plugins.i18n.OrderedProperties Maven / Gradle / Ivy
/*
* OrderedProperties.java
* Copyright 2017 Rob Spoor
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.robtimus.maven.plugins.i18n;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
class OrderedProperties extends Properties {
private static final long serialVersionUID = -6380793892360859605L;
private Map properties = new LinkedHashMap<>();
static OrderedProperties fromInputStream(InputStream input) throws IOException {
OrderedProperties properties = new OrderedProperties();
properties.load(input);
return properties;
}
static OrderedProperties fromReader(Reader input) throws IOException {
OrderedProperties properties = new OrderedProperties();
properties.load(input);
return properties;
}
@Override
public synchronized Object setProperty(String key, String value) {
return properties.put(key, value);
}
@Override
public String getProperty(String key) {
return properties.get(key);
}
@Override
public String getProperty(String key, String defaultValue) {
String value = properties.get(key);
return value == null ? defaultValue : value;
}
@Override
public Enumeration> propertyNames() {
return enumeration(properties.keySet());
}
@Override
public Set stringPropertyNames() {
return new LinkedHashSet<>(properties.keySet());
}
@Override
public synchronized int size() {
return properties.size();
}
@Override
public synchronized boolean isEmpty() {
return properties.isEmpty();
}
@Override
public synchronized Enumeration
© 2015 - 2025 Weber Informatics LLC | Privacy Policy