Skip to content

Commit

Permalink
Java 7: omit explit type in favor of <>
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoref committed Feb 21, 2019
1 parent 6712bb1 commit 264980c
Show file tree
Hide file tree
Showing 200 changed files with 565 additions and 563 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/AbstractMarkupText.java
Expand Up @@ -141,7 +141,7 @@ public MarkupText.SubText findToken(Pattern pattern) {
public List<MarkupText.SubText> findTokens(Pattern pattern) {
String text = getText();
Matcher m = pattern.matcher(text);
List<SubText> r = new ArrayList<SubText>();
List<SubText> r = new ArrayList<>();

while(m.find()) {
int idx = m.start();
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/BulkChange.java
Expand Up @@ -132,7 +132,7 @@ private void pop() {
/**
* {@link BulkChange}s that are effective currently.
*/
private static final ThreadLocal<BulkChange> INSCOPE = new ThreadLocal<BulkChange>();
private static final ThreadLocal<BulkChange> INSCOPE = new ThreadLocal<>();

/**
* Gets the {@link BulkChange} instance currently in scope for the current thread.
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/hudson/ClassicPluginStrategy.java
Expand Up @@ -192,7 +192,7 @@ private static Manifest loadLinkedManifest(File archive) throws IOException {
// TODO: define a mechanism to hide classes
// String export = manifest.getMainAttributes().getValue("Export");

List<File> paths = new ArrayList<File>();
List<File> paths = new ArrayList<>();
if (isLinked) {
parseClassPath(manifest, archive, paths, "Libraries", ",");
parseClassPath(manifest, archive, paths, "Class-Path", " +"); // backward compatibility
Expand All @@ -218,8 +218,8 @@ private static Manifest loadLinkedManifest(File archive) throws IOException {
}

// compute dependencies
List<PluginWrapper.Dependency> dependencies = new ArrayList<PluginWrapper.Dependency>();
List<PluginWrapper.Dependency> optionalDependencies = new ArrayList<PluginWrapper.Dependency>();
List<PluginWrapper.Dependency> dependencies = new ArrayList<>();
List<PluginWrapper.Dependency> optionalDependencies = new ArrayList<>();
String v = atts.getValue("Plugin-Dependencies");
if (v != null) {
for (String s : v.split(",")) {
Expand Down Expand Up @@ -336,7 +336,7 @@ public <T> List<ExtensionComponent<T>> findComponents(Class<T> type, Hudson huds
} catch (AbstractMethodError e) {
// backward compatibility
for (T t : finder.findExtensions(type, hudson))
r.add(new ExtensionComponent<T>(t));
r.add(new ExtensionComponent<>(t));
}
}

Expand Down Expand Up @@ -578,7 +578,7 @@ private List<PluginWrapper> getTransitiveDependencies() {
CyclicGraphDetector<PluginWrapper> cgd = new CyclicGraphDetector<PluginWrapper>() {
@Override
protected List<PluginWrapper> getEdges(PluginWrapper pw) {
List<PluginWrapper> dep = new ArrayList<PluginWrapper>();
List<PluginWrapper> dep = new ArrayList<>();
for (Dependency d : pw.getDependencies()) {
PluginWrapper p = pluginManager.getPlugin(d.shortName);
if (p!=null && p.isActive())
Expand Down Expand Up @@ -644,7 +644,7 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {
@SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS",
justification = "Should not produce network overheads since the URL is local. JENKINS-53793 is a follow-up")
protected Enumeration<URL> findResources(String name) throws IOException {
HashSet<URL> result = new HashSet<URL>();
HashSet<URL> result = new HashSet<>();

if (PluginManager.FAST_LOOKUP) {
for (PluginWrapper pw : getTransitiveDependencies()) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/DNSMultiCast.java
Expand Up @@ -32,7 +32,7 @@ public Object call() {
try {
jmdns = JmDNS.create();

Map<String,String> props = new HashMap<String, String>();
Map<String,String> props = new HashMap<>();
String rootURL = jenkins.getRootUrl();
if (rootURL==null) return null;

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/DescriptorExtensionList.java
Expand Up @@ -76,7 +76,7 @@ DescriptorExtensionList<T,D> createDescriptorList(Jenkins jenkins, Class<T> desc
if (describableType == (Class) Publisher.class) {
return (DescriptorExtensionList) new Publisher.DescriptorExtensionListImpl(jenkins);
}
return new DescriptorExtensionList<T,D>(jenkins,describableType);
return new DescriptorExtensionList<>(jenkins, describableType);
}

/**
Expand Down Expand Up @@ -199,7 +199,7 @@ protected Collection<ExtensionComponent<D>> load(ExtensionComponentSet delta) {
}

private List<ExtensionComponent<D>> _load(Iterable<ExtensionComponent<Descriptor>> set) {
List<ExtensionComponent<D>> r = new ArrayList<ExtensionComponent<D>>();
List<ExtensionComponent<D>> r = new ArrayList<>();
for( ExtensionComponent<Descriptor> c : set ) {
Descriptor d = c.getInstance();
try {
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/hudson/EnvVars.java
Expand Up @@ -200,7 +200,7 @@ public TraceResolver(Comparator<? super String> comparator) {
}

public void clear() {
referredVariables = new TreeSet<String>(comparator);
referredVariables = new TreeSet<>(comparator);
}

public String resolve(String name) {
Expand Down Expand Up @@ -288,8 +288,8 @@ private void cutCycle(List<String> cycle) {
* Scan all variables and list all referring variables.
*/
public void scan() {
refereeSetMap = new TreeMap<String, Set<String>>(comparator);
List<String> extendingVariableNames = new ArrayList<String>();
refereeSetMap = new TreeMap<>(comparator);
List<String> extendingVariableNames = new ArrayList<>();

TraceResolver resolver = new TraceResolver(comparator);

Expand Down Expand Up @@ -327,10 +327,10 @@ public void scan() {

// When A refers B, the last appearance of B always comes after
// the last appearance of A.
List<String> reversedDuplicatedOrder = new ArrayList<String>(sorter.getSorted());
List<String> reversedDuplicatedOrder = new ArrayList<>(sorter.getSorted());
Collections.reverse(reversedDuplicatedOrder);

orderedVariableNames = new ArrayList<String>(overrides.size());
orderedVariableNames = new ArrayList<>(overrides.size());
for(String key: reversedDuplicatedOrder) {
if(overrides.containsKey(key) && !orderedVariableNames.contains(key)) {
orderedVariableNames.add(key);
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/ExpressionFactory2.java
Expand Up @@ -168,5 +168,5 @@ public Collection values() {
*
* @see Functions#getCurrentJellyContext()
*/
protected static final ThreadLocal<JellyContext> CURRENT_CONTEXT = new ThreadLocal<JellyContext>();
protected static final ThreadLocal<JellyContext> CURRENT_CONTEXT = new ThreadLocal<>();
}
16 changes: 8 additions & 8 deletions core/src/main/java/hudson/ExtensionList.java
Expand Up @@ -86,7 +86,7 @@ public class ExtensionList<T> extends AbstractList<T> implements OnMaster {
@CopyOnWrite
private volatile List<ExtensionComponent<T>> extensions;

private final List<ExtensionListListener> listeners = new CopyOnWriteArrayList<ExtensionListListener>();
private final List<ExtensionListListener> listeners = new CopyOnWriteArrayList<>();

/**
* Place to store manually registered instances with the per-Hudson scope.
Expand All @@ -104,7 +104,7 @@ protected ExtensionList(Hudson hudson, Class<T> extensionType) {
}

protected ExtensionList(Jenkins jenkins, Class<T> extensionType) {
this(jenkins,extensionType,new CopyOnWriteArrayList<ExtensionComponent<T>>());
this(jenkins,extensionType, new CopyOnWriteArrayList<>());
}

/**
Expand Down Expand Up @@ -237,7 +237,7 @@ public boolean removeAll(Collection<?> c) {
private synchronized boolean removeSync(Object o) {
boolean removed = removeComponent(legacyInstances, o);
if(extensions!=null) {
List<ExtensionComponent<T>> r = new ArrayList<ExtensionComponent<T>>(extensions);
List<ExtensionComponent<T>> r = new ArrayList<>(extensions);
removed |= removeComponent(r,o);
extensions = sort(r);
}
Expand Down Expand Up @@ -279,11 +279,11 @@ public boolean add(T t) {
}

private synchronized boolean addSync(T t) {
legacyInstances.add(new ExtensionComponent<T>(t));
legacyInstances.add(new ExtensionComponent<>(t));
// if we've already filled extensions, add it
if(extensions!=null) {
List<ExtensionComponent<T>> r = new ArrayList<ExtensionComponent<T>>(extensions);
r.add(new ExtensionComponent<T>(t));
List<ExtensionComponent<T>> r = new ArrayList<>(extensions);
r.add(new ExtensionComponent<>(t));
extensions = sort(r);
}
return true;
Expand Down Expand Up @@ -395,7 +395,7 @@ protected Collection<ExtensionComponent<T>> load(ExtensionComponentSet delta) {
* The implementation should copy a list, do a sort, and return the new instance.
*/
protected List<ExtensionComponent<T>> sort(List<ExtensionComponent<T>> r) {
r = new ArrayList<ExtensionComponent<T>>(r);
r = new ArrayList<>(r);
Collections.sort(r);
return r;
}
Expand All @@ -412,7 +412,7 @@ public static <T> ExtensionList<T> create(Hudson hudson, Class<T> type) {
@SuppressWarnings({"unchecked", "rawtypes"})
public static <T> ExtensionList<T> create(Jenkins jenkins, Class<T> type) {
if(type.getAnnotation(LegacyInstancesAreScopedToHudson.class)!=null)
return new ExtensionList<T>(jenkins,type);
return new ExtensionList<>(jenkins, type);
else {
return new ExtensionList(jenkins, type, staticLegacyInstances.computeIfAbsent(type, key -> new CopyOnWriteArrayList()));
}
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/java/hudson/FilePath.java
Expand Up @@ -325,7 +325,7 @@ public static String normalize(@Nonnull String path) {
}
boolean isAbsolute = buf.length() > 0;
// Split remaining path into tokens, trimming any duplicate or trailing separators
List<String> tokens = new ArrayList<String>();
List<String> tokens = new ArrayList<>();
int s = 0, end = path.length();
for (int i = 0; i < end; i++) {
char c = path.charAt(i);
Expand Down Expand Up @@ -1061,7 +1061,7 @@ private <T> T act(final FileCallable<T> callable, ClassLoader cl) throws IOExcep
if(channel!=null) {
// run this on a remote system
try {
DelegatingCallable<T,IOException> wrapper = new FileCallableWrapper<T>(callable, cl);
DelegatingCallable<T,IOException> wrapper = new FileCallableWrapper<>(callable, cl);
for (FileCallableWrapperFactory factory : ExtensionList.lookup(FileCallableWrapperFactory.class)) {
wrapper = factory.wrap(wrapper);
}
Expand Down Expand Up @@ -1136,7 +1136,7 @@ protected void after() {}
*/
public <T> Future<T> actAsync(final FileCallable<T> callable) throws IOException, InterruptedException {
try {
DelegatingCallable<T,IOException> wrapper = new FileCallableWrapper<T>(callable);
DelegatingCallable<T,IOException> wrapper = new FileCallableWrapper<>(callable);
for (FileCallableWrapperFactory factory : ExtensionList.lookup(FileCallableWrapperFactory.class)) {
wrapper = factory.wrap(wrapper);
}
Expand Down Expand Up @@ -1839,7 +1839,7 @@ public List<FilePath> invoke(File f, VirtualChannel channel) throws IOException
return Collections.emptyList();
}

ArrayList<FilePath> r = new ArrayList<FilePath>(children.length);
ArrayList<FilePath> r = new ArrayList<>(children.length);
for (File child : children)
r.add(new FilePath(child));

Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/hudson/Functions.java
Expand Up @@ -465,7 +465,7 @@ public static String appendIfNotNull(String text, String suffix, String nullText
}

public static Map getSystemProperties() {
return new TreeMap<Object,Object>(System.getProperties());
return new TreeMap<>(System.getProperties());
}

/**
Expand All @@ -479,7 +479,7 @@ public static String getSystemProperty(String key) {
}

public static Map getEnvVars() {
return new TreeMap<String,String>(EnvVars.masterEnvVars);
return new TreeMap<>(EnvVars.masterEnvVars);
}

public static boolean isWindows() {
Expand Down Expand Up @@ -544,7 +544,7 @@ private static String[] logRecordPreformat(LogRecord r) {
* @since 1.525
*/
public static <T> Iterable<T> reverse(Collection<T> collection) {
List<T> list = new ArrayList<T>(collection);
List<T> list = new ArrayList<>(collection);
Collections.reverse(list);
return list;
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/Launcher.java
Expand Up @@ -197,14 +197,14 @@ public ProcStarter cmds(String... args) {
}

public ProcStarter cmds(File program, String... args) {
commands = new ArrayList<String>(args.length+1);
commands = new ArrayList<>(args.length + 1);
commands.add(program.getPath());
commands.addAll(Arrays.asList(args));
return this;
}

public ProcStarter cmds(List<String> args) {
commands = new ArrayList<String>(args);
commands = new ArrayList<>(args);
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/Lookup.java
Expand Up @@ -32,7 +32,7 @@
* @author Kohsuke Kawaguchi
*/
public class Lookup {
private final ConcurrentHashMap<Class,Object> data = new ConcurrentHashMap<Class,Object>();
private final ConcurrentHashMap<Class,Object> data = new ConcurrentHashMap<>();

public <T> T get(Class<T> type) {
return type.cast(data.get(type));
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/Main.java
Expand Up @@ -152,7 +152,7 @@ public static int remotePost(String[] args) throws Exception {
// run the command
long start = System.currentTimeMillis();

List<String> cmd = new ArrayList<String>();
List<String> cmd = new ArrayList<>();
for( int i=1; i<args.length; i++ )
cmd.add(args[i]);
Proc proc = new Proc.LocalProc(cmd.toArray(new String[0]),(String[])null,System.in,
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/MarkupText.java
Expand Up @@ -45,7 +45,7 @@ public class MarkupText extends AbstractMarkupText {
/**
* Added mark up tags.
*/
private final List<Tag> tags = new ArrayList<Tag>();
private final List<Tag> tags = new ArrayList<>();

/**
* Represents one mark up inserted into text.
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/PermalinkList.java
Expand Up @@ -60,7 +60,7 @@ public Permalink get(String id) {
* Finds the closest name match by its ID.
*/
public Permalink findNearest(String id) {
List<String> ids = new ArrayList<String>();
List<String> ids = new ArrayList<>();
for (Permalink p : this)
ids.add(p.getId());
String nearest = EditDistance.findNearest(id, ids);
Expand Down

0 comments on commit 264980c

Please sign in to comment.