Skip to content

Commit 0468455

Browse files
committed
Reduce 'new Class[]' cases
Varargs, use {} for creating arrays and etc.
1 parent 1e3db4a commit 0468455

File tree

13 files changed

+38
-39
lines changed

13 files changed

+38
-39
lines changed

bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/UpdateStrategy.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2007, 2018 IBM Corporation and others.
2+
* Copyright (c) 2007, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -422,12 +422,11 @@ private synchronized static Map<Pair, Object> getConverterMap() {
422422
return converterMap;
423423
}
424424

425-
private static final Class<?>[] integerClasses = new Class[] { byte.class,
426-
Byte.class, short.class, Short.class, int.class, Integer.class,
427-
long.class, Long.class, BigInteger.class };
425+
private static final Class<?>[] integerClasses = { byte.class, Byte.class, short.class, Short.class, int.class,
426+
Integer.class, long.class, Long.class, BigInteger.class };
428427

429-
private static final Class<?>[] floatClasses = new Class[] { float.class,
430-
Float.class, double.class, Double.class, BigDecimal.class };
428+
private static final Class<?>[] floatClasses = { float.class, Float.class, double.class, Double.class,
429+
BigDecimal.class };
431430

432431
/**
433432
* Registers converters to boxed and unboxed types from a list of from

bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/ClassLookupSupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2006, 2015 IBM Corporation and others.
2+
* Copyright (c) 2006, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -53,7 +53,7 @@ public static Class<?>[] getTypeHierarchyFlattened(Class<?> type) {
5353
classSearchOrderLookup = lookup = new HashMap<>();
5454
lookup.put(type, classes);
5555
}
56-
return classes.toArray(new Class[classes.size()]);
56+
return classes.toArray(Class[]::new);
5757
}
5858

5959
/**

bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/IdentityConverter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2005, 2015 db4objects Inc. http://www.db4o.com and others.
2+
* Copyright (C) 2005, 2025 db4objects Inc. http://www.db4o.com and others.
33
*
44
*
55
* This program and the accompanying materials
@@ -37,7 +37,7 @@ public IdentityConverter(Class<?> fromType, Class<?> toType) {
3737
this.toType = toType;
3838
}
3939

40-
private Class<?>[][] primitiveMap = new Class[][] {
40+
private Class<?>[][] primitiveMap = {
4141
{ Integer.TYPE, Integer.class }, { Short.TYPE, Short.class },
4242
{ Long.TYPE, Long.class }, { Double.TYPE, Double.class },
4343
{ Byte.TYPE, Byte.class }, { Float.TYPE, Float.class },

bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/validation/ObjectToPrimitiveValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2006, 2014 IBM Corporation and others.
2+
* Copyright (c) 2006, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -28,7 +28,7 @@ public class ObjectToPrimitiveValidator implements IValidator<Object> {
2828

2929
private Class<?> toType;
3030

31-
private Class<?>[][] primitiveMap = new Class[][] {
31+
private Class<?>[][] primitiveMap = {
3232
{ Integer.TYPE, Integer.class }, { Short.TYPE, Short.class },
3333
{ Long.TYPE, Long.class }, { Double.TYPE, Double.class },
3434
{ Byte.TYPE, Byte.class }, { Float.TYPE, Float.class },

bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/SelectionAdapterFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2010, 2015 IBM Corporation and others.
2+
* Copyright (c) 2010, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -40,7 +40,7 @@ public class SelectionAdapterFactory implements IAdapterFactory {
4040
/**
4141
* The classes we can adapt to.
4242
*/
43-
private static final Class<?>[] CLASSES = new Class[] { IIterable.class, ICountable.class };
43+
private static final Class<?>[] CLASSES = { IIterable.class, ICountable.class };
4444

4545
@Override
4646
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {

bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2015 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -43,7 +43,7 @@ public IPath getPath(Object element) {
4343
}
4444

4545
/** The list of provided adapters. */
46-
private static final Class<?>[] ADAPTER_LIST= new Class[] { ILocationProvider.class };
46+
private static final Class<?>[] ADAPTER_LIST = { ILocationProvider.class };
4747

4848
/** The provided location provider */
4949
private ILocationProvider fLocationProvider= new LocationProvider();

bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IURIEditorInputAdapterFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2007, 2015 IBM Corporation and others.
2+
* Copyright (c) 2007, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -57,7 +57,7 @@ public URI getURI(Object element) {
5757

5858

5959
/** The list of provided adapters. */
60-
private static final Class<?>[] ADAPTER_LIST= new Class[] { ILocationProvider.class };
60+
private static final Class<?>[] ADAPTER_LIST = { ILocationProvider.class };
6161

6262
/** The provided location provider */
6363
private ILocationProvider fLocationProvider= new LocationProvider();

examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/ReflectedMethod.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2005, 2015 db4objects Inc. http://www.db4o.com
2+
* Copyright (C) 2005, 2025 db4objects Inc. http://www.db4o.com
33
*
44
*
55
* This program and the accompanying materials
@@ -35,7 +35,7 @@ public class ReflectedMethod {
3535
* @param methodName The name of the method.
3636
* @param paramTypes The method's parameter types.
3737
*/
38-
public ReflectedMethod(Object subject, String methodName, Class<?>[] paramTypes) {
38+
public ReflectedMethod(Object subject, String methodName, Class<?>... paramTypes) {
3939
this.subject = subject;
4040
method = null;
4141
try {
@@ -62,7 +62,7 @@ public boolean exists() {
6262
* @return any return value or null if there was no return value or an error
6363
* occured.
6464
*/
65-
public Object invoke(Object[] params) {
65+
public Object invoke(Object... params) {
6666
if (method == null)
6767
return null;
6868
try {

examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/ReflectedProperty.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2006, 2015 The Pampered Chef and others.
2+
* Copyright (c) 2006, 2025 The Pampered Chef and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -32,14 +32,14 @@ public class ReflectedProperty {
3232
*/
3333
public ReflectedProperty(Object object, String propertyName) {
3434
this.propertyName = propertyName;
35-
getter = new ReflectedMethod(object, makeGetterName(propertyName), new Class[] {});
35+
getter = new ReflectedMethod(object, makeGetterName(propertyName));
3636
if (!getter.exists()) {
37-
getter = new ReflectedMethod(object, makeBooleanGetterName(propertyName), new Class[] {});
37+
getter = new ReflectedMethod(object, makeBooleanGetterName(propertyName));
3838
if (!getter.exists()) {
3939
throw new IllegalArgumentException("Cannot find getter for " + propertyName);
4040
}
4141
}
42-
setter = new ReflectedMethod(object, makeSetterName(propertyName), new Class[] { getter.getType() });
42+
setter = new ReflectedMethod(object, makeSetterName(propertyName), getter.getType());
4343
}
4444

4545
private String makeBooleanGetterName(String propertyName) {

examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/ducks/RelaxedDuckType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2005, 2015 db4objects Inc. http://www.db4o.com
2+
* Copyright (C) 2005, 2025 db4objects Inc. http://www.db4o.com
33
*
44
*
55
* This program and the accompanying materials
@@ -38,7 +38,7 @@ public static Object implement(Class<?> interfaceToImplement, Object object) {
3838
new RelaxedDuckType(object));
3939
}
4040

41-
public static boolean includes(Object object, String method, Class<?>[] args) {
41+
public static boolean includes(Object object, String method, Class<?>... args) {
4242
try {
4343
object.getClass().getMethod(method, args);
4444
} catch (NoSuchMethodException e) {

0 commit comments

Comments
 (0)