Skip to content

Commit

Permalink
[MNG-6847] Use diamond operator
Browse files Browse the repository at this point in the history
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.staticanalysis.UseDiamondOperator?organizationId=QXBhY2hlIE1hdmVu

Co-authored-by: Moderne <team@moderne.io>
  • Loading branch information
2 people authored and slachiewicz committed Aug 19, 2023
1 parent 600c347 commit cf0718e
Show file tree
Hide file tree
Showing 38 changed files with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public ChangeSet() {
*/
public List<ChangeFile> getFiles() {
if (files == null) {
return new ArrayList<ChangeFile>();
return new ArrayList<>();
}
return files;
}
Expand All @@ -194,7 +194,7 @@ public void setFiles(List<ChangeFile> files) {

public void addFile(ChangeFile file) {
if (files == null) {
files = new ArrayList<ChangeFile>();
files = new ArrayList<>();
}

files.add(file);
Expand Down Expand Up @@ -425,7 +425,7 @@ public void setParentRevision(String parentRevision) {

public void addMergedRevision(String mergedRevision) {
if (mergedRevisions == null) {
mergedRevisions = new LinkedHashSet<String>();
mergedRevisions = new LinkedHashSet<>();
}
mergedRevisions.add(mergedRevision);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class CommandParameters implements Serializable {
private static final long serialVersionUID = -7346070735958137283L;

private Map<String, Object> parameters = new HashMap<String, Object>();
private Map<String, Object> parameters = new HashMap<>();

// ----------------------------------------------------------------------
// String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class ScmFileSet implements Serializable {
* @param basedir directory files in the set are relative to
*/
public ScmFileSet(File basedir) {
this(basedir, new ArrayList<File>(0));
this(basedir, new ArrayList<>(0));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class AddScmResult extends ScmResult {
public AddScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) {
super(commandLine, providerMessage, commandOutput, success);

addedFiles = new ArrayList<ScmFile>(0);
addedFiles = new ArrayList<>(0);
}

public AddScmResult(String commandLine, List<ScmFile> addedFiles) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public CheckInScmResult(List<ScmFile> checkedInFiles, ScmResult result) {

public List<ScmFile> getCheckedInFiles() {
if (this.checkedInFiles == null) {
this.checkedInFiles = new ArrayList<ScmFile>();
this.checkedInFiles = new ArrayList<>();
}
return checkedInFiles;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class InfoScmResult extends ScmResult {
public InfoScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) {
super(commandLine, providerMessage, commandOutput, success);

infoItems = new ArrayList<InfoItem>(0);
infoItems = new ArrayList<>(0);
}

public InfoScmResult(String commandLine, List<InfoItem> files) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ListScmResult extends ScmResult {
public ListScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) {
super(commandLine, providerMessage, commandOutput, success);

files = new ArrayList<ScmFile>(0);
files = new ArrayList<>(0);
}

public ListScmResult(String commandLine, List<ScmFile> files) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public class RemoteInfoScmResult extends ScmResult {
* depending on scm informations can be different
* svn: branch name / remote url
*/
private Map<String, String> branches = new HashMap<String, String>();
private Map<String, String> branches = new HashMap<>();

/**
* depending on scm informations can be different
* svn: branch name / remote url
*/
private Map<String, String> tags = new HashMap<String, String>();
private Map<String, String> tags = new HashMap<>();

public RemoteInfoScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) {
super(commandLine, providerMessage, commandOutput, success);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fil
ChangeLogScmResult changeLogScmResult =
(ChangeLogScmResult) changeLogCmd.executeCommand(repository, fileSet, parameters);

List<ChangeSet> changes = new ArrayList<ChangeSet>();
List<ChangeSet> changes = new ArrayList<>();

ChangeLogSet changeLogSet = changeLogScmResult.getChangeLog();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public List<ScmFile> getUpdatedFiles() {
*/
public List<ChangeSet> getChanges() {
if (changes == null) {
return new ArrayList<ChangeSet>();
return new ArrayList<>();
}
return changes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public boolean validateTagName(String tag) {
*/
@Override
public List<String> validateScmUrl(String scmSpecificUrl, char delimiter) {
List<String> messages = new ArrayList<String>();
List<String> messages = new ArrayList<>();

try {
makeProviderScmRepository(scmSpecificUrl, delimiter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static boolean isValid(String scmUrl) {
* @return A <code>List</code> that contains the errors that occured
*/
public static List<String> validate(String scmUrl) {
List<String> messages = new ArrayList<String>();
List<String> messages = new ArrayList<>();

if (scmUrl == null) {
messages.add("The scm url cannot be null.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ThreadSafeDateFormat(String sDateFormat) {
public SoftReference<SimpleDateFormat> get() {
SoftReference<SimpleDateFormat> softRef = super.get();
if (softRef == null || softRef.get() == null) {
softRef = new SoftReference<SimpleDateFormat>(new SimpleDateFormat(dateFormat));
softRef = new SoftReference<>(new SimpleDateFormat(dateFormat));
super.set(softRef);
}
return softRef;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public ScmVersion getScmVersion(String versionType, String version) throws MojoE
}

protected void handleExcludesIncludesAfterCheckoutAndExport(File checkoutDirectory) throws MojoExecutionException {
List<String> includes = new ArrayList<String>();
List<String> includes = new ArrayList<>();

if (!StringUtils.isBlank(this.getIncludes())) {
String[] tokens = StringUtils.split(this.getIncludes(), ",");
Expand All @@ -439,7 +439,7 @@ protected void handleExcludesIncludesAfterCheckoutAndExport(File checkoutDirecto
}
}

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

if (!StringUtils.isBlank(this.getExcludes())) {
String[] tokens = StringUtils.split(this.getExcludes(), ",");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,25 @@ private HgUtils() {
/**
* Map between command and its valid exit codes
*/
private static final Map<String, List<Integer>> EXIT_CODE_MAP = new HashMap<String, List<Integer>>();
private static final Map<String, List<Integer>> EXIT_CODE_MAP = new HashMap<>();

/**
* Default exit codes for entries not in exitCodeMap
*/
private static final List<Integer> DEFAULT_EXIT_CODES = new ArrayList<Integer>();
private static final List<Integer> DEFAULT_EXIT_CODES = new ArrayList<>();

/** Setup exit codes*/
static {
DEFAULT_EXIT_CODES.add(Integer.valueOf(0));

// Diff is different
List<Integer> diffExitCodes = new ArrayList<Integer>(3);
List<Integer> diffExitCodes = new ArrayList<>(3);
diffExitCodes.add(Integer.valueOf(0)); // No difference
diffExitCodes.add(Integer.valueOf(1)); // Conflicts in merge-like or changes in diff-like
diffExitCodes.add(Integer.valueOf(2)); // Unrepresentable diff changes
EXIT_CODE_MAP.put(HgCommandConstants.DIFF_CMD, diffExitCodes);
// Outgoing is different
List<Integer> outgoingExitCodes = new ArrayList<Integer>(2);
List<Integer> outgoingExitCodes = new ArrayList<>(2);
outgoingExitCodes.add(Integer.valueOf(0)); // There are changes
outgoingExitCodes.add(Integer.valueOf(1)); // No changes
EXIT_CODE_MAP.put(HgCommandConstants.OUTGOING_CMD, outgoingExitCodes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class HgAddConsumer extends HgConsumer {
private final File workingDir;

private final List<ScmFile> addedFiles = new ArrayList<ScmFile>();
private final List<ScmFile> addedFiles = new ArrayList<>();

public HgAddConsumer(File workingDir) {
this.workingDir = workingDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void doConsume(ScmFileStatus status, String trimmedLine) {
}

List<ScmFile> files = listconsumer.getFiles();
List<ScmFile> fileList = new ArrayList<ScmFile>();
List<ScmFile> fileList = new ArrayList<>();
for (ScmFile f : files) {
fileList.add(new ScmFile(f.getPath(), ScmFileStatus.TAGGED));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private ChangeLogScmResult executeChangeLogCommand(
dateInterval.append(" to ");
dateInterval.append(dateFormat.format(endDate == null ? new Date() : endDate)); // Upto now

List<String> cmd = new ArrayList<String>();
List<String> cmd = new ArrayList<>();
cmd.addAll(Arrays.asList(
HgCommandConstants.LOG_CMD, HgCommandConstants.TEMPLATE_OPTION,
HgCommandConstants.TEMPLATE_FORMAT, HgCommandConstants.NO_MERGES_OPTION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class HgChangeLogConsumer extends HgConsumer {

private static final String FILES_TOKEN = "files:";

private List<ChangeSet> logEntries = new ArrayList<ChangeSet>();
private List<ChangeSet> logEntries = new ArrayList<>();

private ChangeSet currentChange;

Expand Down Expand Up @@ -89,7 +89,7 @@ public void doConsume(ScmFileStatus status, String line) {
if (line.startsWith(REVNO_TAG)) {
// Init a new changeset
currentChange = new ChangeSet();
currentChange.setFiles(new ArrayList<ChangeFile>(0));
currentChange.setFiles(new ArrayList<>(0));
logEntries.add(currentChange);

// parse revision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected CheckInScmResult executeCheckInCommand(
repo.isPushChanges() ? HgUtils.differentOutgoingBranchFound(workingDir, branchName) : false;

// Get files that will be committed (if not specified in fileSet)
List<ScmFile> commitedFiles = new ArrayList<ScmFile>();
List<ScmFile> commitedFiles = new ArrayList<>();
List<File> files = fileSet.getFileList();
if (files.isEmpty()) { // Either commit all changes
HgStatusCommand statusCmd = new HgStatusCommand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected CheckOutScmResult executeCheckOutCommand(
}

// Do the actual checkout
List<String> cmdList = new ArrayList<String>();
List<String> cmdList = new ArrayList<>();
if (repo.isPushChanges()) {
cmdList.add(HgCommandConstants.CLONE_CMD);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class HgCheckOutConsumer extends HgConsumer {

private final File workingDirectory;

private List<ScmFile> checkedOut = new ArrayList<ScmFile>();
private List<ScmFile> checkedOut = new ArrayList<>();

public HgCheckOutConsumer(File workingDirectory) {
this.workingDirectory = workingDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
*/
public class HgOutgoingConsumer extends HgConsumer {
private List<HgChangeSet> changes = new CopyOnWriteArrayList<HgChangeSet>();
private List<HgChangeSet> changes = new CopyOnWriteArrayList<>();

private static final String BRANCH = "branch";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public class HgRemoveConsumer extends HgConsumer {
private final File workingDir;

private final List<ScmFile> removedFiles = new ArrayList<ScmFile>();
private final List<ScmFile> removedFiles = new ArrayList<>();

public HgRemoveConsumer(File workingDir) {
this.workingDir = workingDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
*/
class HgStatusConsumer extends HgConsumer {
private final List<ScmFile> repositoryStatus = new ArrayList<ScmFile>();
private final List<ScmFile> repositoryStatus = new ArrayList<>();

private final File workingDir;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected ScmResult executeTagCommand(
result = HgUtils.execute(listconsumer, fileSet.getBasedir(), listCmd);
if (result.isSuccess()) {
List<ScmFile> files = listconsumer.getFiles();
List<ScmFile> fileList = new ArrayList<ScmFile>();
List<ScmFile> fileList = new ArrayList<>();
for (ScmFile f : files) {
if (!f.getPath().endsWith(".hgtags")) {
fileList.add(new ScmFile(f.getPath(), ScmFileStatus.TAGGED));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static void initRepo() throws Exception {
HgUtils.execute(WORKING_DIR, init_cmd);

// Create and add files to repository
List<File> files = new ArrayList<File>();
List<File> files = new ArrayList<>();
for (int i = 0; i < filesInTestBranch.length; i++) {
File file = new File(WORKING_DIR.getAbsolutePath(), filesInTestBranch[i]);
if (file.getParentFile() != null && !file.getParentFile().exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected ScmResult executeAddCommand(
ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
LocalScmProviderRepository localRepo = (LocalScmProviderRepository) repository;

List<ScmFile> fileList = new ArrayList<ScmFile>();
List<ScmFile> fileList = new ArrayList<>();
for (File file : fileSet.getFileList()) {
String path = file.getPath().replace('\\', '/');
localRepo.addFile(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class LocalScmProviderRepository extends ScmProviderRepository {

private String module;

private Set<String> addedFiles = new HashSet<String>();
private Set<String> addedFiles = new HashSet<>();

/**
* @param root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void consumeLine(String line) {

ScmFileStatus status = null;

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

Matcher matcher;
if ((matcher = ADDED_PATTERN.matcher(line)).find()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class GitExeAddCommandTest extends ScmTestCase {

@Test
public void testAddCommandSingleFile() throws Exception {
List<File> files = new ArrayList<File>();
List<File> files = new ArrayList<>();

files.add(new File("myFile.java"));

Expand All @@ -45,7 +45,7 @@ public void testAddCommandSingleFile() throws Exception {

@Test
public void testAddCommandMultipleFiles() throws Exception {
List<File> files = new ArrayList<File>();
List<File> files = new ArrayList<>();

files.add(new File("myFile.java"));
files.add(new File("myFile2.java"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void testConsumer2() throws Exception {
List<ChangeSet> modifications = consumer.getModifications();

// must use *Linked* HashMap to have predictable toString
final Map<ScmFileStatus, AtomicInteger> summary = new LinkedHashMap<ScmFileStatus, AtomicInteger>();
final Map<ScmFileStatus, AtomicInteger> summary = new LinkedHashMap<>();

for (Iterator<ChangeSet> i = modifications.iterator(); i.hasNext(); ) {
ChangeSet entry = i.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet
git = JGitUtils.openRepo(basedir);
BlameResult blameResult = git.blame().setFilePath(filename).call();

List<BlameLine> lines = new ArrayList<BlameLine>();
List<BlameLine> lines = new ArrayList<>();

int i = 0;
while ((i = blameResult.computeNext()) != -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public String getProperty(String group, String propertyName) {
* @return the list of all lines
*/
private List<String> getConfLines() {
List<String> lines = new ArrayList<String>();
List<String> lines = new ArrayList<>();

BufferedReader reader = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void testConsumerWithPattern2() throws Exception {
int origFileCounter = 0;

// must use *Linked* HashMap to have predictable toString
final Map<ScmFileStatus, AtomicInteger> summary = new LinkedHashMap<ScmFileStatus, AtomicInteger>();
final Map<ScmFileStatus, AtomicInteger> summary = new LinkedHashMap<>();

for (ChangeSet entry : consumer.getModifications()) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class ScmManagerStub implements ScmManager {
public ScmManagerStub() {
setScmRepository(new ScmRepositoryStub());
setScmProvider(new ScmProviderStub());
setMessages(new ArrayList<String>(0));
setMessages(new ArrayList<>(0));
}

public void setScmProvider(ScmProvider scmProvider) {
Expand Down
Loading

0 comments on commit cf0718e

Please sign in to comment.