com.github.phillipkruger.microprofileextentions.config.converter.ArrayConverter 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.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.microprofile.config.spi.Converter;
/**
* Converts a comma separated string to a String array
* @author Phillip Kruger ([email protected])
*/
public class ArrayConverter implements Converter {
@Override
public String[] convert(String input) throws IllegalArgumentException {
if(isNullOrEmpty(input))return new String[]{};
Stream stream = Stream.of(input);
return stream.collect(Collectors.toList()).toArray(new String[]{});
}
/**
* 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";
}