Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* The MIT License (MIT)
*
* Copyright 2016-2018 Valentyn Kolesnikov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.github.underscore.string;
import com.github.underscore.BinaryOperator;
import com.github.underscore.BiFunction;
import com.github.underscore.Consumer;
import com.github.underscore.Function;
import com.github.underscore.Function3;
import com.github.underscore.Predicate;
import com.github.underscore.PredicateIndexed;
import com.github.underscore.Tuple;
import com.github.underscore.Optional;
import java.util.*;
public class U extends com.github.underscore.U {
private static final int DEFAULT_TRUNC_LENGTH = 30;
private static final String DEFAULT_TRUNC_OMISSION = "...";
private static final String NULL = "null";
private static final String ELEMENT = "";
private static final String CLOSED_ELEMENT = "";
private static final String EMPTY_ELEMENT = ELEMENT + CLOSED_ELEMENT;
private static final String NULL_ELEMENT = ELEMENT + NULL + CLOSED_ELEMENT;
private static final java.util.regex.Pattern RE_LATIN_1 = java.util.regex.Pattern.compile(
"[\\xc0-\\xd6\\xd8-\\xde\\xdf-\\xf6\\xf8-\\xff]");
private static Map deburredLetters = new LinkedHashMap() { {
put("\u00c0", "A"); put("\u00c1", "A"); put("\u00c2", "A"); put("\u00c3", "A");
put("\u00c4", "A"); put("\u00c5", "A");
put("\u00e0", "a"); put("\u00e1", "a"); put("\u00e2", "a"); put("\u00e3", "a");
put("\u00e4", "a"); put("\u00e5", "a");
put("\u00c7", "C"); put("\u00e7", "c");
put("\u00d0", "D"); put("\u00f0", "d");
put("\u00c8", "E"); put("\u00c9", "E"); put("\u00ca", "E"); put("\u00cb", "E");
put("\u00e8", "e"); put("\u00e9", "e"); put("\u00ea", "e"); put("\u00eb", "e");
put("\u00cC", "I"); put("\u00cd", "I"); put("\u00ce", "I"); put("\u00cf", "I");
put("\u00eC", "i"); put("\u00ed", "i"); put("\u00ee", "i"); put("\u00ef", "i");
put("\u00d1", "N"); put("\u00f1", "n");
put("\u00d2", "O"); put("\u00d3", "O"); put("\u00d4", "O"); put("\u00d5", "O");
put("\u00d6", "O"); put("\u00d8", "O");
put("\u00f2", "o"); put("\u00f3", "o"); put("\u00f4", "o"); put("\u00f5", "o");
put("\u00f6", "o"); put("\u00f8", "o");
put("\u00d9", "U"); put("\u00da", "U"); put("\u00db", "U"); put("\u00dc", "U");
put("\u00f9", "u"); put("\u00fa", "u"); put("\u00fb", "u"); put("\u00fc", "u");
put("\u00dd", "Y"); put("\u00fd", "y"); put("\u00ff", "y");
put("\u00c6", "Ae"); put("\u00e6", "ae");
put("\u00de", "Th"); put("\u00fe", "th");
put("\u00df", "ss");
} };
private static String upper = "[A-Z\\xc0-\\xd6\\xd8-\\xde\\u0400-\\u04FF]";
private static String lower = "[a-z\\xdf-\\xf6\\xf8-\\xff]+";
private static java.util.regex.Pattern reWords = java.util.regex.Pattern.compile(
upper + "+(?=" + upper + lower + ")|" + upper + "?" + lower + "|" + upper + "+|[0-9]+");
public U(final Iterable iterable) {
super(iterable);
}
public U(final String string) {
super(string);
}
public static class Chain extends com.github.underscore.U.Chain {
public Chain(final T item) {
super(item);
}
public Chain(final List list) {
super(list);
}
public Chain first() {
return new Chain(U.first(value()));
}
public Chain first(int n) {
return new Chain(U.first(value(), n));
}
public Chain firstOrNull() {
return new Chain(U.firstOrNull(value()));
}
public Chain firstOrNull(final Predicate pred) {
return new Chain(U.firstOrNull(value(), pred));
}
public Chain initial() {
return new Chain(U.initial(value()));
}
public Chain initial(int n) {
return new Chain(U.initial(value(), n));
}
public Chain last() {
return new Chain(U.last(value()));
}
public Chain last(int n) {
return new Chain(U.last(value(), n));
}
public Chain lastOrNull() {
return new Chain(U.lastOrNull(value()));
}
public Chain lastOrNull(final Predicate pred) {
return new Chain(U.lastOrNull(value(), pred));
}
public Chain rest() {
return new Chain(U.rest(value()));
}
public Chain rest(int n) {
return new Chain(U.rest(value(), n));
}
public Chain compact() {
return new Chain(U.compact(value()));
}
public Chain compact(final T falsyValue) {
return new Chain(U.compact(value(), falsyValue));
}
@SuppressWarnings("unchecked")
public Chain flatten() {
return new Chain((List) U.flatten(value()));
}
public Chain map(final Function super T, F> func) {
return new Chain(U.map(value(), func));
}
public Chain mapIndexed(final BiFunction func) {
return new Chain(U.mapIndexed(value(), func));
}
public Chain filter(final Predicate pred) {
return new Chain(U.filter(value(), pred));
}
public Chain filterIndexed(final PredicateIndexed pred) {
return new Chain(U.filterIndexed(value(), pred));
}
public Chain rejectIndexed(final PredicateIndexed pred) {
return new Chain(U.rejectIndexed(value(), pred));
}
public Chain reject(final Predicate pred) {
return new Chain(U.reject(value(), pred));
}
public Chain filterFalse(final Predicate pred) {
return new Chain(U.filterFalse(value(), pred));
}
public Chain reduce(final BiFunction func, final F zeroElem) {
return new Chain(U.reduce(value(), func, zeroElem));
}
public Chain> reduce(final BinaryOperator func) {
return new Chain>(U.reduce(value(), func));
}
public Chain reduceRight(final BiFunction func, final F zeroElem) {
return new Chain(U.reduceRight(value(), func, zeroElem));
}
public Chain> reduceRight(final BinaryOperator func) {
return new Chain>(U.reduceRight(value(), func));
}
public Chain> find(final Predicate pred) {
return new Chain>(U.find(value(), pred));
}
public Chain> findLast(final Predicate pred) {
return new Chain>(U.findLast(value(), pred));
}
@SuppressWarnings("unchecked")
public Chain max() {
return new Chain(U.max((Collection) value()));
}
public > Chain max(final Function func) {
return new Chain(U.max(value(), func));
}
@SuppressWarnings("unchecked")
public Chain min() {
return new Chain(U.min((Collection) value()));
}
public > Chain min(final Function func) {
return new Chain(U.min(value(), func));
}
@SuppressWarnings("unchecked")
public Chain sort() {
return new Chain(U.sort((List) value()));
}
@SuppressWarnings("unchecked")
public > Chain sortWith(final Comparator comparator) {
return new Chain(U.sortWith((List) value(), comparator));
}
public > Chain sortBy(final Function func) {
return new Chain(U.sortBy(value(), func));
}
@SuppressWarnings("unchecked")
public Chain