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.
/*
* Copyright 2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.util;
import org.apache.commons.lang.StringUtils;
import org.gradle.api.Transformer;
import org.gradle.api.UncheckedIOException;
import org.gradle.api.specs.Spec;
import org.gradle.internal.Cast;
import org.gradle.internal.Factory;
import org.gradle.internal.IoActions;
import org.gradle.internal.UncheckedException;
import org.gradle.internal.io.StreamByteBuffer;
import javax.annotation.Nullable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.Formatter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Callable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
/**
* This class is only here to maintain binary compatibility with existing plugins.
*
* Plugins should prefer external collection frameworks over this class.
* Internally, all code should use {@link org.gradle.util.internal.GUtil}.
*
* @deprecated Will be removed in Gradle 8.0.
*/
@Deprecated
public class GUtil {
private static final Pattern WORD_SEPARATOR = Pattern.compile("\\W+");
private static final Pattern UPPER_LOWER = Pattern.compile("(?m)([A-Z]*)([a-z0-9]*)");
public static > T flatten(Object[] elements, T addTo, boolean flattenMaps) {
return flatten(asList(elements), addTo, flattenMaps);
}
public static > T flatten(Object[] elements, T addTo) {
return flatten(asList(elements), addTo);
}
public static > T flatten(Collection> elements, T addTo) {
return flatten(elements, addTo, true);
}
public static > T flattenElements(Object... elements) {
Collection out = new LinkedList();
flatten(elements, out, true);
return Cast.uncheckedNonnullCast(out);
}
public static > T flatten(Collection> elements, T addTo, boolean flattenMapsAndArrays) {
return flatten(elements, addTo, flattenMapsAndArrays, flattenMapsAndArrays);
}
public static > T flatten(Collection> elements, T addTo, boolean flattenMaps, boolean flattenArrays) {
Iterator> iter = elements.iterator();
while (iter.hasNext()) {
Object element = iter.next();
if (element instanceof Collection) {
flatten((Collection>) element, addTo, flattenMaps, flattenArrays);
} else if ((element instanceof Map) && flattenMaps) {
flatten(((Map, ?>) element).values(), addTo, flattenMaps, flattenArrays);
} else if ((element.getClass().isArray()) && flattenArrays) {
flatten(asList((Object[]) element), addTo, flattenMaps, flattenArrays);
} else {
(Cast.>uncheckedNonnullCast(addTo)).add(element);
}
}
return addTo;
}
/**
* Flattens input collections (including arrays *but* not maps). If input is not a collection wraps it in a collection and returns it.
*
* @param input any object
* @return collection of flattened input or single input wrapped in a collection.
*/
public static Collection> collectionize(Object input) {
if (input == null) {
return emptyList();
} else if (input instanceof Collection) {
Collection> out = new LinkedList