Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/apache/maven/shared/utils/Os.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public static Set<String> getValidFamilies() {
return VALID_FAMILIES;
}

Set<String> valid = new HashSet<String>();
Set<String> valid = new HashSet<>();
valid.add(FAMILY_DOS);
valid.add(FAMILY_MAC);
valid.add(FAMILY_NETWARE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
public class Commandline implements Cloneable {
private final List<Arg> arguments = new Vector<>();

private final Map<String, String> envVars = Collections.synchronizedMap(new LinkedHashMap<String, String>());
private final Map<String, String> envVars = Collections.synchronizedMap(new LinkedHashMap<>());

private Shell shell;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public String getExecutable() {

/** {@inheritDoc} */
public List<String> getShellArgsList() {
List<String> shellArgs = new ArrayList<String>();
List<String> shellArgs = new ArrayList<>();
List<String> existingShellArgs = super.getShellArgsList();

if ((existingShellArgs != null) && !existingShellArgs.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class Shell implements Cloneable {

private String shellCommand;

private final List<String> shellArgs = new ArrayList<String>();
private final List<String> shellArgs = new ArrayList<>();

private boolean quotedArgumentsEnabled = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static final class CacheMiss {}
* Cache of Methods, or CACHE_MISS, keyed by method
* name and actual arguments used to find it.
*/
private final Map<String, Object> methodCache = new Hashtable<String, Object>();
private final Map<String, Object> methodCache = new Hashtable<>();

private MethodMap methodMap = new MethodMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MethodMap {
/**
* Keep track of all methods with the same name.
*/
private final Map<String, List<Method>> methodByNameMap = new Hashtable<String, List<Method>>();
private final Map<String, List<Method>> methodByNameMap = new Hashtable<>();

/**
* Add a method to a list of methods by name.
Expand All @@ -59,7 +59,7 @@ void add(Method method) {
List<Method> l = get(methodName);

if (l == null) {
l = new ArrayList<Method>();
l = new ArrayList<>();
methodByNameMap.put(methodName, l);
}

Expand Down Expand Up @@ -153,7 +153,7 @@ private static Method getMostSpecific(List<Method> methods, Class<?>... classes)
* (the most specific method) otherwise we have ambiguity.
*/

LinkedList<Method> maximals = new LinkedList<Method>();
LinkedList<Method> maximals = new LinkedList<>();

for (Method app : applicables) {
Class<?>[] appArgs = app.getParameterTypes();
Expand Down Expand Up @@ -255,7 +255,7 @@ private static int moreSpecific(Class<?>[] c1, Class<?>[] c2) {
* to formal types through a method invocation conversion).
*/
private static LinkedList<Method> getApplicables(List<Method> methods, Class<?>... classes) {
LinkedList<Method> list = new LinkedList<Method>();
LinkedList<Method> list = new LinkedList<>();

for (Method method : methods) {
if (isApplicable(method, classes)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class ReflectionValueExtractor {
* This approach prevents permgen space overflows due to retention of discarded
* classloaders.
*/
private static final Map<Class<?>, ClassMap> CLASS_MAPS = new WeakHashMap<Class<?>, ClassMap>();
private static final Map<Class<?>, ClassMap> CLASS_MAPS = new WeakHashMap<>();

static final int EOF = -1;

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/apache/maven/shared/utils/io/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public static void fileDelete(@Nonnull String fileName) {
* @return an array of files for the wanted extensions
*/
public static String[] getFilesFromExtension(@Nonnull String directory, @Nonnull String... extensions) {
List<String> files = new ArrayList<String>();
List<String> files = new ArrayList<>();

File currentDir = new File(directory);

Expand Down Expand Up @@ -1291,7 +1291,7 @@ public static List<File> getFiles(
throws IOException {
List<String> fileNames = getFileNames(directory, includes, excludes, includeBasedir);

List<File> files = new ArrayList<File>();
List<File> files = new ArrayList<>();

for (String filename : fileNames) {
files.add(new File(filename));
Expand Down Expand Up @@ -1423,7 +1423,7 @@ public static List<String> getFileAndDirectoryNames(

scanner.scan();

List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();

if (getFiles) {
String[] files = scanner.getIncludedFiles();
Expand Down Expand Up @@ -1835,7 +1835,7 @@ private static void copyFilePermissions(@Nonnull File source, @Nonnull File dest
@Deprecated
@Nonnull
public static List<String> loadFile(@Nonnull File file) throws IOException {
List<String> lines = new ArrayList<String>();
List<String> lines = new ArrayList<>();

if (file.exists()) {
try (BufferedReader reader = Files.newBufferedReader(file.toPath(), Charset.defaultCharset())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public boolean startsWith(String string) {
}

static String[] tokenizePathToString(@Nonnull String path, @Nonnull String separator) {
List<String> ret = new ArrayList<String>();
List<String> ret = new ArrayList<>();
StringTokenizer st = new StringTokenizer(path, separator);
while (st.hasMoreTokens()) {
ret.add(st.nextToken());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ private static boolean equals(char c1, char c2, boolean isCaseSensitive) {
* @return a List of path elements from the tokenized path
*/
private static List<String> tokenizePath(String path, String separator) {
List<String> ret = new ArrayList<String>();
List<String> ret = new ArrayList<>();
StringTokenizer st = new StringTokenizer(path, separator);
while (st.hasMoreTokens()) {
ret.add(st.nextToken());
Expand All @@ -519,7 +519,7 @@ static boolean matchAntPathPatternStart(
}

private static String[] tokenizePathToString(@Nonnull String path, @Nonnull String separator) {
List<String> ret = new ArrayList<String>();
List<String> ret = new ArrayList<>();
StringTokenizer st = new StringTokenizer(path, separator);
while (st.hasMoreTokens()) {
ret.add(st.nextToken());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class WalkCollector implements DirectoryWalkListener {
* Create an instance.
*/
public WalkCollector() {
steps = new ArrayList<File>();
steps = new ArrayList<>();
startCount = 0;
finishCount = 0;
percentageLow = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class PrettyPrintXMLWriter implements XMLWriter {

private PrintWriter writer;

private ArrayList<String> elementStack = new ArrayList<String>();
private ArrayList<String> elementStack = new ArrayList<>();

private boolean processingElement = false;

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/apache/maven/shared/utils/xml/Xpp3Dom.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public class Xpp3Dom implements Iterable<Xpp3Dom> {
*/
public Xpp3Dom(String name) {
this.name = name;
childList = new ArrayList<Xpp3Dom>();
childMap = new HashMap<String, Xpp3Dom>();
childList = new ArrayList<>();
childMap = new HashMap<>();
}

/**
Expand All @@ -113,8 +113,8 @@ public Xpp3Dom(@Nonnull Xpp3Dom src, String name) {
this.name = name;

int size = src.getChildCount();
childList = new ArrayList<Xpp3Dom>(size);
childMap = new HashMap<String, Xpp3Dom>();
childList = new ArrayList<>(size);
childMap = new HashMap<>();

setValue(src.getValue());

Expand Down Expand Up @@ -177,7 +177,7 @@ public void setAttribute(@Nonnull String nameParameter, @Nonnull String valuePar
throw new NullPointerException("name can not be null");
}
if (attributes == null) {
attributes = new HashMap<String, String>();
attributes = new HashMap<>();
}

attributes.put(nameParameter, valueParameter);
Expand Down Expand Up @@ -234,7 +234,7 @@ List<Xpp3Dom> getChildrenList(String nameParameter) {
if (childList == null) {
return Collections.emptyList();
} else {
ArrayList<Xpp3Dom> children = new ArrayList<Xpp3Dom>();
ArrayList<Xpp3Dom> children = new ArrayList<>();
for (Xpp3Dom aChildList : childList) {
if (nameParameter.equals(aChildList.getName())) {
children.add(aChildList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ private static XMLReader instantiate(String s) {
}

private static class DocHandler extends DefaultHandler {
private final List<Xpp3Dom> elemStack = new ArrayList<Xpp3Dom>();
private final List<Xpp3Dom> elemStack = new ArrayList<>();

private final List<StringBuilder> values = new ArrayList<StringBuilder>();
private final List<StringBuilder> values = new ArrayList<>();

Xpp3Dom result = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static Xpp3Dom merge(Xpp3Dom dominant, Xpp3Dom recessive, Boolean childMe
}

private static Map<String, Iterator<Xpp3Dom>> getCommonChildren(Xpp3Dom dominant, Xpp3Dom recessive) {
Map<String, Iterator<Xpp3Dom>> commonChildren = new HashMap<String, Iterator<Xpp3Dom>>();
Map<String, Iterator<Xpp3Dom>> commonChildren = new HashMap<>();

for (String childName : recessive.childMap.keySet()) {
List<Xpp3Dom> dominantChildren = dominant.getChildrenList(childName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ public void testInterpolate_NPE2() {

@Test
public void testInterpolate() {
Map<String, String> variables = new HashMap<String, String>();
Map<String, String> variables = new HashMap<>();
assertThat(
StringUtils.interpolate("This ${text} will get replaced", variables),
is("This ${text} will get replaced"));
Expand Down Expand Up @@ -767,7 +767,7 @@ public void testJoin_Iterator_NPE() {

@Test
public void testJoin_Iterator() {
ArrayList<String> list = new ArrayList<String>();
ArrayList<String> list = new ArrayList<>();

assertThat(StringUtils.join(list.iterator(), null), is(""));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,37 +144,37 @@ public void testValueExtractorWithAInvalidExpression() throws IntrospectionExcep
}

public void testMappedDottedKey() throws IntrospectionException {
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put("a.b", "a.b-value");

assertEquals("a.b-value", ReflectionValueExtractor.evaluate("h.value(a.b)", new ValueHolder(map)));
}

public void testIndexedMapped() throws IntrospectionException {
Map<Object, Object> map = new HashMap<Object, Object>();
Map<Object, Object> map = new HashMap<>();
map.put("a", "a-value");
List<Object> list = new ArrayList<Object>();
List<Object> list = new ArrayList<>();
list.add(map);

assertEquals("a-value", ReflectionValueExtractor.evaluate("h.value[0](a)", new ValueHolder(list)));
}

public void testMappedIndexed() throws IntrospectionException {
List<Object> list = new ArrayList<Object>();
List<Object> list = new ArrayList<>();
list.add("a-value");
Map<Object, Object> map = new HashMap<Object, Object>();
Map<Object, Object> map = new HashMap<>();
map.put("a", list);
assertEquals("a-value", ReflectionValueExtractor.evaluate("h.value(a)[0]", new ValueHolder(map)));
}

public void testMappedMissingDot() throws IntrospectionException {
Map<Object, Object> map = new HashMap<Object, Object>();
Map<Object, Object> map = new HashMap<>();
map.put("a", new ValueHolder("a-value"));
assertNull(ReflectionValueExtractor.evaluate("h.value(a)value", new ValueHolder(map)));
}

public void testIndexedMissingDot() throws IntrospectionException {
List<Object> list = new ArrayList<Object>();
List<Object> list = new ArrayList<>();
list.add(new ValueHolder("a-value"));
assertNull(ReflectionValueExtractor.evaluate("h.value[0]value", new ValueHolder(list)));
}
Expand All @@ -184,7 +184,7 @@ public void testDotDot() throws IntrospectionException {
}

public void testBadIndexedSyntax() throws IntrospectionException {
List<Object> list = new ArrayList<Object>();
List<Object> list = new ArrayList<>();
list.add("a-value");
Object value = new ValueHolder(list);

Expand All @@ -197,7 +197,7 @@ public void testBadIndexedSyntax() throws IntrospectionException {
}

public void testBadMappedSyntax() throws IntrospectionException {
Map<Object, Object> map = new HashMap<Object, Object>();
Map<Object, Object> map = new HashMap<>();
map.put("a", "a-value");
Object value = new ValueHolder(map);

Expand Down Expand Up @@ -304,7 +304,7 @@ public static class Project {

private Scm scm;

private final List<Dependency> dependencies = new ArrayList<Dependency>();
private final List<Dependency> dependencies = new ArrayList<>();

private Build build;

Expand All @@ -314,7 +314,7 @@ public static class Project {

private String version;

private Map<String, Artifact> artifactMap = new HashMap<String, Artifact>();
private Map<String, Artifact> artifactMap = new HashMap<>();

private String description;

Expand Down Expand Up @@ -388,7 +388,7 @@ public Dependency[] getDependenciesAsArray() {
}

public Map<String, Dependency> getDependenciesAsMap() {
Map<String, Dependency> ret = new HashMap<String, Dependency>();
Map<String, Dependency> ret = new HashMap<>();
for (Object o : getDependencies()) {
Dependency dep = (Dependency) o;
ret.put(dep.getArtifactId(), dep);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private void checkFiles(String category, String[] expectedFiles, String[] resolv
}

private static class TestScanConductor implements ScanConductor {
final List<String> visitedFiles = new ArrayList<String>();
final List<String> visitedFiles = new ArrayList<>();

public ScanConductor.ScanAction visitDirectory(String name, File directory) {
assertTrue(directory.isDirectory());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ public void getDefaultExcludesAsList() throws Exception {
@Test
public void getDefaultExcludesAsString() throws Exception {
assertThat(
new HashSet<String>(
new HashSet<>(
Arrays.asList(FileUtils.getDefaultExcludesAsString().split(","))),
hasItems(MINIMUM_DEFAULT_EXCLUDES));
}
Expand Down