Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static io.microsphere.util.SystemUtils.JAVA_HOME;
import static java.util.Collections.emptyList;
import static java.util.Collections.unmodifiableList;
import static io.microsphere.collection.SetUtils.newLinkedHashSet;

/**
* The {@code ArtifactDetector} class is responsible for detecting and resolving artifacts from the classpath.
Expand Down Expand Up @@ -149,7 +150,7 @@

protected Set<URL> getClassPathURLs(boolean includedJdkLibraries) {
Set<URL> urls = findAllClassPathURLs(classLoader);
LinkedHashSet<URL> classPathURLs = new LinkedHashSet<>(urls);
LinkedHashSet<URL> classPathURLs = newLinkedHashSet(urls);

Check warning on line 153 in microsphere-java-core/src/main/java/io/microsphere/classloading/ArtifactDetector.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the URI class instead.

See more on https://sonarcloud.io/project/issues?id=microsphere-projects_microsphere-java&issues=AZ53nb-DdYKePtB9Oln6&open=AZ53nb-DdYKePtB9Oln6&pullRequest=285
if (!includedJdkLibraries) {
removeJdkClassPathURLs(classPathURLs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static io.microsphere.util.StringUtils.isBlank;
import static io.microsphere.util.StringUtils.split;
import static io.microsphere.util.SystemUtils.FILE_ENCODING;
import static io.microsphere.collection.ListUtils.newLinkedList;

/**
* The executor for the banned artifacts that are loading by {@link ClassLoader}.
Expand Down Expand Up @@ -94,7 +95,7 @@ public void execute() {
}

static List<MavenArtifact> loadBannedArtifactConfigs(ClassLoader classLoader) {
LinkedList<MavenArtifact> bannedArtifactConfigs = new LinkedList<>();
LinkedList<MavenArtifact> bannedArtifactConfigs = newLinkedList();
try {
Enumeration<URL> configResources = classLoader.getResources(CONFIG_LOCATION);
while (configResources.hasMoreElements()) {
Expand All @@ -109,7 +110,7 @@ static List<MavenArtifact> loadBannedArtifactConfigs(ClassLoader classLoader) {
}

static List<MavenArtifact> loadBannedArtifactConfigs(URL configResource) throws IOException {
LinkedList<MavenArtifact> bannedArtifactConfigs = new LinkedList<>();
LinkedList<MavenArtifact> bannedArtifactConfigs = newLinkedList();
try (InputStream inputStream = configResource.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, ENCODING))
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import static io.microsphere.util.ServiceLoaderUtils.loadServicesList;
import static java.util.Collections.sort;
import static java.util.Collections.unmodifiableList;
import static io.microsphere.collection.ListUtils.newLinkedList;

/**
* Abstract implementation of {@link EventDispatcher} that provides common functionality for dispatching events to
Expand Down Expand Up @@ -127,7 +128,7 @@
@Override
@Immutable
public List<EventListener<?>> getAllEventListeners() {
LinkedList<EventListener<?>> listeners = new LinkedList<>();
LinkedList<EventListener<?>> listeners = newLinkedList();

sortedListeners().forEach(listener -> {
addIfAbsent(listeners, listener);
Expand Down Expand Up @@ -192,7 +193,7 @@
void doInListener(Class<? extends Event> eventType, Consumer<Collection<EventListener>> consumer) {
if (eventType != null) {
synchronized (mutex) {
List<EventListener> listeners = listenersCache.computeIfAbsent(eventType, e -> new LinkedList<>());
List<EventListener> listeners = listenersCache.computeIfAbsent(eventType, e -> newLinkedList());

Check warning on line 196 in microsphere-java-core/src/main/java/io/microsphere/event/AbstractEventDispatcher.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Provide the parametrized type for this generic.

See more on https://sonarcloud.io/project/issues?id=microsphere-projects_microsphere-java&issues=AZ53ncB0dYKePtB9OloC&open=AZ53ncB0dYKePtB9OloC&pullRequest=285
// consume
consumer.accept(listeners);
// sort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.LinkedHashSet;

Check warning on line 24 in microsphere-java-core/src/main/java/io/microsphere/event/GenericEventListener.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused import 'java.util.LinkedHashSet'.

See more on https://sonarcloud.io/project/issues?id=microsphere-projects_microsphere-java&issues=AZ53ncBidYKePtB9OloB&open=AZ53ncBidYKePtB9OloB&pullRequest=285
import java.util.Map;
import java.util.Set;

Expand All @@ -29,6 +29,7 @@
import static io.microsphere.lang.function.ThrowableConsumer.execute;
import static java.util.Collections.emptySet;
import static java.util.stream.Stream.of;
import static io.microsphere.collection.SetUtils.newLinkedHashSet;

/**
* A generic implementation of the {@link EventListener} interface that supports multiple event handling methods.
Expand Down Expand Up @@ -97,7 +98,7 @@
HashMap<Class<?>, Set<Method>> eventMethods = newHashMap();
of(getClass().getMethods()).filter(this::isHandleEventMethod).forEach(method -> {
Class<?> paramType = method.getParameterTypes()[0];
Set<Method> methods = eventMethods.computeIfAbsent(paramType, key -> new LinkedHashSet<>());
Set<Method> methods = eventMethods.computeIfAbsent(paramType, key -> newLinkedHashSet());
methods.add(method);
});
return eventMethods;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static io.microsphere.util.ClassUtils.getTypeName;
import static java.lang.reflect.Modifier.isFinal;
import static java.util.stream.StreamSupport.stream;
import static io.microsphere.collection.ListUtils.newArrayList;

/**
* A component that allows registration and management of {@link EventListener} instances.
Expand Down Expand Up @@ -111,7 +112,7 @@ static void assertListener(EventListener<?> listener) throws IllegalArgumentExce
*/
default void addEventListeners(E listener, E... others) throws NullPointerException,
IllegalArgumentException {
ArrayList<E> listeners = new ArrayList<>(1 + others.length);
ArrayList<E> listeners = newArrayList(1 + others.length);
listeners.add(listener);
addAll(listeners, others);
addEventListeners(listeners);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.List;

import static java.util.Collections.unmodifiableList;
import static io.microsphere.collection.ListUtils.newArrayList;

/**
* Utility class for working with {@link Filter} instances.
Expand Down Expand Up @@ -74,7 +75,7 @@ public static <E> List<E> filter(Iterable<E> iterable, Filter<E> filter) {
@Nonnull
@Immutable
public static <E> List<E> filter(Iterable<E> iterable, FilterOperator filterOperator, Filter<E>... filters) {
ArrayList<E> list = new ArrayList<E>();
ArrayList<E> list = newArrayList();
Iterator<E> iterator = iterable.iterator();
while (iterator.hasNext()) {
E element = iterator.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.nio.file.Watchable;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

Check warning on line 36 in microsphere-java-core/src/main/java/io/microsphere/io/StandardFileWatchService.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused import 'java.util.TreeSet'.

See more on https://sonarcloud.io/project/issues?id=microsphere-projects_microsphere-java&issues=AZ53ncAudYKePtB9Oln-&open=AZ53ncAudYKePtB9Oln-&pullRequest=285
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
Expand Down Expand Up @@ -63,6 +63,7 @@
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static io.microsphere.collection.SetUtils.newTreeSet;

/**
* /**
Expand Down Expand Up @@ -330,7 +331,7 @@

private static class FileChangedMetadata {

private final Set<Path> filePaths = new TreeSet<>();
private final Set<Path> filePaths = newTreeSet();

private EventDispatcher eventDispatcher;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.microsphere.json.JSONStringer.Scope;

import java.lang.reflect.Array;
import java.util.ArrayList;

Check warning on line 22 in microsphere-java-core/src/main/java/io/microsphere/json/JSONArray.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused import 'java.util.ArrayList'.

See more on https://sonarcloud.io/project/issues?id=microsphere-projects_microsphere-java&issues=AZ53nb_2dYKePtB9Oln7&open=AZ53nb_2dYKePtB9Oln7&pullRequest=285
import java.util.Enumeration;
import java.util.List;

Expand Down Expand Up @@ -82,7 +82,7 @@
* Creates a {@code JSONArray} with no values.
*/
public JSONArray() {
this.values = new ArrayList<>();
this.values = newArrayList();
}

@SuppressWarnings("rawtypes")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import io.microsphere.json.JSONStringer.Scope;

import java.util.ArrayList;

Check warning on line 21 in microsphere-java-core/src/main/java/io/microsphere/json/JSONObject.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused import 'java.util.ArrayList'.

See more on https://sonarcloud.io/project/issues?id=microsphere-projects_microsphere-java&issues=AZ53ncAcdYKePtB9Oln9&open=AZ53ncAcdYKePtB9Oln9&pullRequest=285
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;
Expand All @@ -43,6 +43,7 @@
import static io.microsphere.util.ClassUtils.isEnum;
import static io.microsphere.util.ClassUtils.isNumber;
import static io.microsphere.util.ClassUtils.isWrapperType;
import static io.microsphere.collection.ListUtils.newArrayList;

/**
* A modifiable set of name/value mappings. Names are unique, non-null strings. Values may
Expand Down Expand Up @@ -730,7 +731,7 @@
* @return the array
*/
public JSONArray names() {
return this.nameValuePairs.isEmpty() ? null : new JSONArray(new ArrayList<>(this.nameValuePairs.keySet()));
return this.nameValuePairs.isEmpty() ? null : new JSONArray(newArrayList(this.nameValuePairs.keySet()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package io.microsphere.json;

import java.util.ArrayList;

Check warning on line 19 in microsphere-java-core/src/main/java/io/microsphere/json/JSONStringer.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused import 'java.util.ArrayList'.

See more on https://sonarcloud.io/project/issues?id=microsphere-projects_microsphere-java&issues=AZ53ncAIdYKePtB9Oln8&open=AZ53ncAIdYKePtB9Oln8&pullRequest=285
import java.util.List;

import static io.microsphere.json.JSONObject.NULL;
Expand All @@ -29,6 +29,7 @@
import static io.microsphere.util.ClassUtils.getTypeName;
import static java.lang.String.format;
import static java.util.Arrays.fill;
import static io.microsphere.collection.ListUtils.newArrayList;

/**
* Implements {@link JSONObject#toString} and {@link JSONArray#toString}. Most application
Expand Down Expand Up @@ -121,7 +122,7 @@
* Unlike the original implementation, this stack isn't limited to 20 levels of
* nesting.
*/
private final List<Scope> stack = new ArrayList<>();
private final List<Scope> stack = newArrayList();

/**
* A string containing a full set of spaces for a single level of indentation, or null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
import java.beans.PropertyDescriptor;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.LinkedList;

Check warning on line 33 in microsphere-java-core/src/main/java/io/microsphere/management/builder/MBeanInfoBuilder.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused import 'java.util.LinkedList'.

See more on https://sonarcloud.io/project/issues?id=microsphere-projects_microsphere-java&issues=AZ53ncBSdYKePtB9OloA&open=AZ53ncBSdYKePtB9OloA&pullRequest=285
import java.util.List;
import java.util.function.Consumer;

import static io.microsphere.reflect.MethodUtils.isIsMethod;
import static io.microsphere.util.ClassUtils.getTypeName;
import static java.util.Objects.nonNull;
import static io.microsphere.collection.ListUtils.newLinkedList;

/**
* The {@link MBeanInfo} Builder
Expand All @@ -54,16 +55,16 @@
String className;

@Nullable
List<MBeanAttributeInfoBuilder> attributeBuilders = new LinkedList<>();
List<MBeanAttributeInfoBuilder> attributeBuilders = newLinkedList();

@Nullable
List<MBeanOperationInfoBuilder> operationBuilders = new LinkedList<>();
List<MBeanOperationInfoBuilder> operationBuilders = newLinkedList();

@Nullable
List<MBeanConstructorInfoBuilder> constructorBuilders = new LinkedList<>();
List<MBeanConstructorInfoBuilder> constructorBuilders = newLinkedList();

@Nullable
List<MBeanNotificationInfoBuilder> notificationBuilders = new LinkedList<>();
List<MBeanNotificationInfoBuilder> notificationBuilders = newLinkedList();

public MBeanInfoBuilder attribute(String attributeName, Class<?> attributeType, Consumer<MBeanAttributeInfoBuilder> builderConsumer) {
MBeanAttributeInfoBuilder builder = MBeanAttributeInfoBuilder.attribute(attributeType).name(attributeName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.util.ArrayList;

Check warning on line 27 in microsphere-java-core/src/main/java/io/microsphere/net/ExtendableProtocolURLStreamHandler.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused import 'java.util.ArrayList'.

See more on https://sonarcloud.io/project/issues?id=microsphere-projects_microsphere-java&issues=AZ53ncBBdYKePtB9Oln_&open=AZ53ncBBdYKePtB9Oln_&pullRequest=285
import java.util.List;
import java.util.Objects;
import java.util.Set;
Expand All @@ -50,6 +50,7 @@
import static java.lang.System.setProperty;
import static java.net.Proxy.NO_PROXY;
import static java.util.Collections.sort;
import static io.microsphere.collection.ListUtils.newArrayList;

/**
* Extendable Protocol {@link URLStreamHandler} class supports the sub-protocols,
Expand Down Expand Up @@ -133,7 +134,7 @@

private final String protocol;

private final List<SubProtocolURLConnectionFactory> factories = new ArrayList<>();
private final List<SubProtocolURLConnectionFactory> factories = newArrayList();

/**
* The default constructor must obey the following conventions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.function.Predicate;

import static io.microsphere.annotation.ConfigurationProperty.SYSTEM_PROPERTIES_SOURCE;
import static io.microsphere.collection.ListUtils.newLinkedList;
import static io.microsphere.collection.ListUtils.of;
import static io.microsphere.constants.PropertyConstants.MICROSPHERE_PROPERTY_NAME_PREFIX;
import static io.microsphere.constants.SymbolConstants.COMMA_CHAR;
Expand Down Expand Up @@ -567,7 +568,7 @@ public static List<Method> findMethods(Class<?> targetClass, boolean includeInhe
}

// All methods
LinkedList<Method> allMethods = new LinkedList<>();
LinkedList<Method> allMethods = newLinkedList();

if (includeInheritedTypes) {
while (targetClass != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import static java.lang.reflect.Array.getLength;
import static java.util.Collections.emptyMap;
import static java.util.Collections.unmodifiableMap;
import static io.microsphere.collection.ListUtils.newArrayList;

/**
* Reflection Utility class , generic methods are defined from {@link FieldUtils} , {@link MethodUtils} , {@link
Expand Down Expand Up @@ -375,7 +376,7 @@ static String getCallerClassNameInSunReflectReflection() {
@Nonnull
public static <T> List<T> toList(Object array) throws IllegalArgumentException {
int length = getLength(array);
ArrayList<T> list = new ArrayList<>(length);
ArrayList<T> list = newArrayList(length);
for (int i = 0; i < length; i++) {
Object element = get(array, i);
list.add((T) toObject(element));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ public static List<Annotation> findAllDeclaredAnnotations(Class<?> type, Predica
return emptyList();
}

LinkedList<Annotation> allAnnotations = new LinkedList<>();
LinkedList<Annotation> allAnnotations = newLinkedList();
List<Class<?>> allInheritedClasses = findAllInheritedClasses(type, NON_OBJECT_CLASS_FILTER);

// Add the declared annotations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package io.microsphere.util;

import java.util.LinkedList;

Check warning on line 19 in microsphere-java-core/src/main/java/io/microsphere/util/StopWatch.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused import 'java.util.LinkedList'.

See more on https://sonarcloud.io/project/issues?id=microsphere-projects_microsphere-java&issues=AZ53nb7TdYKePtB9Oln5&open=AZ53nb7TdYKePtB9Oln5&pullRequest=285
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
Expand All @@ -28,6 +28,7 @@
import static java.util.Collections.unmodifiableList;
import static java.util.Objects.hash;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static io.microsphere.collection.ListUtils.newLinkedList;

/**
* <p>{@code StopWatch} provides a simple way to measure execution time for tasks, supporting nested task tracking.
Expand Down Expand Up @@ -80,12 +81,12 @@
/**
* Running tasks(FIFO)
*/
private final List<Task> runningTasks = new LinkedList<>();
private final List<Task> runningTasks = newLinkedList();

/**
* Completed tasks(FILO)
*/
private final List<Task> completedTasks = new LinkedList<>();
private final List<Task> completedTasks = newLinkedList();

/**
* Total running time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import static java.lang.Character.toLowerCase;
import static java.lang.Character.toUpperCase;
import static java.lang.String.valueOf;
import static io.microsphere.collection.ListUtils.newArrayList;

/**
* The utilities class for {@link String}
Expand Down Expand Up @@ -169,7 +170,7 @@ public static String[] split(@Nullable String value, @Nullable String delimiter)

int delimiterLength = delimiter.length();

ArrayList<String> result = new ArrayList<>();
ArrayList<String> result = newArrayList();

if (delimiterLength == 0) {
for (int i = 0; i < length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.jar.JarFile;

import static io.microsphere.collection.CollectionUtils.isEmpty;
import static io.microsphere.collection.ListUtils.newLinkedList;
import static io.microsphere.collection.ListUtils.ofList;
import static io.microsphere.constants.ProtocolConstants.FILE_PROTOCOL;
import static io.microsphere.constants.ProtocolConstants.JAR_PROTOCOL;
Expand Down Expand Up @@ -215,7 +216,7 @@ public static List<JarEntry> filter(JarFile jarFile, JarEntryFilter jarEntryFilt
@Nonnull
@Immutable
protected static List<JarEntry> doFilter(Iterable<JarEntry> jarEntries, JarEntryFilter jarEntryFilter) {
LinkedList<JarEntry> jarEntriesList = new LinkedList<>();
LinkedList<JarEntry> jarEntriesList = newLinkedList();
for (JarEntry jarEntry : jarEntries) {
if (jarEntryFilter == null || jarEntryFilter.accept(jarEntry)) {
jarEntriesList.add(jarEntry);
Expand Down
Loading