diff --git a/src/java.base/share/classes/java/lang/Runtime.java b/src/java.base/share/classes/java/lang/Runtime.java index 661348b6297..02a4fcf2324 100644 --- a/src/java.base/share/classes/java/lang/Runtime.java +++ b/src/java.base/share/classes/java/lang/Runtime.java @@ -124,7 +124,7 @@ */ @NullMarked -public class Runtime { +public class Runtime { private static final Runtime currentRuntime = new Runtime(); private static Version version; @@ -177,7 +177,6 @@ private Runtime() {} * @see #removeShutdownHook * @see #halt(int) */ - public void exit(int status) { Shutdown.exit(status); } @@ -368,6 +367,7 @@ public Process exec(String command) throws IOException { * @see #exec(String[], String[], File) * @see ProcessBuilder */ + @Deprecated(since="18") public Process exec(String command, String @Nullable [] envp) throws IOException { return exec(command, envp, null); } diff --git a/src/java.base/share/classes/java/util/Collections.java b/src/java.base/share/classes/java/util/Collections.java index 3fb41218f4c..c9eaf5a105e 100644 --- a/src/java.base/share/classes/java/util/Collections.java +++ b/src/java.base/share/classes/java/util/Collections.java @@ -385,7 +385,7 @@ else if (cmp > 0) * @see List#reversed List.reversed */ @SuppressWarnings({"rawtypes", "unchecked"}) - public static void reverse( List list) { + public static void reverse(List list) { int size = list.size(); if (size < REVERSE_THRESHOLD || list instanceof RandomAccess) { for (int i=0, mid=size>>1, j=size-1; i list) { * @throws UnsupportedOperationException if the specified list or * its list-iterator does not support the {@code set} operation. */ - public static void shuffle( List list) { + public static void shuffle(List list) { Random rnd = r; if (rnd == null) r = rnd = new Random(); // harmless race. @@ -522,7 +522,7 @@ public static void shuffle(List list, RandomGenerator rnd) { * @since 1.4 */ @SuppressWarnings({"rawtypes", "unchecked"}) - public static void swap( List list, int i, int j) { + public static void swap(List list, int i, int j) { // instead of using a raw type here, it's possible to capture // the wildcard but it will require a call to a supplementary // private method @@ -551,7 +551,7 @@ private static void swap(Object[] arr, int i, int j) { * @throws UnsupportedOperationException if the specified list or its * list-iterator does not support the {@code set} operation. */ - public static void fill( List list, T obj) { + public static void fill(List list, T obj) { int size = list.size(); if (size < FILL_THRESHOLD || list instanceof RandomAccess) { @@ -804,7 +804,7 @@ public static > T max(Collection list, int distance) { + public static void rotate(List list, int distance) { if (list instanceof RandomAccess || list.size() < ROTATE_THRESHOLD) rotate1(list, distance); else @@ -929,8 +929,7 @@ private static void rotate2(List list, int distance) { * is no such occurrence. * @since 1.4 */ - - public static int indexOfSubList( List source, List target) { + public static int indexOfSubList(List source, List target) { int sourceSize = source.size(); int targetSize = target.size(); int maxCandidate = sourceSize - targetSize; @@ -983,8 +982,7 @@ public static int indexOfSubList( List source, List target) { * is no such occurrence. * @since 1.4 */ - - public static int lastIndexOfSubList( List source, List target) { + public static int lastIndexOfSubList(List source, List target) { int sourceSize = source.size(); int targetSize = target.size(); int maxCandidate = sourceSize - targetSize; @@ -1046,6 +1044,7 @@ public static int lastIndexOfSubList( List source, List target) { * returned. * @return an unmodifiable view of the specified collection. */ + @SuppressWarnings("unchecked") public static Collection unmodifiableCollection(Collection c) { if (c.getClass() == UnmodifiableCollection.class) { return (Collection) c; @@ -1069,19 +1068,14 @@ static class UnmodifiableCollection implements Collection, Serializable { this.c = c; } - - public int size() {return c.size();} - + public int size() {return c.size();} public boolean isEmpty() {return c.isEmpty();} public boolean contains(@Nullable Object o) {return c.contains(o);} - public @Nullable Object[] toArray() {return c.toArray();} - public T[] toArray(T[] a) {return c.toArray(a);} public T[] toArray(IntFunction f) {return c.toArray(f);} public String toString() {return c.toString();} - public Iterator iterator() { return new Iterator<>() { private final Iterator i = c.iterator(); @@ -1131,7 +1125,6 @@ public void forEach(Consumer action) { public boolean removeIf(Predicate filter) { throw new UnsupportedOperationException(); } - @SuppressWarnings("unchecked") @Override public Spliterator spliterator() { @@ -1662,18 +1655,12 @@ private static class UnmodifiableMap keySet() { return keySet; } - public Set> entrySet() { if (entrySet==null) entrySet = new UnmodifiableEntrySet<>(m.entrySet()); @@ -1732,7 +1718,6 @@ public void replaceAll(BiFunction function) { throw new UnsupportedOperationException(); } - @Override public V putIfAbsent(K key, V value) { throw new UnsupportedOperationException(); @@ -2093,13 +2078,10 @@ static class UnmodifiableSortedMap m) {super(m); sm = m; } public Comparator comparator() { return sm.comparator(); } - public SortedMap subMap(K fromKey, K toKey) { return new UnmodifiableSortedMap<>(sm.subMap(fromKey, toKey)); } - public SortedMap headMap(K toKey) { return new UnmodifiableSortedMap<>(sm.headMap(toKey)); } - public SortedMap tailMap(K fromKey) { return new UnmodifiableSortedMap<>(sm.tailMap(fromKey)); } public K firstKey() { return sm.firstKey(); } @@ -2158,7 +2140,6 @@ private static class EmptyNavigableMap()); } @Override - public NavigableSet navigableKeySet() { return emptyNavigableSet(); } @@ -2239,26 +2220,20 @@ public Entry pollFirstEntry() { throw new UnsupportedOperationException(); } public Entry pollLastEntry() { throw new UnsupportedOperationException(); } - public NavigableMap descendingMap() { return unmodifiableNavigableMap(nm.descendingMap()); } - public NavigableSet navigableKeySet() { return unmodifiableNavigableSet(nm.navigableKeySet()); } - public NavigableSet descendingKeySet() { return unmodifiableNavigableSet(nm.descendingKeySet()); } - public NavigableMap subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { return unmodifiableNavigableMap( nm.subMap(fromKey, fromInclusive, toKey, toInclusive)); } - public NavigableMap headMap(K toKey, boolean inclusive) { return unmodifiableNavigableMap(nm.headMap(toKey, inclusive)); } - public NavigableMap tailMap(K fromKey, boolean inclusive) { return unmodifiableNavigableMap(nm.tailMap(fromKey, inclusive)); } } @@ -2328,22 +2303,18 @@ static class SynchronizedCollection implements Collection, Serializable { this.mutex = Objects.requireNonNull(mutex); } - - public int size() { + public int size() { synchronized (mutex) {return c.size();} } - public boolean isEmpty() { synchronized (mutex) {return c.isEmpty();} } public boolean contains(@Nullable Object o) { synchronized (mutex) {return c.contains(o);} } - public @Nullable Object[] toArray() { synchronized (mutex) {return c.toArray();} } - public T[] toArray(T[] a) { synchronized (mutex) {return c.toArray(a);} } @@ -2351,7 +2322,6 @@ public boolean contains(@Nullable Object o) { synchronized (mutex) {return c.toArray(f);} } - public Iterator iterator() { return c.iterator(); // Must be manually synched by user! } @@ -2390,7 +2360,6 @@ public void forEach(Consumer consumer) { public boolean removeIf(Predicate filter) { synchronized (mutex) {return c.removeIf(filter);} } - @Override public Spliterator spliterator() { return c.spliterator(); // Must be manually synched by user! @@ -2913,20 +2882,15 @@ private static class SynchronizedMap keySet() { } } - public Set> entrySet() { synchronized (mutex) { if (entrySet==null) @@ -3002,7 +2964,6 @@ public void forEach(BiConsumer action) { public void replaceAll(BiFunction function) { synchronized (mutex) {m.replaceAll(function);} } - @Override public V putIfAbsent(K key, V value) { synchronized (mutex) {return m.putIfAbsent(key, value);} @@ -3121,20 +3082,17 @@ public Comparator comparator() { synchronized (mutex) {return sm.comparator();} } - public SortedMap subMap(K fromKey, K toKey) { synchronized (mutex) { return new SynchronizedSortedMap<>( sm.subMap(fromKey, toKey), mutex); } } - public SortedMap headMap(K toKey) { synchronized (mutex) { return new SynchronizedSortedMap<>(sm.headMap(toKey), mutex); } } - public SortedMap tailMap(K fromKey) { synchronized (mutex) { return new SynchronizedSortedMap<>(sm.tailMap(fromKey),mutex); @@ -3249,7 +3207,6 @@ public Entry pollFirstEntry() public Entry pollLastEntry() { synchronized (mutex) { return nm.pollLastEntry(); } } - public NavigableMap descendingMap() { synchronized (mutex) { return @@ -3261,14 +3218,12 @@ public NavigableSet keySet() { return navigableKeySet(); } - public NavigableSet navigableKeySet() { synchronized (mutex) { return new SynchronizedNavigableSet<>(nm.navigableKeySet(), mutex); } } - public NavigableSet descendingKeySet() { synchronized (mutex) { return new SynchronizedNavigableSet<>(nm.descendingKeySet(), mutex); @@ -3276,27 +3231,23 @@ public NavigableSet descendingKeySet() { } - public SortedMap subMap(K fromKey, K toKey) { synchronized (mutex) { return new SynchronizedNavigableMap<>( nm.subMap(fromKey, true, toKey, false), mutex); } } - public SortedMap headMap(K toKey) { synchronized (mutex) { return new SynchronizedNavigableMap<>(nm.headMap(toKey, false), mutex); } } - public SortedMap tailMap(K fromKey) { synchronized (mutex) { return new SynchronizedNavigableMap<>(nm.tailMap(fromKey, true),mutex); } } - public NavigableMap subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { synchronized (mutex) { return new SynchronizedNavigableMap<>( @@ -3304,7 +3255,6 @@ public NavigableMap subMap(K fromKey, boolean fromInclusive, K toKey, bool } } - public NavigableMap headMap(K toKey, boolean inclusive) { synchronized (mutex) { return new SynchronizedNavigableMap<>( @@ -3312,7 +3262,6 @@ public NavigableMap headMap(K toKey, boolean inclusive) { } } - public NavigableMap tailMap(K fromKey, boolean inclusive) { synchronized (mutex) { return new SynchronizedNavigableMap<>( @@ -3423,14 +3372,10 @@ private String badElementMsg(Object o) { this.type = Objects.requireNonNull(type, "type"); } - - public int size() { return c.size(); } - + public int size() { return c.size(); } public boolean isEmpty() { return c.isEmpty(); } public boolean contains(@Nullable Object o) { return c.contains(o); } - public @Nullable Object[] toArray() { return c.toArray(); } - public T[] toArray(T[] a) { return c.toArray(a); } public T[] toArray(IntFunction f) { return c.toArray(f); } public String toString() { return c.toString(); } @@ -3447,7 +3392,6 @@ public boolean retainAll(Collection coll) { return c.retainAll(coll); } - public Iterator iterator() { // JDK-6363904 - unwrapped iterator could be typecast to // ListIterator with unsafe set() @@ -3510,7 +3454,6 @@ public boolean addAll(Collection coll) { public boolean removeIf(Predicate filter) { return c.removeIf(filter); } - @Override public Spliterator spliterator() {return c.spliterator();} @Override @@ -4004,14 +3947,9 @@ private String badValueMsg(Object value) { this.valueType = Objects.requireNonNull(valueType); } - - public int size() { return m.size(); } - + public int size() { return m.size(); } public boolean isEmpty() { return m.isEmpty(); } - - public boolean containsKey(@Nullable Object key) { return m.containsKey(key); } - public boolean containsValue(@Nullable Object v) { return m.containsValue(v); } public V get(@Nullable Object key) { return m.get(key); } public V remove(@Nullable Object key) { return m.remove(key); } @@ -4022,7 +3960,6 @@ private String badValueMsg(Object value) { public int hashCode() { return m.hashCode(); } public String toString() { return m.toString(); } - public V put(K key, V value) { typeCheck(key, value); return m.put(key, value); @@ -4051,7 +3988,6 @@ public void putAll(Map t) { private transient Set> entrySet; - public Set> entrySet() { if (entrySet==null) entrySet = new CheckedEntrySet<>(m.entrySet(), valueType); @@ -4069,7 +4005,6 @@ public void replaceAll(BiFunction function) { m.replaceAll(typeCheck(function)); } - @Override public V putIfAbsent(K key, V value) { typeCheck(key, value); @@ -4145,9 +4080,7 @@ static class CheckedEntrySet subMap(K fromKey, K toKey) { return checkedSortedMap(sm.subMap(fromKey, toKey), keyType, valueType); } - public SortedMap headMap(K toKey) { return checkedSortedMap(sm.headMap(toKey), keyType, valueType); } - public SortedMap tailMap(K fromKey) { return checkedSortedMap(sm.tailMap(fromKey), keyType, valueType); } @@ -4529,7 +4459,6 @@ public Entry pollLastEntry() { : new CheckedMap.CheckedEntrySet.CheckedEntry<>(entry, valueType); } - public NavigableMap descendingMap() { return checkedNavigableMap(nm.descendingMap(), keyType, valueType); } @@ -4538,46 +4467,38 @@ public NavigableSet keySet() { return navigableKeySet(); } - public NavigableSet navigableKeySet() { return checkedNavigableSet(nm.navigableKeySet(), keyType); } - public NavigableSet descendingKeySet() { return checkedNavigableSet(nm.descendingKeySet(), keyType); } @Override - public NavigableMap subMap(K fromKey, K toKey) { return checkedNavigableMap(nm.subMap(fromKey, true, toKey, false), keyType, valueType); } @Override - public NavigableMap headMap(K toKey) { return checkedNavigableMap(nm.headMap(toKey, false), keyType, valueType); } @Override - public NavigableMap tailMap(K fromKey) { return checkedNavigableMap(nm.tailMap(fromKey, true), keyType, valueType); } - public NavigableMap subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { return checkedNavigableMap(nm.subMap(fromKey, fromInclusive, toKey, toInclusive), keyType, valueType); } - public NavigableMap headMap(K toKey, boolean inclusive) { return checkedNavigableMap(nm.headMap(toKey, inclusive), keyType, valueType); } - public NavigableMap tailMap(K fromKey, boolean inclusive) { return checkedNavigableMap(nm.tailMap(fromKey, inclusive), keyType, valueType); } @@ -4741,22 +4662,17 @@ private static class EmptySet @java.io.Serial private static final long serialVersionUID = 1582296315990362920L; - public Iterator iterator() { return emptyIterator(); } - - public int size() {return 0;} - + public int size() {return 0;} public boolean isEmpty() {return true;} public void clear() {} public boolean contains(@Nullable Object obj) {return false;} public boolean containsAll(Collection c) { return c.isEmpty(); } - public @Nullable Object[] toArray() { return new Object[0]; } - public T[] toArray(T[] a) { if (a.length > 0) a[0] = null; @@ -4773,7 +4689,6 @@ public boolean removeIf(Predicate filter) { Objects.requireNonNull(filter); return false; } - @Override public Spliterator spliterator() { return Spliterators.emptySpliterator(); } @@ -4873,7 +4788,6 @@ private static class EmptyList @java.io.Serial private static final long serialVersionUID = 8842843931221139166L; - public Iterator iterator() { return emptyIterator(); } @@ -4881,19 +4795,15 @@ public ListIterator listIterator() { return emptyListIterator(); } - - public int size() {return 0;} - + public int size() {return 0;} public boolean isEmpty() {return true;} public void clear() {} public boolean contains(@Nullable Object obj) {return false;} public boolean containsAll(Collection c) { return c.isEmpty(); } - public @Nullable Object[] toArray() { return new Object[0]; } - public T[] toArray(T[] a) { if (a.length > 0) a[0] = null; @@ -4929,7 +4839,6 @@ public void forEach(Consumer action) { Objects.requireNonNull(action); } - @Override public Spliterator spliterator() { return Spliterators.emptySpliterator(); } @@ -5024,20 +4933,14 @@ private static class EmptyMap keySet() {return emptySet();} public Collection values() {return emptySet();} - public Set> entrySet() {return emptySet();} public boolean equals(Object o) { @@ -5062,7 +4965,6 @@ public void replaceAll(BiFunction function) { Objects.requireNonNull(function); } - @Override public V putIfAbsent(K key, V value) { throw new UnsupportedOperationException(); @@ -5216,13 +5118,11 @@ private static class SingletonSet SingletonSet(E e) {element = e;} - public Iterator iterator() { return singletonIterator(element); } - - public int size() {return 1;} + public int size() {return 1;} public boolean contains(@Nullable Object o) {return eq(o, element);} @@ -5231,7 +5131,6 @@ public Iterator iterator() { public void forEach(Consumer action) { action.accept(element); } - @Override public Spliterator spliterator() { return singletonSpliterator(element); @@ -5262,7 +5161,7 @@ public int hashCode() { /** * @serial include */ - private static class SingletonList + private static class SingletonList extends AbstractList implements RandomAccess, Serializable { @@ -5272,17 +5171,13 @@ private static class SingletonList @SuppressWarnings("serial") // Conditionally serializable private final E element; - @SuppressWarnings({"inconsistent.constructor.type", "super.invocation.invalid"}) - SingletonList(E obj) {element = obj;} - public Iterator iterator() { return singletonIterator(element); } - - public int size() {return 1;} + public int size() {return 1;} public boolean contains(@Nullable Object obj) {return eq(obj, element);} @@ -5308,7 +5203,6 @@ public void replaceAll(UnaryOperator operator) { @Override public void sort(Comparator c) { } - @Override public Spliterator spliterator() { return singletonSpliterator(element); @@ -5354,14 +5248,9 @@ private static class SingletonMap keySet() { return keySet; } - public Set> entrySet() { if (entrySet==null) entrySet = Collections.singleton( @@ -5405,7 +5293,6 @@ public void replaceAll(BiFunction function) { throw new UnsupportedOperationException(); } - @Override public V putIfAbsent(K key, V value) { throw new UnsupportedOperationException(); @@ -5501,8 +5388,7 @@ private static class CopiesList element = e; } - - public int size() { + public int size() { return n; } @@ -5540,7 +5426,6 @@ public Object[] toArray() { return a; } - @SuppressWarnings("unchecked") public T[] toArray(T[] a) { final int n = this.n; @@ -5625,7 +5510,6 @@ public Stream parallelStream() { return IntStream.range(0, n).parallel().mapToObj(i -> element); } - @Override public Spliterator spliterator() { return stream().spliterator(); @@ -5854,7 +5738,7 @@ static boolean eq(Object o1, Object o2) { * @throws NullPointerException if {@code c} is null * @since 1.5 */ - public static int frequency(Collection c, @Nullable Object o) { + public static int frequency(Collection c, @Nullable Object o) { int result = 0; if (o == null) { for (Object e : c) @@ -5985,7 +5869,7 @@ public static boolean disjoint(Collection c1, Collection c2) { * @since 1.5 */ @SafeVarargs - public static boolean addAll( Collection c, T... elements) { + public static boolean addAll(Collection c, T... elements) { boolean result = false; for (T element : elements) result |= c.add(element); @@ -6045,18 +5929,13 @@ private static class SetFromMap extends AbstractSet< } public void clear() { m.clear(); } - - public int size() { return m.size(); } - + public int size() { return m.size(); } public boolean isEmpty() { return m.isEmpty(); } public boolean contains(@Nullable Object o) { return m.containsKey(o); } public boolean remove(@Nullable Object o) { return m.remove(o) != null; } public boolean add(E e) { return m.put(e, Boolean.TRUE) == null; } - public Iterator iterator() { return s.iterator(); } - public @Nullable Object[] toArray() { return s.toArray(); } - public T[] toArray(T[] a) { return s.toArray(a); } public String toString() { return s.toString(); } public int hashCode() { return s.hashCode(); } @@ -6076,7 +5955,6 @@ public boolean removeIf(Predicate filter) { return s.removeIf(filter); } - @Override public Spliterator spliterator() {return s.spliterator();} @Override @@ -6225,17 +6103,12 @@ static class AsLIFOQueue extends AbstractQueue public E peek() { return q.peekFirst(); } public E element() { return q.getFirst(); } public void clear() { q.clear(); } - - public int size() { return q.size(); } - + public int size() { return q.size(); } public boolean isEmpty() { return q.isEmpty(); } public boolean contains(@Nullable Object o) { return q.contains(o); } public boolean remove(@Nullable Object o) { return q.remove(o); } - public Iterator iterator() { return q.iterator(); } - public @Nullable Object[] toArray() { return q.toArray(); } - public T[] toArray(T[] a) { return q.toArray(a); } public T[] toArray(IntFunction f) { return q.toArray(f); } public String toString() { return q.toString(); } @@ -6251,7 +6124,6 @@ static class AsLIFOQueue extends AbstractQueue public boolean removeIf(Predicate filter) { return q.removeIf(filter); } - @Override public Spliterator spliterator() {return q.spliterator();} @Override diff --git a/src/java.base/share/classes/java/util/Objects.java b/src/java.base/share/classes/java/util/Objects.java index 472531663c9..760de2a0fbb 100644 --- a/src/java.base/share/classes/java/util/Objects.java +++ b/src/java.base/share/classes/java/util/Objects.java @@ -43,7 +43,7 @@ * @since 1.7 */ @NullMarked -public final class Objects { +public final class Objects { private Objects() { throw new AssertionError("No java.util.Objects instances for you!"); } @@ -62,13 +62,20 @@ private Objects() { * @param b an object to be compared with {@code a} for equality * @see Object#equals(Object) */ - - public static boolean equals( @Nullable Object a, @Nullable Object b) { + public static boolean equals(@Nullable Object a, @Nullable Object b) { return (a == b) || (a != null && a.equals(b)); } - // Define and annotate an overload that is unique to j2cl: b/201433789 - public static boolean equals( @Nullable String a, @Nullable String b) { + /** + * Define and annotate an overload that is unique to j2cl: b/201433789. + * + * @param a an object + * @param b an object to be compared with {@code a} for equality + * @return {@code true} if the arguments are equal to each other and + * {@code false} otherwise + * @see Object#equals(Object) + */ + public static boolean equals(@Nullable String a, @Nullable String b) { return equals((Object) a, b); } @@ -87,8 +94,7 @@ public static boolean equals( @Nullable String a, @Nullable String b) { * @see Arrays#deepEquals(Object[], Object[]) * @see Objects#equals(Object, Object) */ - - public static boolean deepEquals( @Nullable Object a, @Nullable Object b) { + public static boolean deepEquals(@Nullable Object a, @Nullable Object b) { if (a == b) return true; else if (a == null || b == null) @@ -104,8 +110,7 @@ else if (a == null || b == null) * @param o an object * @see Object#hashCode */ - - public static int hashCode( @Nullable Object o) { + public static int hashCode(@Nullable Object o) { return o != null ? o.hashCode() : 0; } @@ -134,8 +139,7 @@ public static int hashCode( @Nullable Object o) { * @see Arrays#hashCode(Object[]) * @see List#hashCode */ - - public static int hash( @Nullable Object... values) { + public static int hash(@Nullable Object... values) { return Arrays.hashCode(values); } @@ -148,8 +152,7 @@ public static int hash( @Nullable Object... values) { * @see Object#toString * @see String#valueOf(Object) */ - - public static String toString( @Nullable Object o) { + public static String toString(@Nullable Object o) { return String.valueOf(o); } @@ -163,8 +166,7 @@ public static String toString( @Nullable Object o) { * {@code null} * @see Objects#toString(Object) */ - - public static @Nullable String toString( @Nullable Object o, @Nullable String nullDefault) { + public static @Nullable String toString(@Nullable Object o, @Nullable String nullDefault) { return (o != null) ? o.toString() : nullDefault; } @@ -210,8 +212,7 @@ public static String toIdentityString(Object o) { * @see Comparable * @see Comparator */ - - public static int compare( @Nullable T a, @Nullable T b, Comparator c) { + public static int compare(@Nullable T a, @Nullable T b, Comparator c) { return (a == b) ? 0 : c.compare(a, b); } @@ -275,9 +276,7 @@ public static T requireNonNull(@Nullable T obj, @Nullable String message) { * @see java.util.function.Predicate * @since 1.8 */ - - - public static boolean isNull( @Nullable Object obj) { + public static boolean isNull(@Nullable Object obj) { return obj == null; } @@ -293,9 +292,7 @@ public static boolean isNull( @Nullable Object obj) { * @see java.util.function.Predicate * @since 1.8 */ - - - public static boolean nonNull( @Nullable Object obj) { + public static boolean nonNull(@Nullable Object obj) { return obj != null; } @@ -311,7 +308,7 @@ public static boolean nonNull( @Nullable Object obj) { * {@code defaultObj} is {@code null} * @since 9 */ - public static T requireNonNullElse(@Nullable T obj, @Nullable T defaultObj) { + public static T requireNonNullElse(@Nullable T obj, @Nullable T defaultObj) { return (obj != null) ? obj : requireNonNull(defaultObj, "defaultObj"); } @@ -354,9 +351,7 @@ public static T requireNonNullElseGet(@Nullable T obj, Supplier T requireNonNull( @Nullable T obj, Supplier messageSupplier) { + public static T requireNonNull(@Nullable T obj, Supplier messageSupplier) { if (obj == null) throw new NullPointerException(messageSupplier == null ? null : messageSupplier.get());