private static List<String> asStringList(final Object pages) {
        if (pages instanceof String) {
            return Collections.singletonList((String) pages);
        } else if (pages instanceof Collection) {
            ArrayList<String> strings = new ArrayList<>();
            for (Object o : ((Collection) pages)) {
                if (o instanceof String) {
                    strings.add((String) o);
                }
            }
            if (strings.size() < 1) {
                return null;
            }
            return strings;
        }
        return null;
    }
private static List < String > asStringList ( final Object pages ) { if ( pages instanceof String ) { return Collections . singletonList ( ( String ) pages ) ; } else if ( pages instanceof Collection ) { ArrayList < String > strings = new ArrayList < > ( ) ; for ( Object o : ( ( Collection ) pages ) ) { if ( o instanceof String ) { strings . add ( ( String ) o ) ; } } if ( strings . size ( ) < 1 ) { return null ; } return strings ; } return null ; }
@param pages either a string or collection of strings

@return list of strings, or null if pages was not a string or list, or was a list and contained no strings