Skip to content

Commit

Permalink
Cleanup - Remove unnecessary type casts
Browse files Browse the repository at this point in the history
These types can be inferred by the compiler now.
  • Loading branch information
darxriggs committed Feb 14, 2019
1 parent 288464d commit 81ee0e9
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 17 deletions.
Expand Up @@ -63,6 +63,6 @@ public static <E> List<E> selectNodes(final DomNode domNode, final String xpathE
*/
public static <X> X selectSingleNode(final DomNode domNode, final String xpathExpr) {
WebClientUtil.waitForJSExec(domNode.getPage().getWebClient());
return domNode.<X>getFirstByXPath(xpathExpr);
return domNode.getFirstByXPath(xpathExpr);
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/jvnet/hudson/test/FakeChangeLogSCM.java
Expand Up @@ -106,7 +106,7 @@ public FakeChangeLogSet parse(Run build, RepositoryBrowser<?> browser, File chan
return new FakeChangeLogSet(build, action.entries);
}
}
return new FakeChangeLogSet(build, Collections.<EntryImpl>emptyList());
return new FakeChangeLogSet(build, Collections.emptyList());
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/jvnet/hudson/test/HudsonTestCase.java
Expand Up @@ -66,7 +66,6 @@
import hudson.slaves.ComputerLauncher;
import hudson.slaves.ComputerListener;
import hudson.slaves.DumbSlave;
import hudson.slaves.NodeProperty;
import hudson.slaves.RetentionStrategy;
import hudson.tasks.BuildWrapper;
import hudson.tasks.BuildWrapperDescriptor;
Expand Down Expand Up @@ -648,7 +647,7 @@ public DumbSlave createSlave(String nodeName, String labels, EnvVars env) throws
synchronized (jenkins) {
DumbSlave slave = new DumbSlave(nodeName, "dummy",
createTmpDir().getPath(), "1", Mode.NORMAL, labels==null?"":labels, createComputerLauncher(env),
RetentionStrategy.NOOP, Collections.<NodeProperty<?>>emptyList());
RetentionStrategy.NOOP, Collections.emptyList());
jenkins.addNode(slave);
return slave;
}
Expand Down Expand Up @@ -1761,7 +1760,7 @@ public boolean isLoggable(LogRecord record) {

private static final Logger LOGGER = Logger.getLogger(HudsonTestCase.class.getName());

protected static final List<ToolProperty<?>> NO_PROPERTIES = Collections.<ToolProperty<?>>emptyList();
protected static final List<ToolProperty<?>> NO_PROPERTIES = Collections.emptyList();

/**
* Specify this to a TCP/IP port number to have slaves started with the debugger.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jvnet/hudson/test/JenkinsRule.java
Expand Up @@ -2590,7 +2590,7 @@ public boolean isLoggable(LogRecord record) {

private static final Logger LOGGER = Logger.getLogger(HudsonTestCase.class.getName());

public static final List<ToolProperty<?>> NO_PROPERTIES = Collections.<ToolProperty<?>>emptyList();
public static final List<ToolProperty<?>> NO_PROPERTIES = Collections.emptyList();

/**
* Specify this to a TCP/IP port number to have slaves started with the debugger.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jvnet/hudson/test/MemoryAssert.java
Expand Up @@ -187,7 +187,7 @@ public static void assertGC(WeakReference<?> reference, boolean allowSoft) {
@Override public boolean accept(Object obj, Object referredFrom, Field reference) {
return !referent.equals(reference) || !(referredFrom instanceof WeakReference);
}
}) + "; apparent weak references: " + fromRoots(Collections.singleton(obj), null, null, ScannerUtils.skipObjectsFilter(Collections.<Object>singleton(reference), true));
}) + "; apparent weak references: " + fromRoots(Collections.singleton(obj), null, null, ScannerUtils.skipObjectsFilter(Collections.singleton(reference), true));
}
}
}
Expand Down Expand Up @@ -220,7 +220,7 @@ public static void assertGC(WeakReference<?> reference, boolean allowSoft) {
fail(rootRefs.toString());
} else {
System.err.println("Did not find any soft references to " + obj + ", looking for weak references…");
rootRefs = fromRoots(Collections.singleton(obj), null, null, ScannerUtils.skipObjectsFilter(Collections.<Object>singleton(reference), true));
rootRefs = fromRoots(Collections.singleton(obj), null, null, ScannerUtils.skipObjectsFilter(Collections.singleton(reference), true));
if (!rootRefs.isEmpty()) {
fail(rootRefs.toString());
} else {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/jvnet/hudson/test/PretendSlave.java
Expand Up @@ -8,7 +8,6 @@
import hudson.model.Slave;
import hudson.model.TaskListener;
import hudson.slaves.ComputerLauncher;
import hudson.slaves.NodeProperty;
import hudson.slaves.RetentionStrategy;

import java.io.IOException;
Expand All @@ -29,7 +28,7 @@ public class PretendSlave extends Slave {
public int numLaunch;

public PretendSlave(String name, String remoteFS, int numExecutors, Mode mode, String labelString, ComputerLauncher launcher, FakeLauncher faker) throws IOException, FormException {
super(name, "pretending a slave", remoteFS, String.valueOf(numExecutors), mode, labelString, launcher, RetentionStrategy.NOOP, Collections.<NodeProperty<?>>emptyList());
super(name, "pretending a slave", remoteFS, String.valueOf(numExecutors), mode, labelString, launcher, RetentionStrategy.NOOP, Collections.emptyList());
this.faker = faker;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/jvnet/hudson/test/JenkinsRuleTest.java
Expand Up @@ -29,7 +29,7 @@ public void assertEqualDataBoundBeansForNullLists() throws Exception {

@Test(expected = AssertionError.class)
public void givenOneNullListAndOneNonnullListAssertShouldFail() throws Exception {
j.assertEqualDataBoundBeans(new SomeClass(Collections.<String>emptyList()), new SomeClass(null));
j.assertEqualDataBoundBeans(new SomeClass(Collections.emptyList()), new SomeClass(null));
}

public static class SomeClass {
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/org/jvnet/hudson/test/TestExtensionTest.java
Expand Up @@ -71,35 +71,35 @@ public Class<? extends ItemListener> apply(ItemListener arg0) {
public void test1() throws Exception {
assertThat(
getExtensionClasses(),
Matchers.<Class<? extends ItemListener>>hasItems(AllTests.class, SingleTests.class, MultipleTests.class)
Matchers.hasItems(AllTests.class, SingleTests.class, MultipleTests.class)
);
}

@Test
public void test2() throws Exception {
assertThat(
getExtensionClasses(),
Matchers.<Class<? extends ItemListener>>hasItems(AllTests.class, MultipleTests.class)
Matchers.hasItems(AllTests.class, MultipleTests.class)
);
assertThat(
getExtensionClasses(),
Matchers.not(Matchers.<Class<? extends ItemListener>>hasItem(SingleTests.class))
Matchers.not(Matchers.hasItem(SingleTests.class))
);
}

@Test
public void test3() throws Exception {
assertThat(
getExtensionClasses(),
Matchers.<Class<? extends ItemListener>>hasItems(AllTests.class)
Matchers.hasItems(AllTests.class)
);
assertThat(
getExtensionClasses(),
Matchers.not(Matchers.<Class<? extends ItemListener>>hasItem(SingleTests.class))
Matchers.not(Matchers.hasItem(SingleTests.class))
);
assertThat(
getExtensionClasses(),
Matchers.not(Matchers.<Class<? extends ItemListener>>hasItem(MultipleTests.class))
Matchers.not(Matchers.hasItem(MultipleTests.class))
);
}
}

0 comments on commit 81ee0e9

Please sign in to comment.