{@code
* public class SimpleDeque extends AbstractDeque {
- * private final List list = new ArrayList<>();
+ * private final List list = newArrayList();
*
* public void addFirst(E e) {
* list.add(0, e);
diff --git a/microsphere-java-core/src/main/java/io/microsphere/collection/CollectionUtils.java b/microsphere-java-core/src/main/java/io/microsphere/collection/CollectionUtils.java
index 0cf6c7ae3..385a9e449 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/collection/CollectionUtils.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/collection/CollectionUtils.java
@@ -440,7 +440,7 @@ public static boolean equals(@Nullable Collection> one, @Nullable Collection
*
*
Example Usage
*
{@code
- * Collection collection = new ArrayList<>();
+ * Collection collection = newArrayList();
* int count1 = CollectionUtils.addAll(collection, "a", "b", "c"); // returns 3
*
* int count2 = CollectionUtils.addAll(null, "a", "b"); // returns 0
@@ -486,7 +486,7 @@ public static int addAll(@Nullable Collection collection, T... newValues)
*
*
Example Usage
*
{@code
- * Collection collection = new ArrayList<>();
+ * Collection collection = newArrayList();
* Iterable values = Arrays.asList("a", "b", "c");
* int count1 = CollectionUtils.addAll(collection, values); // returns 3
*
diff --git a/microsphere-java-core/src/main/java/io/microsphere/collection/UnmodifiableDeque.java b/microsphere-java-core/src/main/java/io/microsphere/collection/UnmodifiableDeque.java
index 04630e7b2..30495d17a 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/collection/UnmodifiableDeque.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/collection/UnmodifiableDeque.java
@@ -24,6 +24,7 @@
import java.util.Iterator;
import static io.microsphere.collection.CollectionUtils.unmodifiableIterator;
+import static io.microsphere.collection.ListUtils.*;
/**
* An unmodifiable view of a {@link Deque}. This implementation decorates a given deque and prevents any
@@ -40,7 +41,7 @@
*
*
*
{@code
- * Deque mutableDeque = new LinkedList<>();
+ * Deque mutableDeque = newLinkedList();
* mutableDeque.addFirst("World");
* Deque unmodifiableDeque = new UnmodifiableDeque<>(mutableDeque);
* unmodifiableDeque.addFirst("Hello"); // throws UnsupportedOperationException
diff --git a/microsphere-java-core/src/main/java/io/microsphere/collection/UnmodifiableQueue.java b/microsphere-java-core/src/main/java/io/microsphere/collection/UnmodifiableQueue.java
index 77729e8fe..9f2eb72b5 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/collection/UnmodifiableQueue.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/collection/UnmodifiableQueue.java
@@ -29,6 +29,7 @@
import java.util.stream.Stream;
import static io.microsphere.collection.CollectionUtils.unmodifiableIterator;
+import static io.microsphere.collection.ListUtils.*;
/**
* An unmodifiable view of a {@link Queue}. This implementation decorates a given queue and prevents any
@@ -45,7 +46,7 @@
*
*
*
{@code
- * Queue mutableQueue = new LinkedList<>();
+ * Queue mutableQueue = newLinkedList();
* mutableQueue.add("Hello");
* Queue unmodifiableQueue = new UnmodifiableQueue<>(mutableQueue);
* unmodifiableQueue.add("World"); // throws UnsupportedOperationException
diff --git a/microsphere-java-core/src/main/java/io/microsphere/event/AbstractEventDispatcher.java b/microsphere-java-core/src/main/java/io/microsphere/event/AbstractEventDispatcher.java
index bea8ef142..40cd1f367 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/event/AbstractEventDispatcher.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/event/AbstractEventDispatcher.java
@@ -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.*;
/**
* Abstract implementation of {@link EventDispatcher} that provides common functionality for dispatching events to
@@ -127,7 +128,7 @@ public void removeEventListener(EventListener> listener) throws NullPointerExc
@Override
@Immutable
public List> getAllEventListeners() {
- LinkedList> listeners = new LinkedList<>();
+ LinkedList> listeners = newLinkedList();
sortedListeners().forEach(listener -> {
addIfAbsent(listeners, listener);
@@ -192,7 +193,7 @@ protected void doInListener(EventListener> listener, Consumer eventType, Consumer> consumer) {
if (eventType != null) {
synchronized (mutex) {
- List listeners = listenersCache.computeIfAbsent(eventType, e -> new LinkedList<>());
+ List listeners = listenersCache.computeIfAbsent(eventType, e -> newLinkedList());
// consume
consumer.accept(listeners);
// sort
diff --git a/microsphere-java-core/src/main/java/io/microsphere/event/GenericEventListener.java b/microsphere-java-core/src/main/java/io/microsphere/event/GenericEventListener.java
index 8e2d040e4..1966c0454 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/event/GenericEventListener.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/event/GenericEventListener.java
@@ -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.*;
/**
* A generic implementation of the {@link EventListener} interface that supports multiple event handling methods.
@@ -97,7 +98,7 @@ private Map, Set> findHandleEventMethods() {
HashMap, Set> eventMethods = newHashMap();
of(getClass().getMethods()).filter(this::isHandleEventMethod).forEach(method -> {
Class> paramType = method.getParameterTypes()[0];
- Set methods = eventMethods.computeIfAbsent(paramType, key -> new LinkedHashSet<>());
+ Set methods = eventMethods.computeIfAbsent(paramType, key -> newLinkedHashSet());
methods.add(method);
});
return eventMethods;
diff --git a/microsphere-java-core/src/main/java/io/microsphere/event/Listenable.java b/microsphere-java-core/src/main/java/io/microsphere/event/Listenable.java
index 81bcb169a..c937f500f 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/event/Listenable.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/event/Listenable.java
@@ -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.*;
/**
* A component that allows registration and management of {@link EventListener} instances.
@@ -111,7 +112,7 @@ static void assertListener(EventListener> listener) throws IllegalArgumentExce
*/
default void addEventListeners(E listener, E... others) throws NullPointerException,
IllegalArgumentException {
- ArrayList listeners = new ArrayList<>(1 + others.length);
+ ArrayList listeners = newArrayList(1 + others.length);
listeners.add(listener);
addAll(listeners, others);
addEventListeners(listeners);
diff --git a/microsphere-java-core/src/main/java/io/microsphere/filter/FilterUtils.java b/microsphere-java-core/src/main/java/io/microsphere/filter/FilterUtils.java
index 8725c3b6c..6dfda1453 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/filter/FilterUtils.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/filter/FilterUtils.java
@@ -12,6 +12,7 @@
import java.util.List;
import static java.util.Collections.unmodifiableList;
+import static io.microsphere.collection.ListUtils.*;
/**
* Utility class for working with {@link Filter} instances.
@@ -74,7 +75,7 @@ public static List filter(Iterable iterable, Filter filter) {
@Nonnull
@Immutable
public static List filter(Iterable iterable, FilterOperator filterOperator, Filter... filters) {
- ArrayList list = new ArrayList();
+ ArrayList list = newArrayList();
Iterator iterator = iterable.iterator();
while (iterator.hasNext()) {
E element = iterator.next();
diff --git a/microsphere-java-core/src/main/java/io/microsphere/io/StandardFileWatchService.java b/microsphere-java-core/src/main/java/io/microsphere/io/StandardFileWatchService.java
index 94576736b..b6ccdcf7c 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/io/StandardFileWatchService.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/io/StandardFileWatchService.java
@@ -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.*;
/**
* /**
@@ -330,7 +331,7 @@ static Kind toKind(WatchEvent.Kind> watchEventKind) {
private static class FileChangedMetadata {
- private final Set filePaths = new TreeSet<>();
+ private final Set filePaths = newTreeSet();
private EventDispatcher eventDispatcher;
diff --git a/microsphere-java-core/src/main/java/io/microsphere/json/JSONArray.java b/microsphere-java-core/src/main/java/io/microsphere/json/JSONArray.java
index b5fe96af6..7257fa2f9 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/json/JSONArray.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/json/JSONArray.java
@@ -82,7 +82,7 @@ public class JSONArray {
* Creates a {@code JSONArray} with no values.
*/
public JSONArray() {
- this.values = new ArrayList<>();
+ this.values = newArrayList();
}
@SuppressWarnings("rawtypes")
diff --git a/microsphere-java-core/src/main/java/io/microsphere/json/JSONObject.java b/microsphere-java-core/src/main/java/io/microsphere/json/JSONObject.java
index d07a16292..c1d3c0268 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/json/JSONObject.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/json/JSONObject.java
@@ -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.*;
/**
* A modifiable set of name/value mappings. Names are unique, non-null strings. Values may
@@ -730,7 +731,7 @@ public Iterator keys() {
* @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()));
}
/**
diff --git a/microsphere-java-core/src/main/java/io/microsphere/json/JSONStringer.java b/microsphere-java-core/src/main/java/io/microsphere/json/JSONStringer.java
index ffb062aec..8ea9c1adc 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/json/JSONStringer.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/json/JSONStringer.java
@@ -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.*;
/**
* Implements {@link JSONObject#toString} and {@link JSONArray#toString}. Most application
@@ -121,7 +122,7 @@ enum Scope {
* Unlike the original implementation, this stack isn't limited to 20 levels of
* nesting.
*/
- private final List stack = new ArrayList<>();
+ private final List stack = newArrayList();
/**
* A string containing a full set of spaces for a single level of indentation, or null
diff --git a/microsphere-java-core/src/main/java/io/microsphere/lang/Prioritized.java b/microsphere-java-core/src/main/java/io/microsphere/lang/Prioritized.java
index b369e3840..d26c8ee5e 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/lang/Prioritized.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/lang/Prioritized.java
@@ -21,6 +21,7 @@
import static java.lang.Integer.MAX_VALUE;
import static java.lang.Integer.MIN_VALUE;
import static java.lang.Integer.compare;
+import static io.microsphere.collection.ListUtils.*;
/**
* {@code Prioritized} interface can be implemented by objects that
@@ -45,7 +46,7 @@
* }
*
* // Sorting a list of Prioritized objects
- * List tasks = new ArrayList<>();
+ * List tasks = newArrayList();
* tasks.add(new MyTask(5));
* tasks.add(new MyTask(1));
* Collections.sort(tasks);
diff --git a/microsphere-java-core/src/main/java/io/microsphere/lang/function/Streams.java b/microsphere-java-core/src/main/java/io/microsphere/lang/function/Streams.java
index 863566055..ce140ca8f 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/lang/function/Streams.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/lang/function/Streams.java
@@ -255,7 +255,7 @@ static > Set filterSet(S values, Predicate super T
*
*
Example Usage with Set
*
{@code
- * Set names = new LinkedHashSet<>(Arrays.asList("Alice", "Bob", "Charlie", "Anna"));
+ * Set names = newLinkedHashSet(Arrays.asList("Alice", "Bob", "Charlie", "Anna"));
* Set filteredSet = Streams.filter(names, name -> name.startsWith("A"));
* System.out.println(filteredSet); // Output: [Alice, Anna]
* }
@@ -291,7 +291,7 @@ static > S filter(S values, Predicate super T> predic
*
*
Example Usage with Set
*
{@code
- * Set names = new LinkedHashSet<>(Arrays.asList("Alice", "Anna", "Bob", "Andrew"));
+ * Set names = newLinkedHashSet(Arrays.asList("Alice", "Anna", "Bob", "Andrew"));
* Set filtered = Streams.filterAll(names,
* name -> name.startsWith("A"),
* name -> name.length() > 4
@@ -385,7 +385,7 @@ static Set filterAllSet(T[] values, Predicate super T>... predicates) {
*
*
Example Usage with Set
*
{@code
- * Set names = new LinkedHashSet<>(Arrays.asList("Alice", "Anna", "Bob", "Andrew"));
+ * Set names = newLinkedHashSet(Arrays.asList("Alice", "Anna", "Bob", "Andrew"));
* Set filtered = Streams.filterAny(names,
* name -> name.startsWith("B"),
* name -> name.length() <= 3
@@ -484,7 +484,7 @@ static Set filterAnySet(T[] values, Predicate super T>... predicates) {
*
*
Example Usage with Set
*
{@code
- * Set names = new LinkedHashSet<>(Arrays.asList("Alice", "Anna", "Bob", "Andrew"));
+ * Set names = newLinkedHashSet(Arrays.asList("Alice", "Anna", "Bob", "Andrew"));
* String result = Streams.filterFirst(names,
* name -> name.startsWith("A"),
* name -> name.length() > 4
diff --git a/microsphere-java-core/src/main/java/io/microsphere/management/builder/MBeanInfoBuilder.java b/microsphere-java-core/src/main/java/io/microsphere/management/builder/MBeanInfoBuilder.java
index 25d0b747c..6ad908cb2 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/management/builder/MBeanInfoBuilder.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/management/builder/MBeanInfoBuilder.java
@@ -37,6 +37,7 @@
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.*;
/**
* The {@link MBeanInfo} Builder
@@ -54,16 +55,16 @@ public class MBeanInfoBuilder extends MBeanDescribableBuilder
String className;
@Nullable
- List attributeBuilders = new LinkedList<>();
+ List attributeBuilders = newLinkedList();
@Nullable
- List operationBuilders = new LinkedList<>();
+ List operationBuilders = newLinkedList();
@Nullable
- List constructorBuilders = new LinkedList<>();
+ List constructorBuilders = newLinkedList();
@Nullable
- List notificationBuilders = new LinkedList<>();
+ List notificationBuilders = newLinkedList();
public MBeanInfoBuilder attribute(String attributeName, Class> attributeType, Consumer builderConsumer) {
MBeanAttributeInfoBuilder builder = MBeanAttributeInfoBuilder.attribute(attributeType).name(attributeName);
diff --git a/microsphere-java-core/src/main/java/io/microsphere/metadata/ConfigurationPropertyGenerator.java b/microsphere-java-core/src/main/java/io/microsphere/metadata/ConfigurationPropertyGenerator.java
index a45956fc0..1b42522ee 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/metadata/ConfigurationPropertyGenerator.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/metadata/ConfigurationPropertyGenerator.java
@@ -20,6 +20,7 @@
import io.microsphere.annotation.Nonnull;
import io.microsphere.beans.ConfigurationProperty;
import io.microsphere.lang.Prioritized;
+import static io.microsphere.collection.ListUtils.*;
/**
* {@code ConfigurationPropertyGenerator} interface can be implemented by objects that
@@ -43,7 +44,7 @@
* }
*
* // Registering and using generators
- * List generators = new ArrayList<>();
+ * List generators = newArrayList();
* generators.add(new JsonPropertyGenerator());
* Collections.sort(generators); // Sort by priority
* }
diff --git a/microsphere-java-core/src/main/java/io/microsphere/net/ExtendableProtocolURLStreamHandler.java b/microsphere-java-core/src/main/java/io/microsphere/net/ExtendableProtocolURLStreamHandler.java
index 6a6d8c6be..ce22fb6cb 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/net/ExtendableProtocolURLStreamHandler.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/net/ExtendableProtocolURLStreamHandler.java
@@ -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.*;
/**
* Extendable Protocol {@link URLStreamHandler} class supports the sub-protocols,
@@ -133,7 +134,7 @@ public abstract class ExtendableProtocolURLStreamHandler extends URLStreamHandle
private final String protocol;
- private final List factories = new ArrayList<>();
+ private final List factories = newArrayList();
/**
* The default constructor must obey the following conventions:
diff --git a/microsphere-java-core/src/main/java/io/microsphere/net/URLUtils.java b/microsphere-java-core/src/main/java/io/microsphere/net/URLUtils.java
index b504c9679..14afeb3be 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/net/URLUtils.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/net/URLUtils.java
@@ -818,7 +818,7 @@ public static String buildURI(String... paths) {
*
Example Usage
*
{@code
* // Example 1: Basic usage with multiple parameters
- * Map> matrixParams = new LinkedHashMap<>();
+ * Map> matrixParams = newLinkedHashMap();
* matrixParams.put("key1", Arrays.asList("valueA", "valueB"));
* matrixParams.put("key2", Collections.singletonList("valueC"));
* matrixParams.put("_sp", Arrays.asList("subproto1", "subproto2")); // This will be skipped
diff --git a/microsphere-java-core/src/main/java/io/microsphere/reflect/JavaType.java b/microsphere-java-core/src/main/java/io/microsphere/reflect/JavaType.java
index efad76a35..19c3cebe8 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/reflect/JavaType.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/reflect/JavaType.java
@@ -52,6 +52,7 @@
import static io.microsphere.util.ArrayUtils.asArray;
import static io.microsphere.util.ArrayUtils.length;
import static java.util.Objects.hash;
+import static io.microsphere.collection.MapUtils.*;
/**
* Represents a Java type, encapsulating various operations and utilities for handling different kinds of types,
@@ -860,7 +861,7 @@ public static JavaType fromField(Field field) {
*
{@code
* public class Example {
* public Map getExampleMap() {
- * return new HashMap<>();
+ * return newHashMap();
* }
*
* public static void main(String[] args) {
@@ -892,7 +893,7 @@ public static JavaType fromMethodReturnType(Class> declaredClass, String metho
*
{@code
* public class Example {
* public Map getExampleMap() {
- * return new HashMap<>();
+ * return newHashMap();
* }
*
* public static void main(String[] args) throws Throwable {
diff --git a/microsphere-java-core/src/main/java/io/microsphere/reflect/MethodUtils.java b/microsphere-java-core/src/main/java/io/microsphere/reflect/MethodUtils.java
index cb5d7cef7..796fe7d1f 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/reflect/MethodUtils.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/reflect/MethodUtils.java
@@ -567,7 +567,7 @@ public static List findMethods(Class> targetClass, boolean includeInhe
}
// All methods
- LinkedList allMethods = new LinkedList<>();
+ LinkedList allMethods = newLinkedList();
if (includeInheritedTypes) {
while (targetClass != null) {
diff --git a/microsphere-java-core/src/main/java/io/microsphere/reflect/ReflectionUtils.java b/microsphere-java-core/src/main/java/io/microsphere/reflect/ReflectionUtils.java
index c38289668..7ab6b1c38 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/reflect/ReflectionUtils.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/reflect/ReflectionUtils.java
@@ -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.*;
/**
* Reflection Utility class , generic methods are defined from {@link FieldUtils} , {@link MethodUtils} , {@link
@@ -375,7 +376,7 @@ static String getCallerClassNameInSunReflectReflection() {
@Nonnull
public static List toList(Object array) throws IllegalArgumentException {
int length = getLength(array);
- ArrayList list = new ArrayList<>(length);
+ ArrayList list = newArrayList(length);
for (int i = 0; i < length; i++) {
Object element = get(array, i);
list.add((T) toObject(element));
diff --git a/microsphere-java-core/src/main/java/io/microsphere/reflect/TypeUtils.java b/microsphere-java-core/src/main/java/io/microsphere/reflect/TypeUtils.java
index 7aa07213b..987a6651e 100644
--- a/microsphere-java-core/src/main/java/io/microsphere/reflect/TypeUtils.java
+++ b/microsphere-java-core/src/main/java/io/microsphere/reflect/TypeUtils.java
@@ -67,6 +67,7 @@
import static java.util.stream.Collectors.toSet;
import static java.util.stream.Stream.of;
import static java.util.stream.StreamSupport.stream;
+import static io.microsphere.collection.SetUtils.*;
/**
* The utilities class for {@link Type}
@@ -174,7 +175,7 @@ public static boolean isObjectType(Object type) {
*