Skip to content

Commit

Permalink
refactor: Use diamond operator (#10146)
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek and TeamModerne authored Nov 22, 2023
1 parent 3d4aad9 commit 622cb96
Show file tree
Hide file tree
Showing 26 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private static <T1> T1 doIntercept(
);

if (ArrayUtils.isNotEmpty(resolvedInterceptors)) {
final MethodInterceptorChain<T1, T1> chain = new MethodInterceptorChain<T1, T1>(
final MethodInterceptorChain<T1, T1> chain = new MethodInterceptorChain<>(
resolvedInterceptors,
bean,
interceptedMethod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void memoizedNonEmpty(Blackhole blackhole) {
}

private static <T> Supplier<T> memoizedUsingLambda(Supplier<T> actual) {
return new Supplier<T>() {
return new Supplier<>() {
Supplier<T> delegate = this::initialize;
boolean initialized;

Expand All @@ -63,7 +63,7 @@ private synchronized T initialize() {
}

private static <T> Supplier<T> memoizedNonEmptyUsingLambda(Supplier<T> actual) {
return new Supplier<T>() {
return new Supplier<>() {
Supplier<T> delegate = this::initialize;
boolean initialized;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public AnnotationMetadata getAnnotationMetadata() {

@Override
public MutableAnnotationMetadataDelegate<AnnotationMetadata> getMethodAnnotationMetadata() {
return new MutableAnnotationMetadataDelegate<AnnotationMetadata>() {
return new MutableAnnotationMetadataDelegate<>() {

@Override
public AnnotationMetadata getAnnotationMetadata() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void subscribe(Subscriber<? super T> subscriber) {
* @return propagation aware subscriber
*/
public static <T> Subscriber<T> propagate(PropagatedContext propagatedContext, Subscriber<T> actual) {
return new CoreSubscriber<T>() {
return new CoreSubscriber<>() {

@Override
public Context currentContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ public Set<String> keySet() {
@NonNull
@Override
public Collection<V> values() {
return new AbstractCollection<V>() {
return new AbstractCollection<>() {
@Override
public Iterator<V> iterator() {
return new Iterator<V>() {
return new Iterator<>() {
private int index = 0;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public <T, R> BoundExecutable<T, R> bind(
}
}

return new BoundExecutable<T, R>() {
return new BoundExecutable<>() {
@Override
public Executable<T, R> getTarget() {
return target;
Expand Down Expand Up @@ -157,7 +157,7 @@ public <T, R> BoundExecutable<T, R> tryBind(Executable<T, R> target, ArgumentBin
}
}

return new BoundExecutable<T, R>() {
return new BoundExecutable<>() {

@Override
public List<Argument<?>> getUnboundArguments() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ default Optional<T> convert(S object, Class<T> targetType) {
*/
static <ST, TT> TypeConverter<ST, TT> of(Class<ST> sourceType, Class<TT> targetType, Function<ST, TT> converter) {
// Keep the anonymous class instead of Lambda to reduce the Lambda invocation overhead during the startup
return new TypeConverter<ST, TT>() {
return new TypeConverter<>() {
@Override
public Optional<TT> convert(ST object, Class<TT> targetType1, ConversionContext context) {
return Optional.ofNullable(converter.apply(object));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ default void forEach(BiConsumer<String, List<V>> action) {
@Override
default Iterator<Map.Entry<String, List<V>>> iterator() {
Iterator<String> headerNames = names().iterator();
return new Iterator<Map.Entry<String, List<V>>>() {
return new Iterator<>() {
@Override
public boolean hasNext() {
return headerNames.hasNext();
Expand All @@ -112,7 +112,7 @@ public Map.Entry<String, List<V>> next() {
}

String name = headerNames.next();
return new Map.Entry<String, List<V>>() {
return new Map.Entry<>() {
@Override
public String getKey() {
return name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ default Map<String, V> subMap(String prefix, ArgumentConversionContext<V> valueT
@Override
default Iterator<Map.Entry<String, V>> iterator() {
Iterator<String> names = names().iterator();
return new Iterator<Map.Entry<String, V>>() {
return new Iterator<>() {
@Override
public boolean hasNext() {
return names.hasNext();
Expand All @@ -229,7 +229,7 @@ public Map.Entry<String, V> next() {
}

String name = names.next();
return new Map.Entry<String, V>() {
return new Map.Entry<>() {
@Override
public String getKey() {
return name;
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/io/micronaut/core/type/ReturnType.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static <T1> ReturnType<T1> of(Class<T1> type, Argument<?>... typeArguments) {
for (Argument<?> argument : typeArguments) {
argumentMap.put(argument.getName(), argument);
}
return new ReturnType<T1>() {
return new ReturnType<>() {
@Override
public Class<T1> getType() {
return type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ protected synchronized Optional<T> convertFromNext(ConversionService conversionS
} else {
conversion = conversionService.convert(value, conversionContext);
}
nextConvertor = new BodyConvertor<T>() {
nextConvertor = new BodyConvertor<>() {

@Override
public Optional<T> convert(ArgumentConversionContext<T> currentConversionContext, T value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ private abstract static class BodyConvertor<T> {
protected synchronized Optional<T> convertFromNext(ConversionService conversionService, ArgumentConversionContext<T> conversionContext, T value) {
if (nextConvertor == null) {
Optional<T> conversion = conversionService.convert(value, conversionContext);
nextConvertor = new BodyConvertor<T>() {
nextConvertor = new BodyConvertor<>() {

@Override
public Optional<T> convert(ArgumentConversionContext<T> currentConversionContext, T value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public BindingResult<T> bindFullBody(ArgumentConversionContext<T> context, HttpR
ExecutionFlow<ImmediateByteBody> buffered = nhr.byteBody()
.buffer(nhr.getChannelHandlerContext().alloc());

return new PendingRequestBindingResult<T>() {
return new PendingRequestBindingResult<>() {
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
Optional<T> result;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected HttpConverterRegistrar(BeanProvider<ResourceResolver> resourceResolver
*/
@Deprecated(forRemoval = true)
protected HttpConverterRegistrar(Provider<ResourceResolver> resourceResolver) {
this.resourceResolver = new BeanProvider<ResourceResolver>() {
this.resourceResolver = new BeanProvider<>() {
@Override
public ResourceResolver get() {
return resourceResolver.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class MyIterable implements Iterable<String> {

@Override
public Iterator<String> iterator() {
return new Iterator<String>() {
return new Iterator<>() {

@Override
public boolean hasNext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void setSeat(Seat unused) {
* value to avoid null checks for omitted provider injections.
*/
private static <T> jakarta.inject.Provider<T> nullProvider() {
return new org.atinject.jakartatck.auto.Convertible.NullProvider<T>();
return new org.atinject.jakartatck.auto.Convertible.NullProvider<>();
}

static class NullProvider<T> implements jakarta.inject.Provider<T> {
Expand All @@ -181,7 +181,7 @@ public T get() {
}

public static ThreadLocal<Convertible> localConvertible
= new ThreadLocal<Convertible>();
= new ThreadLocal<>();

public static class Tests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Tire extends RoundThing {

protected static final FuelTank NEVER_INJECTED = new FuelTank();

protected static final Set<String> moreProblems = new LinkedHashSet<String>();
protected static final Set<String> moreProblems = new LinkedHashSet<>();

FuelTank constructorInjection = NEVER_INJECTED;
@Inject FuelTank fieldInjection = NEVER_INJECTED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public class DefaultBeanContext implements InitializableBeanContext {
private static final String PARALLEL_TYPE = Parallel.class.getName();
private static final String INDEXES_TYPE = Indexes.class.getName();
private static final String REPLACES_ANN = Replaces.class.getName();
private static final Comparator<BeanRegistration<?>> BEAN_REGISTRATION_COMPARATOR = new Comparator<BeanRegistration<?>>() {
private static final Comparator<BeanRegistration<?>> BEAN_REGISTRATION_COMPARATOR = new Comparator<>() {
// Keep anonymous class to avoid lambda overhead during the startup
@Override
public int compare(BeanRegistration<?> o1, BeanRegistration<?> o2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Object get(String key) {

@Override
public Iterator<String> iterator() {
return new Iterator<String>() {
return new Iterator<>() {
@Override
public boolean hasNext() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Object get(String key) {
public Iterator<String> iterator() {
Iterator i = map.keySet().iterator();

return new Iterator<String>() {
return new Iterator<>() {
@Override
public boolean hasNext() {
return i.hasNext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public int hashCode() {
}

private ApplicationEventPublisher<Object> createObjectEventPublisher(BeanContext beanContext) {
return new ApplicationEventPublisher<Object>() {
return new ApplicationEventPublisher<>() {
@Override
public void publishEvent(Object event) {
getTypedEventPublisher(Argument.of(event.getClass()), beanContext).publishEvent(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ default Optional<Class<?>> getDeclaringType() {
* @return The constructor injection point
*/
default ConstructorInjectionPoint<T> getConstructor() {
return new ConstructorInjectionPoint<T>() {
return new ConstructorInjectionPoint<>() {

@Override
public Argument<?>[] getArguments() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ public AnnotationValue<A> annotationValue() {
if (annotationValue != null) {
return this.annotationValue;
} else {
return new AnnotationValue<A>(annotationClass.getName());
return new AnnotationValue<>(annotationClass.getName());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public BindingResult<Object> bind(ArgumentConversionContext<Object> context, Map
return () -> Optional.of(result);
} catch (Exception e) {
context.reject(e);
return new BindingResult<Object>() {
return new BindingResult<>() {
@Override
public List<ConversionError> getConversionErrors() {
return CollectionUtils.iterableToList(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void setSeat(Seat unused) {
* value to avoid null checks for omitted provider injections.
*/
private static <T> Provider<T> nullProvider() {
return new NullProvider<T>();
return new NullProvider<>();
}

static class NullProvider<T> implements Provider<T> {
Expand All @@ -180,7 +180,7 @@ public T get() {
}
}

public static ThreadLocal<Convertible> localConvertible = new ThreadLocal<Convertible>();
public static ThreadLocal<Convertible> localConvertible = new ThreadLocal<>();


@TestInstance(TestInstance.Lifecycle.PER_CLASS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Tire extends RoundThing {

protected static final FuelTank NEVER_INJECTED = new FuelTank();

protected static final Set<String> moreProblems = new LinkedHashSet<String>();
protected static final Set<String> moreProblems = new LinkedHashSet<>();

FuelTank constructorInjection = NEVER_INJECTED;
@Inject FuelTank fieldInjection = NEVER_INJECTED;
Expand Down

0 comments on commit 622cb96

Please sign in to comment.