Skip to content

Commit

Permalink
Optimize using List#of and List#copyOf
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasblaesing committed Dec 3, 2024
1 parent a5447c0 commit 24e6f9b
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract class AbstractObjectProvider<T extends AbstractObjectProvider.Refreshab
AbstractObjectProvider(List<String> annotation , AnnotationModelHelper helper)
{
myHelper = helper;
myAnnotationName = Collections.unmodifiableList(new ArrayList<>(annotation));
myAnnotationName = List.copyOf(annotation);
}

/* (non-Javadoc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class AnnotationObjectProvider implements ObjectProvider<BindingQualifier

AnnotationObjectProvider( AnnotationModelHelper helper , List<String> annotation) {
myHelper = helper;
myAnnotationNames = Collections.unmodifiableList(new ArrayList<>(annotation));
myAnnotationNames = List.copyOf(annotation);
}

/* (non-Javadoc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.netbeans.modules.web.beans.impl.model;

import java.util.Arrays;
import java.util.List;
import javax.lang.model.element.TypeElement;

import org.netbeans.modules.j2ee.metadata.model.api.support.annotation.AnnotationModelHelper;
Expand All @@ -32,7 +32,7 @@
class DecoratorObjectProvider extends AbstractObjectProvider<DecoratorObject> {

DecoratorObjectProvider( AnnotationModelHelper helper ) {
super( Arrays.asList(AnnotationUtil.DECORATOR_JAKARTA, AnnotationUtil.DECORATOR), helper);
super(List.of(AnnotationUtil.DECORATOR_JAKARTA, AnnotationUtil.DECORATOR), helper);
}

/* (non-Javadoc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
*/
class InterceptorBindingChecker extends RuntimeAnnotationChecker {

private static final List<String> ANNOTATIONS = Collections.unmodifiableList(List.of(
private static final List<String> ANNOTATIONS = List.of(
INTERCEPTOR_BINDING_FQN, INTERCEPTOR_BINDING_FQN_JAKARTA
));
);

InterceptorBindingChecker(AnnotationModelHelper helper){
init( null, helper );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.netbeans.modules.web.beans.impl.model;

import java.util.Arrays;
import java.util.List;
import javax.lang.model.element.TypeElement;

import org.netbeans.modules.j2ee.metadata.model.api.support.annotation.AnnotationModelHelper;
Expand All @@ -33,7 +33,7 @@ class InterceptorObjectProvider extends AbstractObjectProvider<InterceptorObject

InterceptorObjectProvider( AnnotationModelHelper helper )
{
super(Arrays.asList(AnnotationUtil.INTERCEPTOR, AnnotationUtil.INTERCEPTOR_JAKARTA), helper);
super(List.of(AnnotationUtil.INTERCEPTOR, AnnotationUtil.INTERCEPTOR_JAKARTA), helper);
}

/* (non-Javadoc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.netbeans.modules.web.beans.impl.model;

import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.LinkedList;
Expand All @@ -43,7 +42,7 @@
class NamedStereotypeObjectProvider extends AbstractObjectProvider<NamedStereotype> {

NamedStereotypeObjectProvider(AnnotationModelHelper helper) {
super(Arrays.asList(STEREOTYPE_FQN, STEREOTYPE_FQN_JAKARTA), helper);
super(List.of(STEREOTYPE_FQN, STEREOTYPE_FQN_JAKARTA), helper);
}

/* (non-Javadoc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.netbeans.modules.web.beans.impl.model;

import java.util.Collections;
import java.util.List;

import static org.netbeans.modules.web.beans.analysis.analyzer.AnnotationUtil.NORMAL_SCOPE_FQN;
Expand All @@ -31,9 +30,9 @@
*/
class NormalScopeChecker extends ScopeChecker {

private static final List<String> ANNOTATIONS = Collections.unmodifiableList(List.of(
private static final List<String> ANNOTATIONS = List.of(
NORMAL_SCOPE_FQN, NORMAL_SCOPE_FQN_JAKARTA
));
);

static NormalScopeChecker get(){
return new NormalScopeChecker();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.netbeans.modules.web.beans.impl.model;

import java.lang.annotation.ElementType;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand All @@ -41,9 +40,9 @@
*/
class QualifierChecker extends RuntimeAnnotationChecker implements Checker {

private static final List<String> ANNOTATIONS = Collections.unmodifiableList(List.of(
private static final List<String> ANNOTATIONS = List.of(
QUALIFIER_FQN, QUALIFIER_FQN_JAKARTA
));
);

QualifierChecker(){
this( false );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.netbeans.modules.web.beans.impl.model;

import java.lang.annotation.ElementType;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
Expand All @@ -40,9 +39,9 @@
*/
class ScopeChecker extends RuntimeAnnotationChecker {

private static final List<String> ANNOTATIONS = Collections.unmodifiableList(List.of(
private static final List<String> ANNOTATIONS = List.of(
SCOPE_FQN, SCOPE_FQN_JAKARTA
));
);

static ScopeChecker get(){
return new ScopeChecker();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.netbeans.modules.web.beans.impl.model;

import java.lang.annotation.ElementType;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
Expand All @@ -42,9 +41,9 @@
*/
public class StereotypeChecker extends RuntimeAnnotationChecker {

private static final List<String> ANNOTATIONS = Collections.unmodifiableList(List.of(
private static final List<String> ANNOTATIONS = List.of(
STEREOTYPE_FQN, STEREOTYPE_FQN_JAKARTA
));
);

public StereotypeChecker(AnnotationHelper helper ){
init(null, helper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.netbeans.modules.web.beans.impl.model;

import java.util.Arrays;
import java.util.List;
import javax.lang.model.element.TypeElement;

import org.netbeans.modules.j2ee.metadata.model.api.support.annotation.AnnotationModelHelper;
Expand All @@ -36,7 +36,7 @@ class StereotypedObjectProvider extends AbstractObjectProvider<StereotypedObject
StereotypedObjectProvider( String stereotypeAnnotation ,
AnnotationModelHelper helper )
{
super(Arrays.asList(stereotypeAnnotation), helper);
super(List.of(stereotypeAnnotation), helper);
}

/* (non-Javadoc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
import org.netbeans.modules.web.beans.api.model.ModelUnit;
import org.netbeans.modules.web.beans.api.model.WebBeansModel;

import static java.util.Arrays.asList;


/**
* @author ads
*
Expand Down Expand Up @@ -124,7 +121,7 @@ protected WebBeansModel getModel() {

PersistentObjectManager<BindingQualifier> getManager( String... annotationFQN ){
PersistentObjectManager<BindingQualifier> result = myManagers.computeIfAbsent(
asList(annotationFQN),
List.of(annotationFQN),
fqn -> getHelper().createPersistentObjectManager(
new AnnotationObjectProvider(getHelper(), fqn))
);
Expand Down

0 comments on commit 24e6f9b

Please sign in to comment.