Skip to content

Commit

Permalink
Use Java 11 language features where possible (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Dec 1, 2022
1 parent 13db53e commit 2a3bf4b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -283,7 +282,7 @@ public void setContainerConfigXML(File containerConfigXML) {
protected String[] getExcludes() {
List<String> excludeList = new ArrayList<>();
if (StringUtils.isNotEmpty(warSourceExcludes)) {
excludeList.addAll(Arrays.asList(StringUtils.split(warSourceExcludes, ",")));
excludeList.addAll(List.of(StringUtils.split(warSourceExcludes, ",")));
}

// if contextXML is specified, omit the one in the source directory
Expand Down Expand Up @@ -355,7 +354,7 @@ public void buildExplodedWebapp(File webappDirectory, File jarFile)
}

try {
List<Resource> webResources = this.webResources != null ? Arrays.asList(this.webResources) : null;
List<Resource> webResources = this.webResources != null ? List.of(this.webResources) : null;
if (webResources != null && webResources.size() > 0) {
Properties filterProperties = getBuildFilterProperties();
for (Resource resource : webResources) {
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/org/jenkinsci/maven/plugins/hpi/Artifacts.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.apache.maven.project.MavenProject;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.function.Predicate;
Expand Down Expand Up @@ -46,42 +45,42 @@ public Artifacts removeAll(Predicate<Artifact> filter) {
}

public Artifacts scopeIs(String... scopes) {
final List<String> s = Arrays.asList(scopes);
final List<String> s = List.of(scopes);
return retainAll(a -> s.contains(a.getScope()));
}

public Artifacts scopeIsNot(String... scopes) {
final List<String> s = Arrays.asList(scopes);
final List<String> s = List.of(scopes);
return removeAll(a -> s.contains(a.getScope()));
}

public Artifacts typeIs(String... type) {
final List<String> s = Arrays.asList(type);
final List<String> s = List.of(type);
return retainAll(a -> s.contains(a.getType()));
}

public Artifacts typeIsNot(String... type) {
final List<String> s = Arrays.asList(type);
final List<String> s = List.of(type);
return removeAll(a -> s.contains(a.getType()));
}

public Artifacts groupIdIs(String... groupId) {
final List<String> s = Arrays.asList(groupId);
final List<String> s = List.of(groupId);
return retainAll(a -> s.contains(a.getType()));
}

public Artifacts groupIdIsNot(String... groupId) {
final List<String> s = Arrays.asList(groupId);
final List<String> s = List.of(groupId);
return removeAll(a -> s.contains(a.getType()));
}

public Artifacts artifactIdIs(String... artifactId) {
final List<String> s = Arrays.asList(artifactId);
final List<String> s = List.of(artifactId);
return retainAll(a -> s.contains(a.getType()));
}

public Artifacts artifactIdIsNot(String... artifactId) {
final List<String> s = Arrays.asList(artifactId);
final List<String> s = List.of(artifactId);
return removeAll(a -> s.contains(a.getType()));
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package org.jenkinsci.maven.plugins.hpi;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
* @author Kohsuke Kawaguchi
*/
class ReservedName {
static Set<String> NAMES = new HashSet<>(Arrays.asList(
static Set<String> NAMES = Set.of(
"abstract",
"assert",
"boolean",
Expand Down Expand Up @@ -64,5 +63,5 @@ class ReservedName {
"true",
"false",
"null"
));
);
}

0 comments on commit 2a3bf4b

Please sign in to comment.