001package com.nimbusds.common.config;
002
003
004import java.util.Arrays;
005import java.util.Collections;
006import java.util.List;
007
008
009/**
010 * String list parse utility.
011 */
012public class StringListParser {
013        
014        
015        /**
016         * Parses a list of strings from the specified strings containing space
017         * or comma separated tokens.
018         *
019         * @param s The string, {@code null} if not specified.
020         *
021         * @return The string list, empty list if the string was {@code null}.
022         */
023        public static List<String> parse(final String s) {
024                
025                if (s == null || s.trim().isEmpty())
026                        return Collections.emptyList();
027                
028                return Arrays.asList(s.split("\\s*(,|\\s)\\s*"));
029        }
030        
031        
032        /**
033         * Prevents public instantiation.
034         */
035        private StringListParser(){}
036}