com.github.phillipkruger.microprofileextentions.config.converter.ListConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of config-ext Show documentation
Show all versions of config-ext Show documentation
Some default config providers and converters
package com.github.phillipkruger.microprofileextentions.config.converter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.microprofile.config.spi.Converter;
/**
* Converts a comma separated string to a list
* @author Phillip Kruger ([email protected])
*/
public class ListConverter implements Converter {
@Override
public List convert(String input) throws IllegalArgumentException {
if(isNullOrEmpty(input))return new ArrayList();
Stream stream = Stream.of(input);
return stream.collect(Collectors.toList());
}
/**
* Not to sure about this, got an javax.json.stream.JsonParsingException in Wildfly with a value of org.eclipse.microprofile.config.configproperty.unconfigureddvalue
**/
private boolean isNullOrEmpty(String input){
return input==null || input.isEmpty() || input.equals(UNCONFIGURED_VALUE);
}
private static final String UNCONFIGURED_VALUE = "org.eclipse.microprofile.config.configproperty.unconfigureddvalue";
}