diff options
203 files changed, 466 insertions, 486 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java index b78deb2812c..0d1c978e0de 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java @@ -54,7 +54,7 @@ public class XooBlameCommand extends BlameCommand { try { List<String> lines = FileUtils.readLines(scmDataFile, Charsets.UTF_8.name()); - List<BlameLine> blame = new ArrayList<BlameLine>(lines.size()); + List<BlameLine> blame = new ArrayList<>(lines.size()); int lineNumber = 0; for (String line : lines) { lineNumber++; diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java index d4b774cb851..baeb769d337 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java @@ -39,18 +39,18 @@ public class JavaCommand { private File workDir; // for example -Xmx1G - private final List<String> javaOptions = new ArrayList<String>(); + private final List<String> javaOptions = new ArrayList<>(); // entry point private String className; // relative path to JAR files - private final List<String> classpath = new ArrayList<String>(); + private final List<String> classpath = new ArrayList<>(); // program arguments (parameters of main(String[]) - private final Map<String, String> arguments = new LinkedHashMap<String, String>(); + private final Map<String, String> arguments = new LinkedHashMap<>(); - private final Map<String, String> envVariables = new HashMap<String, String>(System.getenv()); + private final Map<String, String> envVariables = new HashMap<>(System.getenv()); private File tempDir = null; diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java index dd67a10489d..1e3ee06648e 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java @@ -64,7 +64,7 @@ public class JavaProcessLauncher { } private ProcessBuilder create(JavaCommand javaCommand) { - List<String> commands = new ArrayList<String>(); + List<String> commands = new ArrayList<>(); commands.add(buildJavaPath()); commands.addAll(javaCommand.getJavaOptions()); // TODO warning - does it work if temp dir contains a whitespace ? diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java index fd546b9df5d..df3d53518ee 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java @@ -30,7 +30,7 @@ import java.util.concurrent.CopyOnWriteArrayList; public class Monitor { - private final List<ProcessRef> processes = new CopyOnWriteArrayList<ProcessRef>(); + private final List<ProcessRef> processes = new CopyOnWriteArrayList<>(); private final TerminatorThread terminator; private final JavaProcessLauncher launcher; private final Lifecycle lifecycle = new Lifecycle(); @@ -39,7 +39,7 @@ public class Monitor { private Thread shutdownHook = new Thread(new MonitorShutdownHook(), "Monitor Shutdown Hook"); // used by awaitStop() to block until all processes are shutdown - private final List<WatcherThread> watcherThreads = new CopyOnWriteArrayList<WatcherThread>(); + private final List<WatcherThread> watcherThreads = new CopyOnWriteArrayList<>(); static int nextProcessId = 0; Monitor(JavaProcessLauncher launcher, SystemExit exit, TerminatorThread terminator) { diff --git a/server/sonar-process/src/main/java/org/sonar/process/Encryption.java b/server/sonar-process/src/main/java/org/sonar/process/Encryption.java index cca05e6c780..fe9d66ec08f 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/Encryption.java +++ b/server/sonar-process/src/main/java/org/sonar/process/Encryption.java @@ -37,7 +37,7 @@ public final class Encryption { private static final String AES_ALGORITHM = "aes"; private final AesCipher aesCipher; - private final Map<String, Cipher> ciphers = new HashMap<String, Cipher>(); + private final Map<String, Cipher> ciphers = new HashMap<>(); private static final Pattern ENCRYPTED_PATTERN = Pattern.compile("\\{(.*?)\\}(.*)"); public Encryption(@Nullable String pathToSecretKey) { diff --git a/server/sonar-process/src/main/java/org/sonar/process/MinimumViableSystem.java b/server/sonar-process/src/main/java/org/sonar/process/MinimumViableSystem.java index 2389fa5aa18..fdbc7217611 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/MinimumViableSystem.java +++ b/server/sonar-process/src/main/java/org/sonar/process/MinimumViableSystem.java @@ -29,7 +29,7 @@ import java.util.Map; public class MinimumViableSystem { - private final Map<String, String> requiredJavaOptions = new HashMap<String, String>(); + private final Map<String, String> requiredJavaOptions = new HashMap<>(); public MinimumViableSystem setRequiredJavaOption(String propertyKey, String expectedValue) { requiredJavaOptions.put(propertyKey, expectedValue); diff --git a/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java b/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java index 587825f60f5..d93ae29b515 100644 --- a/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java +++ b/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java @@ -99,7 +99,7 @@ public class ListUpdate extends AbstractExecutableScript { if (fieldValue == null && value != null) { // 0. The field does not exist (this is a upsert then) - List values = new ArrayList<Object>(1); + List values = new ArrayList<>(1); values.add(value); source.put(field, values); } else if (!XContentMapValues.isArray(fieldValue) && value != null) { @@ -108,7 +108,7 @@ public class ListUpdate extends AbstractExecutableScript { if (XContentMapValues.nodeStringValue(currentFieldValue.get(idField), null).equals(idValue)) { source.put(field, value); } else { - List values = new ArrayList<Object>(2); + List values = new ArrayList<>(2); values.add(fieldValue); values.add(value); source.put(field, values); diff --git a/server/sonar-search/src/test/java/org/sonar/search/script/UpdateListScriptTest.java b/server/sonar-search/src/test/java/org/sonar/search/script/UpdateListScriptTest.java index 06c2c355c73..360f8a4d021 100644 --- a/server/sonar-search/src/test/java/org/sonar/search/script/UpdateListScriptTest.java +++ b/server/sonar-search/src/test/java/org/sonar/search/script/UpdateListScriptTest.java @@ -43,7 +43,7 @@ public class UpdateListScriptTest { @Test public void fail_missing_attributes_field() { - Map<String, Object> params = new HashMap<String, Object>(); + Map<String, Object> params = new HashMap<>(); // Missing everything try { @@ -105,11 +105,11 @@ public class UpdateListScriptTest { String listField = "listField"; Collection<Map<String, Object>> mapFields; - Map source = new HashMap<String, Object>(); + Map source = new HashMap<>(); source.put("field1", "value1"); // 0 Create list when field does not exists - Map<String, Object> params = new HashMap<String, Object>(); + Map<String, Object> params = new HashMap<>(); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, listField); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, "1"); @@ -124,7 +124,7 @@ public class UpdateListScriptTest { assertThat(mapFields).hasSize(1); // Add item to existing list - params = new HashMap<String, Object>(); + params = new HashMap<>(); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, listField); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, "2"); @@ -136,7 +136,7 @@ public class UpdateListScriptTest { assertThat(mapFields).hasSize(2); // updated first item in list - params = new HashMap<String, Object>(); + params = new HashMap<>(); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, listField); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, "1"); @@ -148,7 +148,7 @@ public class UpdateListScriptTest { assertThat(mapFields).hasSize(2); // updated second item in list - params = new HashMap<String, Object>(); + params = new HashMap<>(); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, listField); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, "2"); @@ -160,7 +160,7 @@ public class UpdateListScriptTest { assertThat(mapFields).hasSize(2); // delete first item - params = new HashMap<String, Object>(); + params = new HashMap<>(); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, listField); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, "1"); @@ -173,7 +173,7 @@ public class UpdateListScriptTest { } private Map<String, Object> mapOf(String k, String v, String k1, String v1) { - Map<String, Object> map = new HashMap<String, Object>(); + Map<String, Object> map = new HashMap<>(); map.put(k, v); map.put(k1, v1); return map; diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/BaseDao.java b/server/sonar-server/src/main/java/org/sonar/server/db/BaseDao.java index 1fe29ad23c4..e0875201856 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/BaseDao.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/BaseDao.java @@ -251,7 +251,7 @@ public abstract class BaseDao<MAPPER, DTO extends Dto<KEY>, KEY extends Serializ try { doInsert(session, item); if (hasIndex()) { - session.enqueue(new UpsertDto<DTO>(getIndexType(), item)); + session.enqueue(new UpsertDto<>(getIndexType(), item)); } } catch (Exception e) { throw new IllegalStateException("Fail to insert item in db: " + item, e); @@ -281,7 +281,7 @@ public abstract class BaseDao<MAPPER, DTO extends Dto<KEY>, KEY extends Serializ try { doDeleteByKey(session, key); if (hasIndex()) { - session.enqueue(new DeleteKey<KEY>(getIndexType(), key)); + session.enqueue(new DeleteKey<>(getIndexType(), key)); } } catch (Exception e) { throw new IllegalStateException("Fail to delete item from db: " + key, e); @@ -290,14 +290,14 @@ public abstract class BaseDao<MAPPER, DTO extends Dto<KEY>, KEY extends Serializ protected final void enqueueUpdate(Object nestedItem, KEY key, DbSession session) { if (hasIndex()) { - session.enqueue(new UpsertNestedItem<KEY>( + session.enqueue(new UpsertNestedItem<>( this.getIndexType(), key, nestedItem)); } } public void enqueueDelete(Object nestedItem, KEY key, DbSession session) { if (hasIndex()) { - session.enqueue(new DeleteNestedItem<KEY>( + session.enqueue(new DeleteNestedItem<>( this.getIndexType(), key, nestedItem)); session.commit(); } @@ -329,7 +329,7 @@ public abstract class BaseDao<MAPPER, DTO extends Dto<KEY>, KEY extends Serializ public void handleResult(ResultContext resultContext) { DTO dto = (DTO) resultContext.getResultObject(); // session.enqueue(new UpsertDto<DTO>(getIndexType(), dto, false)); - getSession().enqueue(new InsertDto<DTO>(getIndexType(), dto, false)); + getSession().enqueue(new InsertDto<>(getIndexType(), dto, false)); count++; if (count % 100000 == 0) { LOGGER.info("Synchronized {} {}", count, getIndexType()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/SelectImpl.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/SelectImpl.java index a433b473e4a..62ad570ded6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/SelectImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/SelectImpl.java @@ -40,7 +40,7 @@ class SelectImpl extends BaseSqlStatement<Select> implements Select { ResultSet rs = pstmt.executeQuery(); Select.Row row = new Select.Row(rs); try { - List<T> rows = new ArrayList<T>(); + List<T> rows = new ArrayList<>(); while (rs.next()) { rows.add(reader.read(row)); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/Referentials.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/Referentials.java index f7ee441c668..1bd842ed732 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/Referentials.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/Referentials.java @@ -109,7 +109,7 @@ class Referentials { stmt = connection.createStatement(); stmt.setFetchSize(10000); rs = stmt.executeQuery("select id from rule_failures"); - Queue<long[]> queue = new ConcurrentLinkedQueue<long[]>(); + Queue<long[]> queue = new ConcurrentLinkedQueue<>(); totalViolations = 0; long[] block = new long[VIOLATION_GROUP_SIZE]; diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/FileSourceDto.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/FileSourceDto.java index fc26516b454..1219afd4d92 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/FileSourceDto.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/FileSourceDto.java @@ -118,11 +118,11 @@ class FileSourceDto { } private Map<Integer, String> computeDuplicationsPerLine(List<List<Block>> duplicationGroups) { - Map<Integer, String> result = new HashMap<Integer, String>(); + Map<Integer, String> result = new HashMap<>(); if (duplicationGroups.isEmpty()) { return result; } - Map<Integer, StringBuilder> dupPerLine = new HashMap<Integer, StringBuilder>(); + Map<Integer, StringBuilder> dupPerLine = new HashMap<>(); int blockId = 1; for (List<Block> group : duplicationGroups) { Block originBlock = group.get(0); diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/NewIndex.java b/server/sonar-server/src/main/java/org/sonar/server/es/NewIndex.java index b5768fdec3d..e8b8bc7517e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/NewIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/NewIndex.java @@ -53,8 +53,8 @@ public class NewIndex { public static class NewIndexType { private final String name; - private final Map<String, Object> attributes = new TreeMap<String, Object>(); - private final Map<String, Object> properties = new TreeMap<String, Object>(); + private final Map<String, Object> attributes = new TreeMap<>(); + private final Map<String, Object> properties = new TreeMap<>(); private NewIndexType(String typeName) { this.name = typeName; @@ -278,7 +278,7 @@ public class NewIndex { private final String indexName; private final ImmutableSettings.Builder settings = DefaultIndexSettings.defaults(); - private final SortedMap<String, NewIndexType> types = new TreeMap<String, NewIndexType>(); + private final SortedMap<String, NewIndexType> types = new TreeMap<>(); NewIndex(String indexName) { Preconditions.checkArgument(StringUtils.isAllLowerCase(indexName), "Index name must be lower-case: " + indexName); diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueBulkChangeQuery.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueBulkChangeQuery.java index 2dff217866e..69322f4a9fb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueBulkChangeQuery.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueBulkChangeQuery.java @@ -49,7 +49,7 @@ public class IssueBulkChangeQuery { private boolean hasComment; private boolean sendNotifications; - Map<String, Map<String, Object>> propertiesByActions = new HashMap<String, Map<String, Object>>(); + Map<String, Map<String, Object>> propertiesByActions = new HashMap<>(); public IssueBulkChangeQuery(Map<String, Object> props, String comment, boolean sendNotifications) { this.sendNotifications = sendNotifications; diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java index 3f5489fccbf..206c3bc8a89 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java @@ -135,7 +135,7 @@ public class IssueService { return Collections.emptyList(); } List<Transition> outTransitions = workflow.outTransitions(issue); - List<Transition> allowedTransitions = new ArrayList<Transition>(); + List<Transition> allowedTransitions = new ArrayList<>(); for (Transition transition : outTransitions) { String projectUuid = issue.projectUuid(); if (StringUtils.isBlank(transition.requiredProjectPermission()) || diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/Result.java b/server/sonar-server/src/main/java/org/sonar/server/issue/Result.java index ccf2c867502..cf7bd8bfd7d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/Result.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/Result.java @@ -42,7 +42,7 @@ public class Result<T> { } public static <T> Result<T> of() { - return new Result<T>(null); + return new Result<>(null); } public Result<T> set(@Nullable T object) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java index e7710b9019b..4d3f4ffa201 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java @@ -69,7 +69,7 @@ public class QProfileExporters { } public List<ProfileExporter> exportersForLanguage(String language) { - List<ProfileExporter> result = new ArrayList<ProfileExporter>(); + List<ProfileExporter> result = new ArrayList<>(); for (ProfileExporter exporter : exporters) { if (exporter.getSupportedLanguages() == null || exporter.getSupportedLanguages().length == 0 || ArrayUtils.contains(exporter.getSupportedLanguages(), language)) { result.add(exporter); @@ -127,7 +127,7 @@ public class QProfileExporters { * Used by rails */ public List<ProfileImporter> findProfileImportersForLanguage(String language) { - List<ProfileImporter> result = new ArrayList<ProfileImporter>(); + List<ProfileImporter> result = new ArrayList<>(); for (ProfileImporter importer : importers) { if (importer.getSupportedLanguages() == null || importer.getSupportedLanguages().length == 0 || ArrayUtils.contains(importer.getSupportedLanguages(), language)) { result.add(importer); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLoader.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLoader.java index 6670519ec30..38a652bead9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLoader.java @@ -107,7 +107,7 @@ public class QProfileLoader { } public Map<String, Long> countAllActiveRules() { - Map<String, Long> counts = new HashMap<String, Long>(); + Map<String, Long> counts = new HashMap<>(); for (Map.Entry<String, Long> entry : index.get(ActiveRuleIndex.class).countAllByQualityProfileKey().entrySet()) { counts.put(entry.getKey(), entry.getValue()); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java index 98e708ec3f1..56ab441ac67 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java @@ -218,7 +218,7 @@ public class QProfileService { DbSession session = db.openSession(false); try { SearchResponse response = activityIndex.doSearch(query, options); - Result<QProfileActivity> result = new Result<QProfileActivity>(response); + Result<QProfileActivity> result = new Result<>(response); for (SearchHit hit : response.getHits().getHits()) { QProfileActivity profileActivity = new QProfileActivity(hit.getSource()); RuleDto ruleDto = db.ruleDao().getNullableByKey(session, profileActivity.ruleKey()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java index 66048c8ba45..239e0e7b753 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleDoc.java @@ -88,7 +88,7 @@ public class ActiveRuleDoc extends BaseDoc implements ActiveRule { @Override public Map<String, String> params() { - Map<String, String> params = new HashMap<String, String>(); + Map<String, String> params = new HashMap<>(); List<Map<String, String>> allParams = getNullableField(ActiveRuleNormalizer.ActiveRuleField.PARAMS.field()); if (allParams != null) { for (Map<String, String> param : allParams) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndex.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndex.java index ff5892613e6..b2af81656a8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndex.java @@ -64,14 +64,14 @@ public class ActiveRuleIndex extends BaseIndex<ActiveRule, ActiveRuleDto, Active @Override protected Map mapKey() { - Map<String, Object> mapping = new HashMap<String, Object>(); + Map<String, Object> mapping = new HashMap<>(); mapping.put("path", ActiveRuleNormalizer.ActiveRuleField.KEY.field()); return mapping; } @Override protected Map mapProperties() { - Map<String, Object> mapping = new HashMap<String, Object>(); + Map<String, Object> mapping = new HashMap<>(); for (IndexField field : ActiveRuleNormalizer.ActiveRuleField.ALL_FIELDS) { mapping.put(field.field(), mapField(field)); } @@ -80,7 +80,7 @@ public class ActiveRuleIndex extends BaseIndex<ActiveRule, ActiveRuleDto, Active @Override protected Map mapDomain() { - Map<String, Object> mapping = new HashMap<String, Object>(); + Map<String, Object> mapping = new HashMap<>(); mapping.put("dynamic", false); mapping.put("_id", mapKey()); mapping.put("_parent", mapParent()); @@ -90,14 +90,14 @@ public class ActiveRuleIndex extends BaseIndex<ActiveRule, ActiveRuleDto, Active } private Map mapRouting() { - Map<String, Object> mapping = new HashMap<String, Object>(); + Map<String, Object> mapping = new HashMap<>(); mapping.put("required", true); mapping.put("path", ActiveRuleNormalizer.ActiveRuleField.RULE_KEY.field()); return mapping; } private Object mapParent() { - Map<String, Object> mapping = new HashMap<String, Object>(); + Map<String, Object> mapping = new HashMap<>(); mapping.put("type", this.getParentType()); return mapping; } @@ -123,7 +123,7 @@ public class ActiveRuleIndex extends BaseIndex<ActiveRule, ActiveRuleDto, Active SearchResponse response = request.get(); - List<ActiveRule> activeRules = new ArrayList<ActiveRule>(); + List<ActiveRule> activeRules = new ArrayList<>(); for (SearchHit hit : response.getHits()) { activeRules.add(toDoc(hit.getSource())); } @@ -185,7 +185,7 @@ public class ActiveRuleIndex extends BaseIndex<ActiveRule, ActiveRuleDto, Active .setSize(0) .setTypes(this.getIndexType()); SearchResponse response = request.get(); - Map<String, Multimap<String, FacetValue>> stats = new HashMap<String, Multimap<String, FacetValue>>(); + Map<String, Multimap<String, FacetValue>> stats = new HashMap<>(); Aggregation aggregation = response.getAggregations().get(ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY.field()); for (Terms.Bucket value : ((Terms) aggregation).getBuckets()) { stats.put(value.getKey() diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java index 335991d4448..93a4f525049 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java @@ -74,12 +74,12 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu @Override public List<UpdateRequest> normalize(ActiveRuleDto activeRuleDto) { - List<UpdateRequest> requests = new ArrayList<UpdateRequest>(); + List<UpdateRequest> requests = new ArrayList<>(); ActiveRuleKey key = activeRuleDto.getKey(); Preconditions.checkArgument(key != null, "Cannot normalize ActiveRuleDto with null key"); - Map<String, Object> newRule = new HashMap<String, Object>(); + Map<String, Object> newRule = new HashMap<>(); newRule.put("_parent", key.ruleKey().toString()); newRule.put(ActiveRuleField.RULE_KEY.field(), key.ruleKey().toString()); newRule.put(ActiveRuleField.KEY.field(), key.toString()); @@ -157,7 +157,7 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu private List<UpdateRequest> nestedUpdate(ActiveRuleParamDto param, ActiveRuleKey key) { Preconditions.checkArgument(key != null, "Cannot normalize ActiveRuleParamDto for null key of ActiveRule"); - Map<String, Object> newParam = new HashMap<String, Object>(); + Map<String, Object> newParam = new HashMap<>(); newParam.put(ActiveRuleParamField.NAME.field(), param.getKey()); newParam.put(ActiveRuleParamField.VALUE.field(), param.getValue()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileChangelogAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileChangelogAction.java index 50d9ed6c4d9..04f2b73385b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileChangelogAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileChangelogAction.java @@ -117,7 +117,7 @@ public class QProfileChangelogAction implements BaseQProfileWsAction { DbSession session = dbClient.openSession(false); try { SearchResponse response = activityIndex.doSearch(query, options); - Result<QProfileActivity> result = new Result<QProfileActivity>(response); + Result<QProfileActivity> result = new Result<>(response); for (SearchHit hit : response.getHits().getHits()) { QProfileActivity profileActivity = new QProfileActivity(hit.getSource()); RuleDto ruleDto = dbClient.ruleDao().getNullableByKey(session, profileActivity.ruleKey()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java index 674e9cade10..d17ef7ef29b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java @@ -144,7 +144,7 @@ public class RegisterRules implements Startable { } private Map<RuleKey, RuleDto> loadRules(DbSession session) { - Map<RuleKey, RuleDto> rules = new HashMap<RuleKey, RuleDto>(); + Map<RuleKey, RuleDto> rules = new HashMap<>(); for (RuleDto rule : dbClient.ruleDao().findByNonManual(session)) { rules.put(rule.getKey(), rule); } @@ -152,7 +152,7 @@ public class RegisterRules implements Startable { } private Map<String, CharacteristicDto> loadCharacteristics(DbSession session) { - Map<String, CharacteristicDto> characteristics = new HashMap<String, CharacteristicDto>(); + Map<String, CharacteristicDto> characteristics = new HashMap<>(); for (CharacteristicDto characteristicDto : characteristicDao.selectEnabledCharacteristics(session)) { characteristics.put(characteristicDto.getKey(), characteristicDto); } @@ -182,7 +182,7 @@ public class RegisterRules implements Startable { } private List<RulesDefinition.ExtendedRepository> getRepositories(RulesDefinition.Context context) { - List<RulesDefinition.ExtendedRepository> repositories = new ArrayList<RulesDefinition.ExtendedRepository>(); + List<RulesDefinition.ExtendedRepository> repositories = new ArrayList<>(); for (RulesDefinition.Repository repoDef : context.repositories()) { repositories.add(repoDef); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleDoc.java b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleDoc.java index 3c9de11535b..c1f90ed185e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleDoc.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleDoc.java @@ -141,7 +141,7 @@ public class RuleDoc extends BaseDoc implements Rule { @Override public List<RuleParam> params() { - List<RuleParam> params = new ArrayList<RuleParam>(); + List<RuleParam> params = new ArrayList<>(); final List<Map<String, Object>> esParams = getNullableField(RuleNormalizer.RuleField.PARAMS.field()); if (esParams != null) { for (final Map<String, Object> esParam : esParams) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java index 2eaa52be492..4562695bb3b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java @@ -99,14 +99,14 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { @Override protected Map mapKey() { - Map<String, Object> mapping = new HashMap<String, Object>(); + Map<String, Object> mapping = new HashMap<>(); mapping.put("path", RuleNormalizer.RuleField.KEY.field()); return mapping; } @Override protected Map mapProperties() { - Map<String, Object> mapping = new HashMap<String, Object>(); + Map<String, Object> mapping = new HashMap<>(); for (IndexField field : RuleNormalizer.RuleField.ALL_FIELDS) { mapping.put(field.field(), mapField(field)); } @@ -115,7 +115,7 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { private void setFields(QueryContext options, SearchRequestBuilder esSearch) { /* integrate Option's Fields */ - Set<String> fields = new HashSet<String>(); + Set<String> fields = new HashSet<>(); if (!options.getFieldsToReturn().isEmpty()) { for (String fieldToReturn : options.getFieldsToReturn()) { if (!fieldToReturn.isEmpty()) { @@ -210,7 +210,7 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { /* Build main filter (match based) */ protected Map<String, FilterBuilder> getFilters(RuleQuery query, QueryContext options) { - Map<String, FilterBuilder> filters = new HashMap<String, FilterBuilder>(); + Map<String, FilterBuilder> filters = new HashMap<>(); /* Add enforced filter on rules that are REMOVED */ filters.put(RuleNormalizer.RuleField.STATUS.field(), @@ -300,7 +300,7 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { Collection<RuleStatus> statusValues = query.getStatuses(); if (statusValues != null && !statusValues.isEmpty()) { - Collection<String> stringStatus = new ArrayList<String>(); + Collection<String> stringStatus = new ArrayList<>(); for (RuleStatus status : statusValues) { stringStatus.add(status.name()); } @@ -350,7 +350,7 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { } protected Map<String, AggregationBuilder> getFacets(RuleQuery query, QueryContext options, QueryBuilder queryBuilder, Map<String, FilterBuilder> filters) { - Map<String, AggregationBuilder> aggregations = new HashMap<String, AggregationBuilder>(); + Map<String, AggregationBuilder> aggregations = new HashMap<>(); StickyFacetBuilder stickyFacetBuilder = stickyFacetBuilder(queryBuilder, filters); addDefaultFacets(query, options, queryBuilder, filters, aggregations, stickyFacetBuilder); @@ -528,7 +528,7 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { esSearch.setQuery(QueryBuilders.filteredQuery(qb, fb)); SearchResponse esResult = esSearch.get(); - return new Result<Rule>(this, esResult); + return new Result<>(this, esResult); } @Override @@ -542,7 +542,7 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { } public Set<String> terms(String fields, @Nullable String query, int size) { - Set<String> tags = new HashSet<String>(); + Set<String> tags = new HashSet<>(); String key = "_ref"; TermsBuilder terms = AggregationBuilders.terms(key) diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java index a9d5d828428..9452b8a62a4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java @@ -136,13 +136,13 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { @Override public List<UpdateRequest> normalize(RuleDto rule) { - List<UpdateRequest> requests = new ArrayList<UpdateRequest>(); + List<UpdateRequest> requests = new ArrayList<>(); DbSession session = db.openSession(false); try { /** Update Fields */ - Map<String, Object> update = new HashMap<String, Object>(); + Map<String, Object> update = new HashMap<>(); update.put(RuleField.ID.field(), rule.getId()); @@ -314,7 +314,7 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { } private List<UpdateRequest> nestedUpdate(RuleParamDto param, RuleKey key) { - Map<String, Object> newParam = new HashMap<String, Object>(); + Map<String, Object> newParam = new HashMap<>(); newParam.put(RuleParamField.NAME.field(), param.getName()); newParam.put(RuleParamField.TYPE.field(), param.getType()); newParam.put(RuleParamField.DESCRIPTION.field(), param.getDescription()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java b/server/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java index 65d82a82998..3b2c1cdc0c6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java @@ -234,7 +234,7 @@ public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serial protected abstract Map mapKey(); protected Map mapDomain() { - Map<String, Object> mapping = new HashMap<String, Object>(); + Map<String, Object> mapping = new HashMap<>(); mapping.put("dynamic", false); mapping.put("_all", ImmutableMap.of("enabled", false)); if (mapKey() != null) { @@ -297,10 +297,10 @@ public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serial } protected Map mapNestedField(IndexField field) { - Map<String, Object> mapping = new HashMap<String, Object>(); + Map<String, Object> mapping = new HashMap<>(); mapping.put("type", "nested"); mapping.put("dynamic", "true"); - Map<String, Object> mappings = new HashMap<String, Object>(); + Map<String, Object> mappings = new HashMap<>(); for (IndexField nestedField : field.nestedFields()) { if (nestedField != null) { mappings.put(nestedField.field(), mapField(nestedField)); @@ -339,7 +339,7 @@ public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serial } protected Map mapMultiField(IndexField field) { - Map<String, Object> mapping = new HashMap<String, Object>(); + Map<String, Object> mapping = new HashMap<>(); if (field.isSortable()) { mapping.put(IndexField.SORT_SUFFIX, ImmutableMap.of( "type", "string", @@ -357,7 +357,7 @@ public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serial } protected Map mapStringField(IndexField field, boolean allowRecursive) { - Map<String, Object> mapping = new HashMap<String, Object>(); + Map<String, Object> mapping = new HashMap<>(); // check if the field needs to be MultiField if (allowRecursive && needMultiField(field)) { mapping.put("type", "multi_field"); @@ -372,7 +372,7 @@ public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serial } protected Map mapTextField(IndexField field, boolean allowRecursive) { - Map<String, Object> mapping = new HashMap<String, Object>(); + Map<String, Object> mapping = new HashMap<>(); // check if the field needs to be MultiField if (allowRecursive && needMultiField(field)) { mapping.put("type", "multi_field"); @@ -420,7 +420,7 @@ public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serial if (keys.isEmpty()) { return Collections.emptyList(); } - List<DOMAIN> results = new ArrayList<DOMAIN>(); + List<DOMAIN> results = new ArrayList<>(); MultiGetRequestBuilder request = client.prepareMultiGet() .setPreference("_local"); for (KEY key : keys) { @@ -474,7 +474,7 @@ public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serial } public Map<String, Long> countByField(IndexField indexField, FilterBuilder filter) { - Map<String, Long> counts = new HashMap<String, Long>(); + Map<String, Long> counts = new HashMap<>(); SearchRequestBuilder request = client.prepareSearch(this.getIndexName()) .setTypes(this.getIndexType()) diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/BaseNormalizer.java b/server/sonar-server/src/main/java/org/sonar/server/search/BaseNormalizer.java index 5d9b819bfca..34b412fedcd 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/BaseNormalizer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/BaseNormalizer.java @@ -41,7 +41,7 @@ public abstract class BaseNormalizer<DTO extends Dto<KEY>, KEY extends Serializa } protected Map<String, Object> getUpsertFor(Set<IndexField> fields, Map<String, Object> update) { - Map<String, Object> upsert = new HashMap<String, Object>(update); + Map<String, Object> upsert = new HashMap<>(update); for (IndexField field : fields) { if (!upsert.containsKey(field.field())) { if (field.type().equals(IndexField.Type.OBJECT)) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/Facets.java b/server/sonar-server/src/main/java/org/sonar/server/search/Facets.java index 7f94bd314f5..d8441db4679 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/Facets.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/Facets.java @@ -112,7 +112,7 @@ class Facets { } public List<String> getFacetKeys(String facetName) { - List<String> keys = new ArrayList<String>(); + List<String> keys = new ArrayList<>(); if (this.facetValues.containsKey(facetName)) { for (FacetValue facetValue : facetValues.get(facetName)) { keys.add(facetValue.getKey()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/IndexClient.java b/server/sonar-server/src/main/java/org/sonar/server/search/IndexClient.java index 89a2b3d40d2..882b5af4c60 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/IndexClient.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/IndexClient.java @@ -35,7 +35,7 @@ public class IndexClient { public IndexClient(Index<?, ?, ?>... indexComponents) { - this.indexComponents = new HashMap<Class<?>, Index<?, ?, ?>>(); + this.indexComponents = new HashMap<>(); for (Index<?, ?, ?> indexComponent : indexComponents) { this.indexComponents.put(indexComponent.getClass(), indexComponent); diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/IndexQueue.java b/server/sonar-server/src/main/java/org/sonar/server/search/IndexQueue.java index 9d244062923..441569fbdb6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/IndexQueue.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/IndexQueue.java @@ -68,7 +68,7 @@ public class IndexQueue implements WorkQueue<IndexAction<?>> { boolean refreshRequired = false; Map<String, Index> indexes = getIndexMap(); - Set<String> indices = new HashSet<String>(); + Set<String> indices = new HashSet<>(); for (IndexAction action : actions) { Index index = indexes.get(action.getIndexType()); action.setIndex(index); @@ -139,7 +139,7 @@ public class IndexQueue implements WorkQueue<IndexAction<?>> { } private Map<String, Index> getIndexMap() { - Map<String, Index> indexes = new HashMap<String, Index>(); + Map<String, Index> indexes = new HashMap<>(); for (Index index : container.getComponentsByType(Index.class)) { indexes.put(index.getIndexType(), index); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/Result.java b/server/sonar-server/src/main/java/org/sonar/server/search/Result.java index 55b6faa6e73..ee2901cdf7a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/Result.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/Result.java @@ -46,7 +46,7 @@ public class Result<K> { this.scrollId = response.getScrollId(); this.facets = new Facets(response); this.total = (int) response.getHits().totalHits(); - this.hits = new ArrayList<K>(); + this.hits = new ArrayList<>(); if (index != null) { for (SearchHit hit : response.getHits()) { this.hits.add(index.toDoc(hit.getSource())); diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteKey.java b/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteKey.java index da01dd568c4..4c2b53ac05c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteKey.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteKey.java @@ -43,7 +43,7 @@ public class DeleteKey<K extends Serializable> extends IndexAction<DeleteRequest @Override public List<DeleteRequest> doCall(Index index) { - List<DeleteRequest> requests = new ArrayList<DeleteRequest>(); + List<DeleteRequest> requests = new ArrayList<>(); requests.add(Requests.deleteRequest(index.getIndexName()) .id(getKey()) .type(indexType) diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteNestedItem.java b/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteNestedItem.java index cebe2828083..4b7453f3238 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteNestedItem.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/action/DeleteNestedItem.java @@ -46,7 +46,7 @@ public class DeleteNestedItem<K extends Serializable> extends IndexAction<Update @Override public List<UpdateRequest> doCall(Index index) { - List<UpdateRequest> updates = new ArrayList<UpdateRequest>(); + List<UpdateRequest> updates = new ArrayList<>(); updates.addAll(deleteItem(index, item, key)); for (Object otherItem : items) { updates.addAll(deleteItem(index, otherItem, key)); diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/action/InsertDto.java b/server/sonar-server/src/main/java/org/sonar/server/search/action/InsertDto.java index 467272b2cb2..45576708131 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/action/InsertDto.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/action/InsertDto.java @@ -43,7 +43,7 @@ public class InsertDto<DTO extends Dto> extends IndexAction<ActionRequest> { @Override public List<ActionRequest> doCall(Index index) { - List<ActionRequest> inserts = new ArrayList<ActionRequest>(); + List<ActionRequest> inserts = new ArrayList<>(); List<UpdateRequest> updates = index.getNormalizer().normalize(dto); for (UpdateRequest update : updates) { if (update.doc() != null) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/action/UpsertNestedItem.java b/server/sonar-server/src/main/java/org/sonar/server/search/action/UpsertNestedItem.java index a1029e39136..fcf3a6ac36e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/action/UpsertNestedItem.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/action/UpsertNestedItem.java @@ -46,7 +46,7 @@ public class UpsertNestedItem<K extends Serializable> extends IndexAction<Update @Override public List<UpdateRequest> doCall(Index index) { - List<UpdateRequest> updates = new ArrayList<UpdateRequest>(); + List<UpdateRequest> updates = new ArrayList<>(); updates.addAll(normalizeItem(index, item, key)); for (Object otherItem : items) { updates.addAll(normalizeItem(index, otherItem, key)); diff --git a/server/sonar-server/src/main/java/org/sonar/server/source/CharactersReader.java b/server/sonar-server/src/main/java/org/sonar/server/source/CharactersReader.java index fcb680afe28..457b460705c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/source/CharactersReader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/source/CharactersReader.java @@ -40,7 +40,7 @@ class CharactersReader { public CharactersReader(BufferedReader stringBuffer) { this.stringBuffer = stringBuffer; - this.openTags = new ArrayDeque<String>(); + this.openTags = new ArrayDeque<>(); } boolean readNextChar() throws IOException { diff --git a/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/BarChartTest.java b/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/BarChartTest.java index 14c60232171..bb756359466 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/BarChartTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/BarChartTest.java @@ -110,7 +110,7 @@ public class BarChartTest extends BaseChartWebTest { @Test public void testStackedBarCharteightyTwenty() throws IOException { - Map<String, String> params = new HashMap<String, String>(); + Map<String, String> params = new HashMap<>(); params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.STACKED_BAR_CHART); params.put(BaseChartWeb.CHART_PARAM_VALUES, "80,20"); BarChart chart = new BarChart(params); @@ -121,7 +121,7 @@ public class BarChartTest extends BaseChartWebTest { @Test public void testStackedBarChartfiftyFifty() throws IOException { - Map<String, String> params = new HashMap<String, String>(); + Map<String, String> params = new HashMap<>(); params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.STACKED_BAR_CHART); params.put(BaseChartWeb.CHART_PARAM_VALUES, "50,50"); BarChart chart = new BarChart(params); @@ -131,7 +131,7 @@ public class BarChartTest extends BaseChartWebTest { } private Map<String, String> getDefaultParams() { - Map<String, String> params = new HashMap<String, String>(); + Map<String, String> params = new HashMap<>(); params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.BAR_CHART_HORIZONTAL); params.put(BaseChartWeb.CHART_PARAM_VALUES, "100,50"); return params; diff --git a/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/CustomBarChartTest.java b/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/CustomBarChartTest.java index 3ba7eacc440..2046beb7043 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/CustomBarChartTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/CustomBarChartTest.java @@ -30,7 +30,7 @@ public class CustomBarChartTest extends BaseChartWebTest { @Test public void testEmptyParameters() throws IOException { - Map<String, String> params = new HashMap<String, String>(); + Map<String, String> params = new HashMap<>(); CustomBarChart chart = new CustomBarChart(params); BufferedImage img = chart.getChartImage(); saveChart(img, "custom-horizontal-bar-chart-empty.png"); @@ -81,7 +81,7 @@ public class CustomBarChartTest extends BaseChartWebTest { } private Map<String, String> getDefaultParams() { - Map<String, String> params = new HashMap<String, String>(); + Map<String, String> params = new HashMap<>(); params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.BAR_CHART_HORIZONTAL); params.put(BaseChartWeb.CHART_PARAM_VALUES, "100,50"); return params; diff --git a/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/PieChartTest.java b/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/PieChartTest.java index 863d2e7f7fe..afaf2ba6710 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/PieChartTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/PieChartTest.java @@ -99,7 +99,7 @@ public class PieChartTest extends BaseChartWebTest { } private Map<String, String> getDefaultParams() { - Map<String, String> params = new HashMap<String, String>(); + Map<String, String> params = new HashMap<>(); params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.PIE_CHART); params.put(BaseChartWeb.CHART_PARAM_VALUES, "100,50"); params.put(BaseChartWeb.CHART_PARAM_DIMENSIONS, "50x50"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/SparkLinesChartTest.java b/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/SparkLinesChartTest.java index 2ebee6fde29..15ddb7878bd 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/SparkLinesChartTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/charts/deprecated/SparkLinesChartTest.java @@ -110,7 +110,7 @@ public class SparkLinesChartTest extends BaseChartWebTest { } private Map<String, String> getDefaultParams() { - Map<String, String> params = new HashMap<String, String>(); + Map<String, String> params = new HashMap<>(); params.put(BaseChartWeb.CHART_PARAM_TYPE, BaseChartWeb.SPARKLINES_CHART); params.put(BaseChartWeb.CHART_PARAM_VALUES, "1,1,2,4,3,3,4,5,5,5,6,7,7,7,8,8"); return params; diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/BaseDataChangeTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/BaseDataChangeTest.java index 339a8b6672d..38e9edd51d6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/BaseDataChangeTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/BaseDataChangeTest.java @@ -78,7 +78,7 @@ public class BaseDataChangeTest extends AbstractDaoTestCase { public void read_column_types() throws Exception { db.prepareDbUnit(getClass(), "persons.xml"); - final List<Object[]> persons = new ArrayList<Object[]>(); + final List<Object[]> persons = new ArrayList<>(); new BaseDataChange(db.database()) { @Override public void execute(Context context) throws SQLException { @@ -100,7 +100,7 @@ public class BaseDataChangeTest extends AbstractDaoTestCase { public void parameterized_query() throws Exception { db.prepareDbUnit(getClass(), "persons.xml"); - final List<Long> ids = new ArrayList<Long>(); + final List<Long> ids = new ArrayList<>(); new BaseDataChange(db.database()) { @Override public void execute(Context context) throws SQLException { @@ -156,7 +156,7 @@ public class BaseDataChangeTest extends AbstractDaoTestCase { public void bad_parameterized_query() throws Exception { db.prepareDbUnit(getClass(), "persons.xml"); - final List<Long> ids = new ArrayList<Long>(); + final List<Long> ids = new ArrayList<>(); BaseDataChange change = new BaseDataChange(db.database()) { @Override public void execute(Context context) throws SQLException { @@ -174,7 +174,7 @@ public class BaseDataChangeTest extends AbstractDaoTestCase { public void scroll() throws Exception { db.prepareDbUnit(getClass(), "persons.xml"); - final List<Long> ids = new ArrayList<Long>(); + final List<Long> ids = new ArrayList<>(); new BaseDataChange(db.database()) { @Override public void execute(Context context) throws SQLException { @@ -435,7 +435,7 @@ public class BaseDataChangeTest extends AbstractDaoTestCase { public void read_not_null_fields() throws Exception { db.prepareDbUnit(getClass(), "persons.xml"); - final List<Object[]> persons = new ArrayList<Object[]>(); + final List<Object[]> persons = new ArrayList<>(); new BaseDataChange(db.database()) { @Override public void execute(Context context) throws SQLException { diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyPutMappingRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyPutMappingRequestBuilderTest.java index e9639abe0c0..3cf9f9e373f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyPutMappingRequestBuilderTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyPutMappingRequestBuilderTest.java @@ -117,7 +117,7 @@ public class ProxyPutMappingRequestBuilderTest { } protected static Map mapDomain() { - Map<String, Object> mapping = new HashMap<String, Object>(); + Map<String, Object> mapping = new HashMap<>(); mapping.put("dynamic", false); mapping.put("_all", ImmutableMap.of("enabled", false)); return mapping; diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java index a518646c6f9..a9793c9a594 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java @@ -1093,7 +1093,7 @@ public class RuleIndexMediumTest { @Test public void scroll_byIds() { - Set<Integer> ids = new HashSet<Integer>(); + Set<Integer> ids = new HashSet<>(); for (int i = 0; i < 150; i++) { RuleDto rule = RuleTesting.newDto(RuleKey.of("scroll", "r_" + i)); dao.insert(dbSession, rule); diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/action/DeleteKeyTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/action/DeleteKeyTest.java index 13a654ce7f5..d04d991ae25 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/search/action/DeleteKeyTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/search/action/DeleteKeyTest.java @@ -47,7 +47,7 @@ public class DeleteKeyTest { @Test public void get_delete_request() { String key = "test_key"; - DeleteKey<String> deleteAction = new DeleteKey<String>(TEST_INDEX.getIndexType(), key); + DeleteKey<String> deleteAction = new DeleteKey<>(TEST_INDEX.getIndexType(), key); try { deleteAction.call(); diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java index bd97afb9ad4..498a4c00cc5 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java @@ -199,7 +199,7 @@ public class SonarClient { throw new IllegalArgumentException(String.format( "Expecting even number of elements. Got %s", Arrays.toString(params))); } - Map<String, Object> map = new HashMap<String, Object>(); + Map<String, Object> map = new HashMap<>(); for (int index = 0; index < params.length; index++) { if (params[index] == null) { throw new IllegalArgumentException(String.format( diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/EncodingUtils.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/EncodingUtils.java index 8516b293634..31110650d8f 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/EncodingUtils.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/EncodingUtils.java @@ -40,7 +40,7 @@ public class EncodingUtils { if (array.length%2==1) { throw new IllegalArgumentException("Not an even number of arguments"); } - Map<String, Object> map = new LinkedHashMap<String, Object>(); + Map<String, Object> map = new LinkedHashMap<>(); for (int i = 0; i < array.length; i += 2) { Object value = array[i + 1]; if (value != null) { diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/ActionPlanQuery.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/ActionPlanQuery.java index 8a2db776250..b4a35dcdd22 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/ActionPlanQuery.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/ActionPlanQuery.java @@ -29,7 +29,7 @@ public class ActionPlanQuery { public static final String BASE_URL = "/api/action_plans/search"; - private final Map<String, Object> params = new HashMap<String, Object>(); + private final Map<String, Object> params = new HashMap<>(); private ActionPlanQuery() { } diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/BulkChangeQuery.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/BulkChangeQuery.java index db43ec72c54..1e9955fe43b 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/BulkChangeQuery.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/BulkChangeQuery.java @@ -29,7 +29,7 @@ import java.util.Map; */ public class BulkChangeQuery { - private final Map<String, Object> params = new HashMap<String, Object>(); + private final Map<String, Object> params = new HashMap<>(); private BulkChangeQuery() { } diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueQuery.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueQuery.java index b9ffe11ea50..ba8878cb5f9 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueQuery.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueQuery.java @@ -30,7 +30,7 @@ import java.util.Map; */ public class IssueQuery { - private final Map<String, Object> params = new HashMap<String, Object>(); + private final Map<String, Object> params = new HashMap<>(); private IssueQuery() { } diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewActionPlan.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewActionPlan.java index 015efe48e53..b25476ff656 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewActionPlan.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewActionPlan.java @@ -30,7 +30,7 @@ import java.util.Map; */ public class NewActionPlan { - private final Map<String, Object> params = new HashMap<String, Object>(); + private final Map<String, Object> params = new HashMap<>(); private NewActionPlan() { } diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewIssue.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewIssue.java index 6e8dcb441ec..2eab384d225 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewIssue.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewIssue.java @@ -28,7 +28,7 @@ import java.util.Map; */ public class NewIssue { - private final Map<String, Object> params = new HashMap<String, Object>(); + private final Map<String, Object> params = new HashMap<>(); private NewIssue() { } diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/UpdateActionPlan.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/UpdateActionPlan.java index 506132892de..80bf4ece77f 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/UpdateActionPlan.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/UpdateActionPlan.java @@ -30,7 +30,7 @@ import java.util.Map; */ public class UpdateActionPlan { - private final Map<String, Object> params = new HashMap<String, Object>(); + private final Map<String, Object> params = new HashMap<>(); private UpdateActionPlan() { } diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultActionPlanClient.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultActionPlanClient.java index a9bbd61d3f3..6820982c250 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultActionPlanClient.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultActionPlanClient.java @@ -45,7 +45,7 @@ public class DefaultActionPlanClient implements ActionPlanClient { @Override public List<ActionPlan> find(String projectKey) { String json = requestFactory.get(ActionPlanQuery.BASE_URL, EncodingUtils.toMap("project", projectKey)); - List<ActionPlan> result = new ArrayList<ActionPlan>(); + List<ActionPlan> result = new ArrayList<>(); Map jsonRoot = (Map) JSONValue.parse(json); List<Map> jsonActionPlans = (List<Map>) jsonRoot.get("actionPlans"); if (jsonActionPlans != null) { diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultBulkChange.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultBulkChange.java index 62f9c9562c7..9e51a565b14 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultBulkChange.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultBulkChange.java @@ -34,7 +34,7 @@ public class DefaultBulkChange implements BulkChange { private Integer totalIssuesChanged; private Integer totalIssuesNotChanged; - private final List<String> issuesNotChangedKeys = new ArrayList<String>(); + private final List<String> issuesNotChangedKeys = new ArrayList<>(); @Override public List<String> issuesNotChangedKeys() { diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssue.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssue.java index 4492c919ab5..7bbc8f8ee5f 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssue.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssue.java @@ -169,7 +169,7 @@ public class DefaultIssue implements Issue { */ @Override public List<IssueComment> comments() { - List<IssueComment> comments = new ArrayList<IssueComment>(); + List<IssueComment> comments = new ArrayList<>(); List<Map> jsonComments = (List<Map>) json.get("comments"); if (jsonComments != null) { for (Map jsonComment : jsonComments) { diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueChange.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueChange.java index b7e7ecf6626..dacd93cc17e 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueChange.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueChange.java @@ -51,7 +51,7 @@ public class DefaultIssueChange implements IssueChange { @Override public List<IssueChangeDiff> diffs() { - List<IssueChangeDiff> diffs = new ArrayList<IssueChangeDiff>(); + List<IssueChangeDiff> diffs = new ArrayList<>(); List<Map> jsonDiffs = (List<Map>) json.get("diffs"); for (Map jsonDiff : jsonDiffs) { diffs.add(new DefaultIssueChangeDiff(jsonDiff)); diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssues.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssues.java index 5f89a1a32bd..524d7b5d678 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssues.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssues.java @@ -39,13 +39,13 @@ import java.util.Map; */ public class DefaultIssues implements Issues { - private final List<Issue> list = new ArrayList<Issue>(); - private final Map<String, Rule> rulesByKey = new HashMap<String, Rule>(); - private final Map<String, User> usersByKey = new HashMap<String, User>(); - private final Map<Long, Component> componentsById = new HashMap<Long, Component>(); - private final Map<String, Component> componentsByKey = new HashMap<String, Component>(); - private final Map<String, Component> projectsByKey = new HashMap<String, Component>(); - private final Map<String, ActionPlan> actionPlansByKey = new HashMap<String, ActionPlan>(); + private final List<Issue> list = new ArrayList<>(); + private final Map<String, Rule> rulesByKey = new HashMap<>(); + private final Map<String, User> usersByKey = new HashMap<>(); + private final Map<Long, Component> componentsById = new HashMap<>(); + private final Map<String, Component> componentsByKey = new HashMap<>(); + private final Map<String, Component> projectsByKey = new HashMap<>(); + private final Map<String, ActionPlan> actionPlansByKey = new HashMap<>(); private Paging paging; @Override diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/IssueJsonParser.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/IssueJsonParser.java index 02cad915e57..3ce006dec67 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/IssueJsonParser.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/IssueJsonParser.java @@ -111,7 +111,7 @@ public class IssueJsonParser { } List<String> parseTransitions(String json) { - List<String> transitions = new ArrayList<String>(); + List<String> transitions = new ArrayList<>(); Map jRoot = (Map) JSONValue.parse(json); List<String> jTransitions = (List<String>) jRoot.get("transitions"); for (String jTransition : jTransitions) { @@ -121,7 +121,7 @@ public class IssueJsonParser { } List<IssueChange> parseChangelog(String json) { - List<IssueChange> changes = new ArrayList<IssueChange>(); + List<IssueChange> changes = new ArrayList<>(); Map jRoot = (Map) JSONValue.parse(json); List<Map> jChanges = (List<Map>) jRoot.get("changelog"); if (jChanges != null) { @@ -133,7 +133,7 @@ public class IssueJsonParser { } List<String> parseActions(String json) { - List<String> actions = new ArrayList<String>(); + List<String> actions = new ArrayList<>(); Map jRoot = (Map) JSONValue.parse(json); List<String> jActions = (List<String>) jRoot.get("actions"); for (String jAction : jActions) { diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/PermissionParameters.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/PermissionParameters.java index 8965152a81b..dcd2dec76f7 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/PermissionParameters.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/PermissionParameters.java @@ -28,7 +28,7 @@ public class PermissionParameters { private final Map<String, Object> params; private PermissionParameters(){ - params = new HashMap<String, Object>(); + params = new HashMap<>(); } public static PermissionParameters create() { diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/project/NewProject.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/project/NewProject.java index 740ba8219c7..1aa5bff79cc 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/project/NewProject.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/project/NewProject.java @@ -30,7 +30,7 @@ public class NewProject { private final Map<String, Object> params; private NewProject() { - params = new HashMap<String, Object>(); + params = new HashMap<>(); } public static NewProject create() { diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/internal/DefaultQProfileResult.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/internal/DefaultQProfileResult.java index ca9e6237e06..3e51fa24179 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/internal/DefaultQProfileResult.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/internal/DefaultQProfileResult.java @@ -36,7 +36,7 @@ public class DefaultQProfileResult implements QProfileResult { @Override public List<String> infos() { - List<String> infos = new ArrayList<String>(); + List<String> infos = new ArrayList<>(); List<String> jsonInfos = (List<String>) json.get("infos"); if (jsonInfos != null) { for (String info : jsonInfos) { @@ -48,7 +48,7 @@ public class DefaultQProfileResult implements QProfileResult { @Override public List<String> warnings() { - List<String> warnings = new ArrayList<String>(); + List<String> warnings = new ArrayList<>(); List<String> jsonWarnings = (List<String>) json.get("warnings"); if (jsonWarnings != null) { for (String warning : jsonWarnings) { diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/NewCondition.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/NewCondition.java index 64f8ff9d7a6..da8b9b82b54 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/NewCondition.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/NewCondition.java @@ -32,7 +32,7 @@ public class NewCondition { private final Map<String, Object> params; private NewCondition() { - params = new HashMap<String, Object>(); + params = new HashMap<>(); } public static NewCondition create(long qGateId) { diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/UpdateCondition.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/UpdateCondition.java index 70fb4c6d5b5..e5fb7fc33b6 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/UpdateCondition.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/UpdateCondition.java @@ -32,7 +32,7 @@ public class UpdateCondition { private final Map<String, Object> params; private UpdateCondition() { - params = new HashMap<String, Object>(); + params = new HashMap<>(); } public static UpdateCondition create(long id) { diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGateClient.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGateClient.java index b9497d652e2..a9909d265ba 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGateClient.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGateClient.java @@ -61,7 +61,7 @@ public class DefaultQualityGateClient implements QualityGateClient { @Override public QualityGate rename(long qGateId, String qGateName) { - Map<String, Object> params = new HashMap<String, Object>(); + Map<String, Object> params = new HashMap<>(); params.put("id", qGateId); params.put("name", qGateName); String json = requestFactory.post(RENAME_URL, params); @@ -123,7 +123,7 @@ public class DefaultQualityGateClient implements QualityGateClient { } private Map<String, Object> selectionParams(long qGateId, long projectId) { - Map<String, Object> params = new HashMap<String, Object>(); + Map<String, Object> params = new HashMap<>(); params.put("gateId", Long.toString(qGateId)); params.put("projectId", Long.toString(projectId)); return params; @@ -152,7 +152,7 @@ public class DefaultQualityGateClient implements QualityGateClient { private Collection<QualityGateCondition> jsonToConditions(String json) { Map jsonRoot = (Map) JSONValue.parse(json); Collection<Map> conditionArray = (Collection<Map>) jsonRoot.get("conditions"); - Collection<QualityGateCondition> conditions = new ArrayList<QualityGateCondition>(); + Collection<QualityGateCondition> conditions = new ArrayList<>(); if (conditionArray != null) { for (Map conditionJson: conditionArray) { conditions.add(new DefaultQualityGateCondition(conditionJson)); diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGates.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGates.java index e29c5123a37..6367069401f 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGates.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGates.java @@ -38,7 +38,7 @@ public class DefaultQualityGates implements QualityGates { @SuppressWarnings("unchecked") public DefaultQualityGates(Map<String, Object> json) { - qualityGates = new LinkedHashMap<Long, QualityGate>(); + qualityGates = new LinkedHashMap<>(); JSONArray gatesJson = JsonUtils.getArray(json, "qualitygates"); if (gatesJson != null) { for (Object entry: gatesJson) { diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java index 434e5676cbb..6192dc1b84f 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java @@ -147,7 +147,7 @@ public class Measure extends Model { if (data == null) { return null; } - Map<String, String> map = new LinkedHashMap<String, String>(); + Map<String, String> map = new LinkedHashMap<>(); String[] parts = data.split(separator); for (String part : parts) { String[] kv = part.split("="); diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Profile.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Profile.java index 22077d37721..cc0437161a0 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Profile.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Profile.java @@ -34,7 +34,7 @@ public class Profile extends Model { private String name; private boolean defaultProfile; private String parentName; - private List<Rule> rules = new ArrayList<Rule>(); + private List<Rule> rules = new ArrayList<>(); @CheckForNull public String getLanguage() { @@ -153,7 +153,7 @@ public class Profile extends Model { public Rule addParameter(@Nullable String key, @Nullable String value) { if (parameters==null) { - parameters = new HashMap<String,String>(); + parameters = new HashMap<>(); } parameters.put(key, value); return this; diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Source.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Source.java index a8393c5dbbc..e27a6870fc8 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Source.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Source.java @@ -28,7 +28,7 @@ import java.util.TreeMap; public class Source extends Model { - private SortedMap<Integer, String> lines = new TreeMap<Integer, String>(); + private SortedMap<Integer, String> lines = new TreeMap<>(); public Collection<String> getLines() { return lines.values(); diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/AbstractUnmarshaller.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/AbstractUnmarshaller.java index db0918e4146..fc3254e7b72 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/AbstractUnmarshaller.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/AbstractUnmarshaller.java @@ -49,7 +49,7 @@ public abstract class AbstractUnmarshaller<M extends Model> implements Unmarshal @Override public final List<M> toModels(String json) { WSUtils utils = WSUtils.getINSTANCE(); - List<M> result = new ArrayList<M>(); + List<M> result = new ArrayList<>(); Object array = utils.parse(json); for (int i = 0; i < utils.getArraySize(array); i++) { Object elt = utils.getArrayElement(array, i); diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceSearchUnmarshaller.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceSearchUnmarshaller.java index 5fa580560b8..b907a174356 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceSearchUnmarshaller.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceSearchUnmarshaller.java @@ -40,7 +40,7 @@ public class ResourceSearchUnmarshaller extends AbstractUnmarshaller<ResourceSea result.setPageSize(utils.getInteger(json, "page_size")); result.setTotal(utils.getInteger(json, "total")); - List<ResourceSearchResult.Resource> resources = new ArrayList<ResourceSearchResult.Resource>(); + List<ResourceSearchResult.Resource> resources = new ArrayList<>(); JSONArray dataJson = JsonUtils.getArray((JSONObject) json, "data"); if (dataJson != null) { for (Object jsonResource : dataJson) { diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java index c4cbdb64d29..836d0f83d0d 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java @@ -77,7 +77,7 @@ public class ResourceUnmarshaller extends AbstractUnmarshaller<Resource> { private List<Measure> parseMeasures(Object measuresJson) { WSUtils utils = WSUtils.getINSTANCE(); - List<Measure> projectMeasures = new ArrayList<Measure>(); + List<Measure> projectMeasures = new ArrayList<>(); int len = utils.getArraySize(measuresJson); for (int i = 0; i < len; i++) { Object measureJson = utils.getArrayElement(measuresJson, i); diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserParameters.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserParameters.java index 50a2411532a..025cea9a2c6 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserParameters.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserParameters.java @@ -25,7 +25,7 @@ import java.util.Map; public class UserParameters { - private final Map<String, Object> params = new HashMap<String, Object>(); + private final Map<String, Object> params = new HashMap<>(); private UserParameters() { } diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserQuery.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserQuery.java index a77bd2f1943..2550ef713d6 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserQuery.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserQuery.java @@ -30,7 +30,7 @@ import java.util.Map; */ public class UserQuery { - private final Map<String, Object> params = new HashMap<String, Object>(); + private final Map<String, Object> params = new HashMap<>(); private UserQuery() { } diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/user/internal/DefaultUserClient.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/user/internal/DefaultUserClient.java index 2a73cd871ff..7b1af27b70b 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/user/internal/DefaultUserClient.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/user/internal/DefaultUserClient.java @@ -54,7 +54,7 @@ public class DefaultUserClient implements UserClient { @Override public List<User> find(UserQuery query) { String json = requestFactory.get(SEARCH_URL, query.urlParams()); - List<User> result = new ArrayList<User>(); + List<User> result = new ArrayList<>(); Map jsonRoot = (Map) JSONValue.parse(json); List<Map> jsonUsers = (List<Map>) jsonRoot.get("users"); if (jsonUsers != null) { @@ -83,7 +83,7 @@ public class DefaultUserClient implements UserClient { @Override public void deactivate(String login) { - Map<String, Object> params = new HashMap<String, Object>(); + Map<String, Object> params = new HashMap<>(); params.put("login", login); requestFactory.post(DEACTIVATE_URL, params); } diff --git a/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java b/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java index d9f35910a2c..d85612b74fa 100644 --- a/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java +++ b/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java @@ -59,7 +59,7 @@ public class JdbcSettings { if (!dir.exists()) { throw new MessageException("Directory does not exist: " + dirPath); } - List<File> files = new ArrayList<File>(FileUtils.listFiles(dir, new String[] {"jar"}, false)); + List<File> files = new ArrayList<>(FileUtils.listFiles(dir, new String[] {"jar"}, false)); if (files.isEmpty()) { throw new MessageException("Directory does not contain JDBC driver: " + dirPath); } diff --git a/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java b/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java index 981a8877125..b3ea11f54a4 100644 --- a/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java +++ b/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java @@ -2847,7 +2847,7 @@ public final class BatchReport { } case 56: { if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { - childRef_ = new java.util.ArrayList<java.lang.Integer>(); + childRef_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000040; } childRef_.add(input.readInt32()); @@ -2857,7 +2857,7 @@ public final class BatchReport { int length = input.readRawVarint32(); int limit = input.pushLimit(length); if (!((mutable_bitField0_ & 0x00000040) == 0x00000040) && input.getBytesUntilLimit() > 0) { - childRef_ = new java.util.ArrayList<java.lang.Integer>(); + childRef_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000040; } while (input.getBytesUntilLimit() > 0) { @@ -2879,7 +2879,7 @@ public final class BatchReport { } case 82: { if (!((mutable_bitField0_ & 0x00000080) == 0x00000080)) { - link_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.ComponentLink>(); + link_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000080; } link_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.ComponentLink.PARSER, extensionRegistry)); @@ -2887,7 +2887,7 @@ public final class BatchReport { } case 90: { if (!((mutable_bitField0_ & 0x00004000) == 0x00004000)) { - event_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Event>(); + event_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00004000; } event_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Event.PARSER, extensionRegistry)); @@ -4336,7 +4336,7 @@ public final class BatchReport { private java.util.List<java.lang.Integer> childRef_ = java.util.Collections.emptyList(); private void ensureChildRefIsMutable() { if (!((bitField0_ & 0x00000040) == 0x00000040)) { - childRef_ = new java.util.ArrayList<java.lang.Integer>(childRef_); + childRef_ = new java.util.ArrayList<>(childRef_); bitField0_ |= 0x00000040; } } @@ -4403,7 +4403,7 @@ public final class BatchReport { java.util.Collections.emptyList(); private void ensureLinkIsMutable() { if (!((bitField0_ & 0x00000080) == 0x00000080)) { - link_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.ComponentLink>(link_); + link_ = new java.util.ArrayList<>(link_); bitField0_ |= 0x00000080; } } @@ -4628,8 +4628,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.ComponentLink, org.sonar.batch.protocol.output.BatchReport.ComponentLink.Builder, org.sonar.batch.protocol.output.BatchReport.ComponentLinkOrBuilder> getLinkFieldBuilder() { if (linkBuilder_ == null) { - linkBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.ComponentLink, org.sonar.batch.protocol.output.BatchReport.ComponentLink.Builder, org.sonar.batch.protocol.output.BatchReport.ComponentLinkOrBuilder>( + linkBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( link_, ((bitField0_ & 0x00000080) == 0x00000080), getParentForChildren(), @@ -5047,7 +5046,7 @@ public final class BatchReport { java.util.Collections.emptyList(); private void ensureEventIsMutable() { if (!((bitField0_ & 0x00004000) == 0x00004000)) { - event_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Event>(event_); + event_ = new java.util.ArrayList<>(event_); bitField0_ |= 0x00004000; } } @@ -5272,8 +5271,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.Event, org.sonar.batch.protocol.output.BatchReport.Event.Builder, org.sonar.batch.protocol.output.BatchReport.EventOrBuilder> getEventFieldBuilder() { if (eventBuilder_ == null) { - eventBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Event, org.sonar.batch.protocol.output.BatchReport.Event.Builder, org.sonar.batch.protocol.output.BatchReport.EventOrBuilder>( + eventBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( event_, ((bitField0_ & 0x00004000) == 0x00004000), getParentForChildren(), @@ -7763,7 +7761,7 @@ public final class BatchReport { } case 18: { if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - measure_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Measure>(); + measure_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000002; } measure_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Measure.PARSER, extensionRegistry)); @@ -8177,7 +8175,7 @@ public final class BatchReport { java.util.Collections.emptyList(); private void ensureMeasureIsMutable() { if (!((bitField0_ & 0x00000002) == 0x00000002)) { - measure_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Measure>(measure_); + measure_ = new java.util.ArrayList<>(measure_); bitField0_ |= 0x00000002; } } @@ -8402,8 +8400,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.Measure, org.sonar.batch.protocol.output.BatchReport.Measure.Builder, org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder> getMeasureFieldBuilder() { if (measureBuilder_ == null) { - measureBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Measure, org.sonar.batch.protocol.output.BatchReport.Measure.Builder, org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder>( + measureBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( measure_, ((bitField0_ & 0x00000002) == 0x00000002), getParentForChildren(), @@ -12066,7 +12063,7 @@ public final class BatchReport { } case 18: { if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - issue_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Issue>(); + issue_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000002; } issue_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Issue.PARSER, extensionRegistry)); @@ -12559,7 +12556,7 @@ public final class BatchReport { java.util.Collections.emptyList(); private void ensureIssueIsMutable() { if (!((bitField0_ & 0x00000002) == 0x00000002)) { - issue_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Issue>(issue_); + issue_ = new java.util.ArrayList<>(issue_); bitField0_ |= 0x00000002; } } @@ -12784,8 +12781,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.Issue, org.sonar.batch.protocol.output.BatchReport.Issue.Builder, org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder> getIssueFieldBuilder() { if (issueBuilder_ == null) { - issueBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Issue, org.sonar.batch.protocol.output.BatchReport.Issue.Builder, org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder>( + issueBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( issue_, ((bitField0_ & 0x00000002) == 0x00000002), getParentForChildren(), @@ -13027,7 +13023,7 @@ public final class BatchReport { } case 18: { if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - changeset_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Changesets.Changeset>(); + changeset_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000002; } changeset_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Changesets.Changeset.PARSER, extensionRegistry)); @@ -13035,7 +13031,7 @@ public final class BatchReport { } case 24: { if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - changesetIndexByLine_ = new java.util.ArrayList<java.lang.Integer>(); + changesetIndexByLine_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000004; } changesetIndexByLine_.add(input.readInt32()); @@ -13045,7 +13041,7 @@ public final class BatchReport { int length = input.readRawVarint32(); int limit = input.pushLimit(length); if (!((mutable_bitField0_ & 0x00000004) == 0x00000004) && input.getBytesUntilLimit() > 0) { - changesetIndexByLine_ = new java.util.ArrayList<java.lang.Integer>(); + changesetIndexByLine_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000004; } while (input.getBytesUntilLimit() > 0) { @@ -14250,7 +14246,7 @@ public final class BatchReport { java.util.Collections.emptyList(); private void ensureChangesetIsMutable() { if (!((bitField0_ & 0x00000002) == 0x00000002)) { - changeset_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Changesets.Changeset>(changeset_); + changeset_ = new java.util.ArrayList<>(changeset_); bitField0_ |= 0x00000002; } } @@ -14475,8 +14471,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.Changesets.Changeset, org.sonar.batch.protocol.output.BatchReport.Changesets.Changeset.Builder, org.sonar.batch.protocol.output.BatchReport.Changesets.ChangesetOrBuilder> getChangesetFieldBuilder() { if (changesetBuilder_ == null) { - changesetBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Changesets.Changeset, org.sonar.batch.protocol.output.BatchReport.Changesets.Changeset.Builder, org.sonar.batch.protocol.output.BatchReport.Changesets.ChangesetOrBuilder>( + changesetBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( changeset_, ((bitField0_ & 0x00000002) == 0x00000002), getParentForChildren(), @@ -14489,7 +14484,7 @@ public final class BatchReport { private java.util.List<java.lang.Integer> changesetIndexByLine_ = java.util.Collections.emptyList(); private void ensureChangesetIndexByLineIsMutable() { if (!((bitField0_ & 0x00000004) == 0x00000004)) { - changesetIndexByLine_ = new java.util.ArrayList<java.lang.Integer>(changesetIndexByLine_); + changesetIndexByLine_ = new java.util.ArrayList<>(changesetIndexByLine_); bitField0_ |= 0x00000004; } } @@ -15293,8 +15288,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder> getRangeFieldBuilder() { if (rangeBuilder_ == null) { - rangeBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>( + rangeBuilder_ = new com.google.protobuf.SingleFieldBuilder<>( getRange(), getParentForChildren(), isClean()); @@ -15534,7 +15528,7 @@ public final class BatchReport { } case 18: { if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - duplicate_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Duplicate>(); + duplicate_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000002; } duplicate_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Duplicate.PARSER, extensionRegistry)); @@ -16081,8 +16075,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder> getOriginPositionFieldBuilder() { if (originPositionBuilder_ == null) { - originPositionBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>( + originPositionBuilder_ = new com.google.protobuf.SingleFieldBuilder<>( getOriginPosition(), getParentForChildren(), isClean()); @@ -16095,7 +16088,7 @@ public final class BatchReport { java.util.Collections.emptyList(); private void ensureDuplicateIsMutable() { if (!((bitField0_ & 0x00000002) == 0x00000002)) { - duplicate_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Duplicate>(duplicate_); + duplicate_ = new java.util.ArrayList<>(duplicate_); bitField0_ |= 0x00000002; } } @@ -16320,8 +16313,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.Duplicate, org.sonar.batch.protocol.output.BatchReport.Duplicate.Builder, org.sonar.batch.protocol.output.BatchReport.DuplicateOrBuilder> getDuplicateFieldBuilder() { if (duplicateBuilder_ == null) { - duplicateBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Duplicate, org.sonar.batch.protocol.output.BatchReport.Duplicate.Builder, org.sonar.batch.protocol.output.BatchReport.DuplicateOrBuilder>( + duplicateBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( duplicate_, ((bitField0_ & 0x00000002) == 0x00000002), getParentForChildren(), @@ -16438,7 +16430,7 @@ public final class BatchReport { } case 18: { if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - duplication_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Duplication>(); + duplication_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000002; } duplication_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Duplication.PARSER, extensionRegistry)); @@ -16852,7 +16844,7 @@ public final class BatchReport { java.util.Collections.emptyList(); private void ensureDuplicationIsMutable() { if (!((bitField0_ & 0x00000002) == 0x00000002)) { - duplication_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Duplication>(duplication_); + duplication_ = new java.util.ArrayList<>(duplication_); bitField0_ |= 0x00000002; } } @@ -17077,8 +17069,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.Duplication, org.sonar.batch.protocol.output.BatchReport.Duplication.Builder, org.sonar.batch.protocol.output.BatchReport.DuplicationOrBuilder> getDuplicationFieldBuilder() { if (duplicationBuilder_ == null) { - duplicationBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Duplication, org.sonar.batch.protocol.output.BatchReport.Duplication.Builder, org.sonar.batch.protocol.output.BatchReport.DuplicationOrBuilder>( + duplicationBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( duplication_, ((bitField0_ & 0x00000002) == 0x00000002), getParentForChildren(), @@ -17962,7 +17953,7 @@ public final class BatchReport { } case 18: { if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - symbol_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol>(); + symbol_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000002; } symbol_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.PARSER, extensionRegistry)); @@ -18118,7 +18109,7 @@ public final class BatchReport { } case 18: { if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - reference_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Range>(); + reference_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000002; } reference_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Range.PARSER, extensionRegistry)); @@ -18617,8 +18608,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder> getDeclarationFieldBuilder() { if (declarationBuilder_ == null) { - declarationBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>( + declarationBuilder_ = new com.google.protobuf.SingleFieldBuilder<>( getDeclaration(), getParentForChildren(), isClean()); @@ -18631,7 +18621,7 @@ public final class BatchReport { java.util.Collections.emptyList(); private void ensureReferenceIsMutable() { if (!((bitField0_ & 0x00000002) == 0x00000002)) { - reference_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Range>(reference_); + reference_ = new java.util.ArrayList<>(reference_); bitField0_ |= 0x00000002; } } @@ -18856,8 +18846,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder> getReferenceFieldBuilder() { if (referenceBuilder_ == null) { - referenceBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>( + referenceBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( reference_, ((bitField0_ & 0x00000002) == 0x00000002), getParentForChildren(), @@ -19244,7 +19233,7 @@ public final class BatchReport { java.util.Collections.emptyList(); private void ensureSymbolIsMutable() { if (!((bitField0_ & 0x00000002) == 0x00000002)) { - symbol_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol>(symbol_); + symbol_ = new java.util.ArrayList<>(symbol_); bitField0_ |= 0x00000002; } } @@ -19469,8 +19458,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol, org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.Builder, org.sonar.batch.protocol.output.BatchReport.Symbols.SymbolOrBuilder> getSymbolFieldBuilder() { if (symbolBuilder_ == null) { - symbolBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol, org.sonar.batch.protocol.output.BatchReport.Symbols.Symbol.Builder, org.sonar.batch.protocol.output.BatchReport.Symbols.SymbolOrBuilder>( + symbolBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( symbol_, ((bitField0_ & 0x00000002) == 0x00000002), getParentForChildren(), @@ -21107,8 +21095,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder> getRangeFieldBuilder() { if (rangeBuilder_ == null) { - rangeBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Range, org.sonar.batch.protocol.output.BatchReport.Range.Builder, org.sonar.batch.protocol.output.BatchReport.RangeOrBuilder>( + rangeBuilder_ = new com.google.protobuf.SingleFieldBuilder<>( getRange(), getParentForChildren(), isClean()); @@ -22220,7 +22207,7 @@ public final class BatchReport { } case 18: { if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - coveredFile_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.CoverageDetail.CoveredFile>(); + coveredFile_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000002; } coveredFile_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.CoverageDetail.CoveredFile.PARSER, extensionRegistry)); @@ -22353,7 +22340,7 @@ public final class BatchReport { } case 16: { if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - coveredLine_ = new java.util.ArrayList<java.lang.Integer>(); + coveredLine_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000002; } coveredLine_.add(input.readInt32()); @@ -22363,7 +22350,7 @@ public final class BatchReport { int length = input.readRawVarint32(); int limit = input.pushLimit(length); if (!((mutable_bitField0_ & 0x00000002) == 0x00000002) && input.getBytesUntilLimit() > 0) { - coveredLine_ = new java.util.ArrayList<java.lang.Integer>(); + coveredLine_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000002; } while (input.getBytesUntilLimit() > 0) { @@ -22756,7 +22743,7 @@ public final class BatchReport { private java.util.List<java.lang.Integer> coveredLine_ = java.util.Collections.emptyList(); private void ensureCoveredLineIsMutable() { if (!((bitField0_ & 0x00000002) == 0x00000002)) { - coveredLine_ = new java.util.ArrayList<java.lang.Integer>(coveredLine_); + coveredLine_ = new java.util.ArrayList<>(coveredLine_); bitField0_ |= 0x00000002; } } @@ -23269,7 +23256,7 @@ public final class BatchReport { java.util.Collections.emptyList(); private void ensureCoveredFileIsMutable() { if (!((bitField0_ & 0x00000002) == 0x00000002)) { - coveredFile_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.CoverageDetail.CoveredFile>(coveredFile_); + coveredFile_ = new java.util.ArrayList<>(coveredFile_); bitField0_ |= 0x00000002; } } @@ -23494,8 +23481,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.CoverageDetail.CoveredFile, org.sonar.batch.protocol.output.BatchReport.CoverageDetail.CoveredFile.Builder, org.sonar.batch.protocol.output.BatchReport.CoverageDetail.CoveredFileOrBuilder> getCoveredFileFieldBuilder() { if (coveredFileBuilder_ == null) { - coveredFileBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.CoverageDetail.CoveredFile, org.sonar.batch.protocol.output.BatchReport.CoverageDetail.CoveredFile.Builder, org.sonar.batch.protocol.output.BatchReport.CoverageDetail.CoveredFileOrBuilder>( + coveredFileBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( coveredFile_, ((bitField0_ & 0x00000002) == 0x00000002), getParentForChildren(), @@ -24073,7 +24059,7 @@ public final class BatchReport { } case 10: { if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - dep_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependency>(); + dep_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000001; } dep_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependency.PARSER, extensionRegistry)); @@ -24263,7 +24249,7 @@ public final class BatchReport { } case 34: { if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - child_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependency>(); + child_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000008; } child_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependency.PARSER, extensionRegistry)); @@ -25024,7 +25010,7 @@ public final class BatchReport { java.util.Collections.emptyList(); private void ensureChildIsMutable() { if (!((bitField0_ & 0x00000008) == 0x00000008)) { - child_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependency>(child_); + child_ = new java.util.ArrayList<>(child_); bitField0_ |= 0x00000008; } } @@ -25249,8 +25235,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependency, org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependency.Builder, org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependencyOrBuilder> getChildFieldBuilder() { if (childBuilder_ == null) { - childBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependency, org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependency.Builder, org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependencyOrBuilder>( + childBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( child_, ((bitField0_ & 0x00000008) == 0x00000008), getParentForChildren(), @@ -25570,7 +25555,7 @@ public final class BatchReport { java.util.Collections.emptyList(); private void ensureDepIsMutable() { if (!((bitField0_ & 0x00000001) == 0x00000001)) { - dep_ = new java.util.ArrayList<org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependency>(dep_); + dep_ = new java.util.ArrayList<>(dep_); bitField0_ |= 0x00000001; } } @@ -25795,8 +25780,7 @@ public final class BatchReport { org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependency, org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependency.Builder, org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependencyOrBuilder> getDepFieldBuilder() { if (depBuilder_ == null) { - depBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependency, org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependency.Builder, org.sonar.batch.protocol.output.BatchReport.ModuleDependencies.ModuleDependencyOrBuilder>( + depBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( dep_, ((bitField0_ & 0x00000001) == 0x00000001), getParentForChildren(), diff --git a/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java b/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java index afc771a998f..5b776ce0b82 100644 --- a/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java +++ b/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java @@ -369,7 +369,7 @@ public final class FileSourceDb { } case 136: { if (!((mutable_bitField0_ & 0x00010000) == 0x00010000)) { - duplication_ = new java.util.ArrayList<java.lang.Integer>(); + duplication_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00010000; } duplication_.add(input.readInt32()); @@ -379,7 +379,7 @@ public final class FileSourceDb { int length = input.readRawVarint32(); int limit = input.pushLimit(length); if (!((mutable_bitField0_ & 0x00010000) == 0x00010000) && input.getBytesUntilLimit() > 0) { - duplication_ = new java.util.ArrayList<java.lang.Integer>(); + duplication_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00010000; } while (input.getBytesUntilLimit() > 0) { @@ -2205,7 +2205,7 @@ public final class FileSourceDb { private java.util.List<java.lang.Integer> duplication_ = java.util.Collections.emptyList(); private void ensureDuplicationIsMutable() { if (!((bitField0_ & 0x00010000) == 0x00010000)) { - duplication_ = new java.util.ArrayList<java.lang.Integer>(duplication_); + duplication_ = new java.util.ArrayList<>(duplication_); bitField0_ |= 0x00010000; } } @@ -2361,7 +2361,7 @@ public final class FileSourceDb { } case 10: { if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - lines_ = new java.util.ArrayList<org.sonar.server.source.db.FileSourceDb.Line>(); + lines_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000001; } lines_.add(input.readMessage(org.sonar.server.source.db.FileSourceDb.Line.PARSER, extensionRegistry)); @@ -2708,7 +2708,7 @@ public final class FileSourceDb { java.util.Collections.emptyList(); private void ensureLinesIsMutable() { if (!((bitField0_ & 0x00000001) == 0x00000001)) { - lines_ = new java.util.ArrayList<org.sonar.server.source.db.FileSourceDb.Line>(lines_); + lines_ = new java.util.ArrayList<>(lines_); bitField0_ |= 0x00000001; } } @@ -2933,8 +2933,7 @@ public final class FileSourceDb { org.sonar.server.source.db.FileSourceDb.Line, org.sonar.server.source.db.FileSourceDb.Line.Builder, org.sonar.server.source.db.FileSourceDb.LineOrBuilder> getLinesFieldBuilder() { if (linesBuilder_ == null) { - linesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.server.source.db.FileSourceDb.Line, org.sonar.server.source.db.FileSourceDb.Line.Builder, org.sonar.server.source.db.FileSourceDb.LineOrBuilder>( + linesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( lines_, ((bitField0_ & 0x00000001) == 0x00000001), getParentForChildren(), @@ -3151,7 +3150,7 @@ public final class FileSourceDb { } case 58: { if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { - coveredFile_ = new java.util.ArrayList<org.sonar.server.source.db.FileSourceDb.Test.CoveredFile>(); + coveredFile_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000040; } coveredFile_.add(input.readMessage(org.sonar.server.source.db.FileSourceDb.Test.CoveredFile.PARSER, extensionRegistry)); @@ -3390,7 +3389,7 @@ public final class FileSourceDb { } case 16: { if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - coveredLine_ = new java.util.ArrayList<java.lang.Integer>(); + coveredLine_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000002; } coveredLine_.add(input.readInt32()); @@ -3400,7 +3399,7 @@ public final class FileSourceDb { int length = input.readRawVarint32(); int limit = input.pushLimit(length); if (!((mutable_bitField0_ & 0x00000002) == 0x00000002) && input.getBytesUntilLimit() > 0) { - coveredLine_ = new java.util.ArrayList<java.lang.Integer>(); + coveredLine_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000002; } while (input.getBytesUntilLimit() > 0) { @@ -3866,7 +3865,7 @@ public final class FileSourceDb { private java.util.List<java.lang.Integer> coveredLine_ = java.util.Collections.emptyList(); private void ensureCoveredLineIsMutable() { if (!((bitField0_ & 0x00000002) == 0x00000002)) { - coveredLine_ = new java.util.ArrayList<java.lang.Integer>(coveredLine_); + coveredLine_ = new java.util.ArrayList<>(coveredLine_); bitField0_ |= 0x00000002; } } @@ -4921,7 +4920,7 @@ public final class FileSourceDb { java.util.Collections.emptyList(); private void ensureCoveredFileIsMutable() { if (!((bitField0_ & 0x00000040) == 0x00000040)) { - coveredFile_ = new java.util.ArrayList<org.sonar.server.source.db.FileSourceDb.Test.CoveredFile>(coveredFile_); + coveredFile_ = new java.util.ArrayList<>(coveredFile_); bitField0_ |= 0x00000040; } } @@ -5146,8 +5145,7 @@ public final class FileSourceDb { org.sonar.server.source.db.FileSourceDb.Test.CoveredFile, org.sonar.server.source.db.FileSourceDb.Test.CoveredFile.Builder, org.sonar.server.source.db.FileSourceDb.Test.CoveredFileOrBuilder> getCoveredFileFieldBuilder() { if (coveredFileBuilder_ == null) { - coveredFileBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.server.source.db.FileSourceDb.Test.CoveredFile, org.sonar.server.source.db.FileSourceDb.Test.CoveredFile.Builder, org.sonar.server.source.db.FileSourceDb.Test.CoveredFileOrBuilder>( + coveredFileBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( coveredFile_, ((bitField0_ & 0x00000040) == 0x00000040), getParentForChildren(), diff --git a/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceTestDb.java b/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceTestDb.java index e03062ece80..3fbf75e74c1 100644 --- a/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceTestDb.java +++ b/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceTestDb.java @@ -209,7 +209,7 @@ public final class FileSourceTestDb { } case 58: { if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { - coverageBlock_ = new java.util.ArrayList<org.sonar.server.source.db.FileSourceTestDb.Test.CoverageBlock>(); + coverageBlock_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000040; } coverageBlock_.add(input.readMessage(org.sonar.server.source.db.FileSourceTestDb.Test.CoverageBlock.PARSER, extensionRegistry)); @@ -409,7 +409,7 @@ public final class FileSourceTestDb { } case 32: { if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - lines_ = new java.util.ArrayList<java.lang.Integer>(); + lines_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000008; } lines_.add(input.readInt32()); @@ -419,7 +419,7 @@ public final class FileSourceTestDb { int length = input.readRawVarint32(); int limit = input.pushLimit(length); if (!((mutable_bitField0_ & 0x00000008) == 0x00000008) && input.getBytesUntilLimit() > 0) { - lines_ = new java.util.ArrayList<java.lang.Integer>(); + lines_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000008; } while (input.getBytesUntilLimit() > 0) { @@ -1220,7 +1220,7 @@ public final class FileSourceTestDb { private java.util.List<java.lang.Integer> lines_ = java.util.Collections.emptyList(); private void ensureLinesIsMutable() { if (!((bitField0_ & 0x00000008) == 0x00000008)) { - lines_ = new java.util.ArrayList<java.lang.Integer>(lines_); + lines_ = new java.util.ArrayList<>(lines_); bitField0_ |= 0x00000008; } } @@ -2444,7 +2444,7 @@ public final class FileSourceTestDb { java.util.Collections.emptyList(); private void ensureCoverageBlockIsMutable() { if (!((bitField0_ & 0x00000040) == 0x00000040)) { - coverageBlock_ = new java.util.ArrayList<org.sonar.server.source.db.FileSourceTestDb.Test.CoverageBlock>(coverageBlock_); + coverageBlock_ = new java.util.ArrayList<>(coverageBlock_); bitField0_ |= 0x00000040; } } @@ -2668,8 +2668,7 @@ public final class FileSourceTestDb { org.sonar.server.source.db.FileSourceTestDb.Test.CoverageBlock, org.sonar.server.source.db.FileSourceTestDb.Test.CoverageBlock.Builder, org.sonar.server.source.db.FileSourceTestDb.Test.CoverageBlockOrBuilder> getCoverageBlockFieldBuilder() { if (coverageBlockBuilder_ == null) { - coverageBlockBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.server.source.db.FileSourceTestDb.Test.CoverageBlock, org.sonar.server.source.db.FileSourceTestDb.Test.CoverageBlock.Builder, org.sonar.server.source.db.FileSourceTestDb.Test.CoverageBlockOrBuilder>( + coverageBlockBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( coverageBlock_, ((bitField0_ & 0x00000040) == 0x00000040), getParentForChildren(), @@ -2771,7 +2770,7 @@ public final class FileSourceTestDb { } case 10: { if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - test_ = new java.util.ArrayList<org.sonar.server.source.db.FileSourceTestDb.Test>(); + test_ = new java.util.ArrayList<>(); mutable_bitField0_ |= 0x00000001; } test_.add(input.readMessage(org.sonar.server.source.db.FileSourceTestDb.Test.PARSER, extensionRegistry)); @@ -3118,7 +3117,7 @@ public final class FileSourceTestDb { java.util.Collections.emptyList(); private void ensureTestIsMutable() { if (!((bitField0_ & 0x00000001) == 0x00000001)) { - test_ = new java.util.ArrayList<org.sonar.server.source.db.FileSourceTestDb.Test>(test_); + test_ = new java.util.ArrayList<>(test_); bitField0_ |= 0x00000001; } } @@ -3342,8 +3341,7 @@ public final class FileSourceTestDb { org.sonar.server.source.db.FileSourceTestDb.Test, org.sonar.server.source.db.FileSourceTestDb.Test.Builder, org.sonar.server.source.db.FileSourceTestDb.TestOrBuilder> getTestFieldBuilder() { if (testBuilder_ == null) { - testBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.server.source.db.FileSourceTestDb.Test, org.sonar.server.source.db.FileSourceTestDb.Test.Builder, org.sonar.server.source.db.FileSourceTestDb.TestOrBuilder>( + testBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<>( test_, ((bitField0_ & 0x00000001) == 0x00000001), getParentForChildren(), diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java index 219f8a536ea..1571119eb99 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java @@ -28,7 +28,7 @@ import java.util.Map; public class ActiveRule { private final String repositoryKey, ruleKey, templateRuleKey; private final String name, severity, internalKey, language; - private final Map<String, String> params = new HashMap<String, String>(); + private final Map<String, String> params = new HashMap<>(); public ActiveRule(String repositoryKey, String ruleKey, @Nullable String templateRuleKey, String name, @Nullable String severity, @Nullable String internalKey, @Nullable String language) { diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/GlobalRepositories.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/GlobalRepositories.java index 4dccd3a286f..a31828ccc9c 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/GlobalRepositories.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/GlobalRepositories.java @@ -33,8 +33,8 @@ import java.util.Map; public class GlobalRepositories { private long timestamp; - private Collection<Metric> metrics = new ArrayList<Metric>(); - private Map<String, String> globalSettings = new HashMap<String, String>(); + private Collection<Metric> metrics = new ArrayList<>(); + private Map<String, String> globalSettings = new HashMap<>(); public Map<String, String> globalSettings() { return globalSettings; diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectRepositories.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectRepositories.java index eb3200b6ac3..803560c176a 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectRepositories.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectRepositories.java @@ -33,10 +33,10 @@ import java.util.*; public class ProjectRepositories { private long timestamp; - private Map<String, QProfile> qprofilesByLanguage = new HashMap<String, QProfile>(); - private Collection<ActiveRule> activeRules = new ArrayList<ActiveRule>(); - private Map<String, Map<String, String>> settingsByModule = new HashMap<String, Map<String, String>>(); - private Map<String, Map<String, FileData>> fileDataByModuleAndPath = new HashMap<String, Map<String, FileData>>(); + private Map<String, QProfile> qprofilesByLanguage = new HashMap<>(); + private Collection<ActiveRule> activeRules = new ArrayList<>(); + private Map<String, Map<String, String>> settingsByModule = new HashMap<>(); + private Map<String, Map<String, FileData>> fileDataByModuleAndPath = new HashMap<>(); private Date lastAnalysisDate; public Map<String, String> settings(String moduleKey) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java index 5a66504364e..dfd3a7c009c 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java @@ -160,7 +160,7 @@ public class BatchExtensionDictionnary { * Extension dependencies */ private <T> List<Object> getDependencies(T extension) { - List<Object> result = new ArrayList<Object>(); + List<Object> result = new ArrayList<>(); result.addAll(evaluateAnnotatedClasses(extension, DependsUpon.class)); return result; } @@ -169,7 +169,7 @@ public class BatchExtensionDictionnary { * Objects that depend upon this extension. */ public <T> List<Object> getDependents(T extension) { - List<Object> result = new ArrayList<Object>(); + List<Object> result = new ArrayList<>(); result.addAll(evaluateAnnotatedClasses(extension, DependedUpon.class)); return result; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcLeakPrevention.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcLeakPrevention.java index acf6658a16a..c98fd8faf30 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcLeakPrevention.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcLeakPrevention.java @@ -44,7 +44,7 @@ public class JdbcLeakPrevention { public List<String> unregisterDrivers() throws SQLException { Set<Driver> registeredDrivers = registeredDrivers(); - List<String> unregisteredNames = new ArrayList<String>(); + List<String> unregisteredNames = new ArrayList<>(); Enumeration<Driver> drivers = DriverManager.getDrivers(); while (drivers.hasMoreElements()) { Driver driver = drivers.nextElement(); @@ -60,7 +60,7 @@ public class JdbcLeakPrevention { } private Set<Driver> registeredDrivers() { - Set<Driver> registeredDrivers = new HashSet<Driver>(); + Set<Driver> registeredDrivers = new HashSet<>(); Enumeration<Driver> drivers = DriverManager.getDrivers(); while (drivers.hasMoreElements()) { Driver driver = drivers.nextElement(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java index 3af2092c66e..1c4bf3e019a 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java @@ -102,8 +102,8 @@ public final class DebtDecorator implements Decorator { private void saveMeasures(DecoratorContext context, List<Issue> issues) { Long total = 0L; - SumMap<RuleKey> ruleDebts = new SumMap<RuleKey>(); - SumMap<Characteristic> characteristicDebts = new SumMap<Characteristic>(); + SumMap<RuleKey> ruleDebts = new SumMap<>(); + SumMap<Characteristic> characteristicDebts = new SumMap<>(); // Aggregate rules debt from current issues (and populate current characteristic debt) for (Issue issue : issues) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/DecoratorsSelector.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/DecoratorsSelector.java index c50574fb637..a77a09cb844 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/DecoratorsSelector.java +++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/DecoratorsSelector.java @@ -39,7 +39,7 @@ public final class DecoratorsSelector { } public Collection<Decorator> select(Project project) { - List<Decorator> decorators = new ArrayList<Decorator>(batchExtDictionnary.select(Decorator.class, project, false, null)); + List<Decorator> decorators = new ArrayList<>(batchExtDictionnary.select(Decorator.class, project, false, null)); SetMultimap<Metric, Decorator> decoratorsByGeneratedMetric = getDecoratorsByMetric(decorators); for (Metric metric : batchExtDictionnary.select(Metric.class, null, false, null)) { if (metric.getFormula() != null) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/design/DirectoryDsmDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/design/DirectoryDsmDecorator.java index 95c3da4ae8c..f0527ca66f6 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/design/DirectoryDsmDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/design/DirectoryDsmDecorator.java @@ -42,7 +42,7 @@ public class DirectoryDsmDecorator extends DsmDecorator { @Override protected List<Resource> getChildren(Resource resource, DecoratorContext context) { List<DecoratorContext> fileContexts = context.getChildren(); - List<Resource> files = new ArrayList<Resource>(fileContexts.size()); + List<Resource> files = new ArrayList<>(fileContexts.size()); for (DecoratorContext decoratorContext : fileContexts) { files.add(decoratorContext.getResource()); } @@ -51,7 +51,7 @@ public class DirectoryDsmDecorator extends DsmDecorator { @Override protected Set<Edge> doProcess(List<Resource> children, DecoratorContext context) { - IncrementalCyclesAndFESSolver<Resource> cycleDetector = new IncrementalCyclesAndFESSolver<Resource>(getIndex(), children); + IncrementalCyclesAndFESSolver<Resource> cycleDetector = new IncrementalCyclesAndFESSolver<>(getIndex(), children); Set<Cycle> cycles = cycleDetector.getCycles(); MinimumFeedbackEdgeSetSolver solver = new MinimumFeedbackEdgeSetSolver(cycles); diff --git a/sonar-batch/src/main/java/org/sonar/batch/design/DsmDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/design/DsmDecorator.java index 8dafbe0cbd0..790debf713b 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/design/DsmDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/design/DsmDecorator.java @@ -91,7 +91,7 @@ public abstract class DsmDecorator implements Decorator { } protected final Dsm<Resource> getDsm(Collection<Resource> children, Set<Edge> feedbackEdges) { - Dsm<Resource> dsm = new Dsm<Resource>(index, children, feedbackEdges); + Dsm<Resource> dsm = new Dsm<>(index, children, feedbackEdges); DsmTopologicalSorter.sort(dsm); return dsm; } @@ -112,7 +112,7 @@ public abstract class DsmDecorator implements Decorator { } protected final List<Dependency> getEdges(Collection<Resource> vertices) { - List<Dependency> result = new ArrayList<Dependency>(); + List<Dependency> result = new ArrayList<>(); for (Resource vertice : vertices) { Collection<Dependency> outgoingEdges = index.getOutgoingEdges(vertice); if (outgoingEdges != null) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/design/MavenDependenciesSensor.java b/sonar-batch/src/main/java/org/sonar/batch/design/MavenDependenciesSensor.java index 4d04022e509..6956cac89b7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/design/MavenDependenciesSensor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/design/MavenDependenciesSensor.java @@ -112,7 +112,7 @@ public class MavenDependenciesSensor implements Sensor { private String scope; - List<InputDependency> dependencies = new ArrayList<InputDependency>(); + List<InputDependency> dependencies = new ArrayList<>(); public InputDependency(String key, String version) { this.key = key; diff --git a/sonar-batch/src/main/java/org/sonar/batch/design/ProjectDsmDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/design/ProjectDsmDecorator.java index 66471955795..620ceeabd3f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/design/ProjectDsmDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/design/ProjectDsmDecorator.java @@ -61,7 +61,7 @@ public class ProjectDsmDecorator extends DsmDecorator { @Override protected Set<Edge> doProcess(List<Resource> children, DecoratorContext context) { - CycleDetector<Resource> cycleDetector = new CycleDetector<Resource>(getIndex(), children); + CycleDetector<Resource> cycleDetector = new CycleDetector<>(getIndex(), children); Set<Cycle> cycles = cycleDetector.getCycles(); MinimumFeedbackEdgeSetSolver solver = new MinimumFeedbackEdgeSetSolver(cycles); diff --git a/sonar-batch/src/main/java/org/sonar/batch/design/SubProjectDsmDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/design/SubProjectDsmDecorator.java index 9e03a13c7df..62aa622b11d 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/design/SubProjectDsmDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/design/SubProjectDsmDecorator.java @@ -43,7 +43,7 @@ public class SubProjectDsmDecorator extends DsmDecorator { @Override protected List<Resource> getChildren(Resource resource, DecoratorContext context) { List<DecoratorContext> directoryContexts = context.getChildren(); - List<Resource> directories = new ArrayList<Resource>(directoryContexts.size()); + List<Resource> directories = new ArrayList<>(directoryContexts.size()); for (DecoratorContext decoratorContext : directoryContexts) { directories.add(decoratorContext.getResource()); } @@ -52,7 +52,7 @@ public class SubProjectDsmDecorator extends DsmDecorator { @Override protected Set<Edge> doProcess(List<Resource> children, DecoratorContext context) { - IncrementalCyclesAndFESSolver<Resource> cycleDetector = new IncrementalCyclesAndFESSolver<Resource>(getIndex(), children); + IncrementalCyclesAndFESSolver<Resource> cycleDetector = new IncrementalCyclesAndFESSolver<>(getIndex(), children); Set<Cycle> cycles = cycleDetector.getCycles(); MinimumFeedbackEdgeSetSolver solver = new MinimumFeedbackEdgeSetSolver(cycles); diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/BatchResource.java b/sonar-batch/src/main/java/org/sonar/batch/index/BatchResource.java index 5fe13a1c89a..af4eedd4bd9 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/BatchResource.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/BatchResource.java @@ -37,7 +37,7 @@ public class BatchResource { private final Resource r; private Snapshot s; private final BatchResource parent; - private final Collection<BatchResource> children = new ArrayList<BatchResource>(); + private final Collection<BatchResource> children = new ArrayList<>(); private InputPath inputPath; public BatchResource(int batchId, Resource r, @Nullable BatchResource parent) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/Cache.java b/sonar-batch/src/main/java/org/sonar/batch/index/Cache.java index fa98e02d0b8..be01e354f7b 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/Cache.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/Cache.java @@ -300,29 +300,29 @@ public class Cache<V> { * Lazy-loading values for given keys */ public Iterable<V> values(Object firstKey, Object secondKey) { - return new ValueIterable<V>(exchange, firstKey, secondKey); + return new ValueIterable<>(exchange, firstKey, secondKey); } /** * Lazy-loading values for a given key */ public Iterable<V> values(Object firstKey) { - return new ValueIterable<V>(exchange, firstKey); + return new ValueIterable<>(exchange, firstKey); } /** * Lazy-loading values */ public Iterable<V> values() { - return new ValueIterable<V>(exchange); + return new ValueIterable<>(exchange); } public Iterable<Entry<V>> entries() { - return new EntryIterable<V>(exchange); + return new EntryIterable<>(exchange); } public Iterable<Entry<V>> entries(Object firstKey) { - return new EntryIterable<V>(exchange, firstKey); + return new EntryIterable<>(exchange, firstKey); } private void resetKey(Object key) { @@ -370,7 +370,7 @@ public class Cache<V> { } originExchange.append(Key.BEFORE); Exchange iteratorExchange = new Exchange(originExchange); - return new ValueIterator<T>(iteratorExchange, filter); + return new ValueIterator<>(iteratorExchange, filter); } } @@ -431,7 +431,7 @@ public class Cache<V> { } originExchange.append(Key.BEFORE); Exchange iteratorExchange = new Exchange(originExchange); - return new EntryIterator<T>(iteratorExchange, filter); + return new EntryIterator<>(iteratorExchange, filter); } } @@ -468,7 +468,7 @@ public class Cache<V> { for (int i = 0; i < key.getDepth(); i++) { array[i] = key.indexTo(i - key.getDepth()).decode(); } - return new Entry<T>(array, value); + return new Entry<>(array, value); } throw new NoSuchElementException(); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/Caches.java b/sonar-batch/src/main/java/org/sonar/batch/index/Caches.java index ac0f509ec9d..74c2d7f6ad9 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/Caches.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/Caches.java @@ -91,7 +91,7 @@ public class Caches implements Startable { try { Exchange exchange = persistit.getExchange(volume, cacheName, true); exchange.setMaximumValueSize(Value.MAXIMUM_SIZE); - Cache<V> cache = new Cache<V>(cacheName, exchange); + Cache<V> cache = new Cache<>(cacheName, exchange); cacheNames.add(cacheName); return cache; } catch (Exception e) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java index 14803caa3b5..a0436ba85fa 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java @@ -223,7 +223,7 @@ public class DefaultIndex extends SonarIndex { } else { unfiltered = measureCache.byResource(indexedResource); } - Collection<Measure> all = new ArrayList<Measure>(); + Collection<Measure> all = new ArrayList<>(); if (unfiltered != null) { for (Measure measure : unfiltered) { all.add(measure); @@ -300,7 +300,7 @@ public class DefaultIndex extends SonarIndex { private void registerOutgoingDependency(Dependency dependency) { Map<Resource, Dependency> outgoingDeps = outgoingDependenciesByResource.get(dependency.getFrom()); if (outgoingDeps == null) { - outgoingDeps = new HashMap<Resource, Dependency>(); + outgoingDeps = new HashMap<>(); outgoingDependenciesByResource.put(dependency.getFrom(), outgoingDeps); } outgoingDeps.put(dependency.getTo(), dependency); @@ -309,7 +309,7 @@ public class DefaultIndex extends SonarIndex { private void registerIncomingDependency(Dependency dependency) { Map<Resource, Dependency> incomingDeps = incomingDependenciesByResource.get(dependency.getTo()); if (incomingDeps == null) { - incomingDeps = new HashMap<Resource, Dependency>(); + incomingDeps = new HashMap<>(); incomingDependenciesByResource.put(dependency.getTo(), incomingDeps); } incomingDeps.put(dependency.getFrom(), dependency); diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java index 33c2a98cc69..81891856cdf 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java @@ -80,9 +80,9 @@ public class ResourceKeyMigration { void migrateIfNeeded(Project module, Iterable<InputFile> inputFiles, DefaultModuleFileSystem fs) { logger.info("Update component keys"); - Map<String, InputFile> deprecatedFileKeyMapper = new HashMap<String, InputFile>(); - Map<String, InputFile> deprecatedTestKeyMapper = new HashMap<String, InputFile>(); - Map<String, String> deprecatedDirectoryKeyMapper = new HashMap<String, String>(); + Map<String, InputFile> deprecatedFileKeyMapper = new HashMap<>(); + Map<String, InputFile> deprecatedTestKeyMapper = new HashMap<>(); + Map<String, String> deprecatedDirectoryKeyMapper = new HashMap<>(); for (InputFile inputFile : inputFiles) { String deprecatedKey = computeDeprecatedKey(module.getKey(), (DeprecatedDefaultInputFile) inputFile, fs); if (deprecatedKey != null) { @@ -225,7 +225,7 @@ public class ResourceKeyMigration { .setParameter("rootId", moduleId) .setParameter("enabled", false) .getResultList(); - Map<String, ResourceModel> disabledResourceByKey = new HashMap<String, ResourceModel>(); + Map<String, ResourceModel> disabledResourceByKey = new HashMap<>(); for (ResourceModel disabledResourceModel : disabledResources) { disabledResourceByKey.put(disabledResourceModel.getKey(), disabledResourceModel); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java index 9f92432a026..35765f96fb9 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java +++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java @@ -296,7 +296,7 @@ public class BatchMediumTester { } private static class FakeServerLineHashesLoader implements ServerLineHashesLoader { - private Map<String, String[]> byKey = new HashMap<String, String[]>(); + private Map<String, String[]> byKey = new HashMap<>(); @Override public String[] getLineHashes(String fileKey) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java index 8aa0a88a574..b352631eddd 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java +++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java @@ -193,7 +193,7 @@ public class TaskResult implements org.sonar.batch.mediumtest.ScanTaskObserver { return Collections.emptyList(); } TextPointer pointer = file.newPointer(line, lineOffset); - List<TypeOfText> result = new ArrayList<TypeOfText>(); + List<TypeOfText> result = new ArrayList<>(); InputStream inputStream = null; try { inputStream = FileUtils.openInputStream(highlightingFile); diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/PhasesTimeProfiler.java b/sonar-batch/src/main/java/org/sonar/batch/phases/PhasesTimeProfiler.java index 612e4d49d5a..32c2538ab10 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/PhasesTimeProfiler.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/PhasesTimeProfiler.java @@ -81,7 +81,7 @@ public class PhasesTimeProfiler implements SensorExecutionHandler, DecoratorExec static class DecoratorsProfiler { List<Decorator> decorators = Lists.newArrayList(); - Map<Decorator, Long> durations = new IdentityHashMap<Decorator, Long>(); + Map<Decorator, Long> durations = new IdentityHashMap<>(); long startTime; Decorator currentDecorator; diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java index d4bce006df4..687adba5178 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java +++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java @@ -76,7 +76,7 @@ public abstract class AbstractTimeProfiling { return Long.valueOf(o2.getValue().totalTime()).compareTo(o1.getValue().totalTime()); } }); - Map<Object, G> sortedMap = new LinkedHashMap<Object, G>(); + Map<Object, G> sortedMap = new LinkedHashMap<>(); for (Map.Entry<?, G> entry : entries) { sortedMap.put(entry.getKey(), entry.getValue()); } @@ -85,7 +85,7 @@ public abstract class AbstractTimeProfiling { static <G extends AbstractTimeProfiling> List<G> truncate(Collection<G> sortedList) { int maxSize = 10; - List<G> result = new ArrayList<G>(maxSize); + List<G> result = new ArrayList<>(maxSize); int i = 0; for (G item : sortedList) { if (i >= maxSize || item.totalTime() == 0) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java index c4a0fc19174..f4bae408420 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java +++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java @@ -30,8 +30,8 @@ import java.util.Map.Entry; public class ModuleProfiling extends AbstractTimeProfiling { - private Map<Phase, PhaseProfiling> profilingPerPhase = new HashMap<Phase, PhaseProfiling>(); - private Map<String, ItemProfiling> profilingPerBatchStep = new LinkedHashMap<String, ItemProfiling>(); + private Map<Phase, PhaseProfiling> profilingPerPhase = new HashMap<>(); + private Map<String, ItemProfiling> profilingPerBatchStep = new LinkedHashMap<>(); private final Project module; public ModuleProfiling(@Nullable Project module, System2 system) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java index 2bb5599a0fe..15b16d02b49 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java +++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java @@ -30,7 +30,7 @@ public class PhaseProfiling extends AbstractTimeProfiling { private final Phase phase; - private Map<String, ItemProfiling> profilingPerItem = new HashMap<String, ItemProfiling>(); + private Map<String, ItemProfiling> profilingPerItem = new HashMap<>(); PhaseProfiling(System2 system, Phase phase) { super(system); diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java index b4357e407bd..c62c528c2fb 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java +++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java @@ -59,7 +59,7 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx @VisibleForTesting ModuleProfiling totalProfiling; - private Map<Project, ModuleProfiling> modulesProfilings = new HashMap<Project, ModuleProfiling>(); + private Map<Project, ModuleProfiling> modulesProfilings = new HashMap<>(); private DecoratorsProfiler decoratorsProfiler; private final System2 system; @@ -258,7 +258,7 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx class DecoratorsProfiler { private List<Decorator> decorators = Lists.newArrayList(); - private Map<Decorator, Long> durations = new IdentityHashMap<Decorator, Long>(); + private Map<Decorator, Long> durations = new IdentityHashMap<>(); private long startTime; private Decorator currentDecorator; diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/language/DefaultLanguagesRepository.java b/sonar-batch/src/main/java/org/sonar/batch/repository/language/DefaultLanguagesRepository.java index fe5f50ba9ea..dd3b43b422f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/repository/language/DefaultLanguagesRepository.java +++ b/sonar-batch/src/main/java/org/sonar/batch/repository/language/DefaultLanguagesRepository.java @@ -54,7 +54,7 @@ public class DefaultLanguagesRepository implements LanguagesRepository { @Override public Collection<Language> all() { org.sonar.api.resources.Language[] all = languages.all(); - Collection<Language> result = new ArrayList<Language>(all.length); + Collection<Language> result = new ArrayList<>(all.length); for (org.sonar.api.resources.Language language : all) { result.add(new Language(language.getKey(), language.getName(), language.getFileSuffixes())); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileWrapper.java b/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileWrapper.java index 41914729afa..302f71e5db2 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileWrapper.java +++ b/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileWrapper.java @@ -85,7 +85,7 @@ public class RulesProfileWrapper extends RulesProfile { @Override public List<ActiveRule> getActiveRules() { - List<ActiveRule> activeRules = new ArrayList<ActiveRule>(); + List<ActiveRule> activeRules = new ArrayList<>(); for (RulesProfile profile : profiles) { activeRules.addAll(profile.getActiveRules()); } @@ -105,7 +105,7 @@ public class RulesProfileWrapper extends RulesProfile { @Override public List<ActiveRule> getActiveRulesByRepository(String repositoryKey) { - List<ActiveRule> activeRules = new ArrayList<ActiveRule>(); + List<ActiveRule> activeRules = new ArrayList<>(); for (RulesProfile profile : profiles) { activeRules.addAll(profile.getActiveRulesByRepository(repositoryKey)); } @@ -114,7 +114,7 @@ public class RulesProfileWrapper extends RulesProfile { @Override public List<ActiveRule> getActiveRules(boolean acceptDisabledRules) { - List<ActiveRule> activeRules = new ArrayList<ActiveRule>(); + List<ActiveRule> activeRules = new ArrayList<>(); for (RulesProfile profile : profiles) { activeRules.addAll(profile.getActiveRules(acceptDisabledRules)); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/UsedQProfiles.java b/sonar-batch/src/main/java/org/sonar/batch/rule/UsedQProfiles.java index ac923055950..15a6d3cd3ae 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/rule/UsedQProfiles.java +++ b/sonar-batch/src/main/java/org/sonar/batch/rule/UsedQProfiles.java @@ -103,7 +103,7 @@ public class UsedQProfiles { } public Map<String, QProfile> profilesByKey() { - Map<String, QProfile> map = new HashMap<String, QProfile>(); + Map<String, QProfile> map = new HashMap<>(); for (QProfile profile : profiles) { map.put(profile.getKey(), profile); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java index 3c63472ede6..861600fdba9 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java @@ -125,9 +125,9 @@ public class ProjectReactorBuilder { } private Map<String, Map<String, String>> extractPropertiesByModule(String currentModuleId, Map<String, String> parentProperties) { - Map<String, String> allProperties = new HashMap<String, String>(); + Map<String, String> allProperties = new HashMap<>(); allProperties.putAll(parentProperties); - Map<String, String> currentModuleProperties = new HashMap<String, String>(); + Map<String, String> currentModuleProperties = new HashMap<>(); String prefix = !currentModuleId.isEmpty() ? currentModuleId + "." : ""; // By default all properties starting with module prefix belong to current module for (Map.Entry<String, String> entry : allProperties.entrySet()) { @@ -138,11 +138,11 @@ public class ProjectReactorBuilder { parentProperties.remove(key); } } - List<String> moduleIds = new ArrayList<String>(Arrays.asList(getListFromProperty(currentModuleProperties, PROPERTY_MODULES))); + List<String> moduleIds = new ArrayList<>(Arrays.asList(getListFromProperty(currentModuleProperties, PROPERTY_MODULES))); // Sort module by reverse lexicographic order to avoid issue when one module id is a prefix of another one Collections.sort(moduleIds); Collections.reverse(moduleIds); - Map<String, Map<String, String>> result = new HashMap<String, Map<String, String>>(); + Map<String, Map<String, String>> result = new HashMap<>(); for (String moduleId : moduleIds) { result.putAll(extractPropertiesByModule(moduleId, currentModuleProperties)); } @@ -445,7 +445,7 @@ public class ProjectReactorBuilder { dirPath = pattern.substring(0, i); filePattern = pattern.substring(i + 1); } - List<IOFileFilter> filters = new ArrayList<IOFileFilter>(); + List<IOFileFilter> filters = new ArrayList<>(); if (pattern.indexOf('*') >= 0) { filters.add(FileFileFilter.FILE); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java index 88970aa75da..208b5766483 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java @@ -61,7 +61,7 @@ public class ProjectReactorValidator { String branch = settings.getString(CoreProperties.PROJECT_BRANCH_PROPERTY); String rootProjectKey = ComponentKeys.createKey(reactor.getRoot().getKey(), branch); - List<String> validationMessages = new ArrayList<String>(); + List<String> validationMessages = new ArrayList<>(); checkDeprecatedProperties(validationMessages); for (ProjectDefinition moduleDef : reactor.getProjects()) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java index c45dd646495..5809addf3f5 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java @@ -122,7 +122,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module } private List<File> keepOnlyDirs(List<File> dirsOrFiles) { - List<File> result = new ArrayList<File>(); + List<File> result = new ArrayList<>(); for (File f : dirsOrFiles) { if (f.isDirectory()) { result.add(f); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java index 0e5dec4bbad..87527835a81 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java @@ -90,7 +90,7 @@ public class FileIndexer { InputFileBuilder inputFileBuilder = inputFileBuilderFactory.create(fileSystem); executorService = Executors.newFixedThreadPool(Math.max(1, Runtime.getRuntime().availableProcessors() - 1)); - tasks = new ArrayList<Future<Void>>(); + tasks = new ArrayList<>(); indexFiles(fileSystem, progress, inputFileBuilder, fileSystem.sources(), InputFile.Type.MAIN); indexFiles(fileSystem, progress, inputFileBuilder, fileSystem.tests(), InputFile.Type.TEST); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReport.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReport.java index fb23eed4c21..5604537b15f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReport.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReport.java @@ -75,11 +75,11 @@ public class IssuesReport { } public List<ResourceReport> getResourceReports() { - return new ArrayList<ResourceReport>(resourceReportsByResource.values()); + return new ArrayList<>(resourceReportsByResource.values()); } public List<BatchResource> getResourcesWithReport() { - return new ArrayList<BatchResource>(resourceReportsByResource.keySet()); + return new ArrayList<>(resourceReportsByResource.keySet()); } public void addIssueOnResource(BatchResource resource, Issue issue, Rule rule, RulePriority severity) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java index 3025da02f0d..11b8be7a456 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java @@ -122,7 +122,7 @@ public class JSONReport implements Reporter { writeJsonIssues(json, ruleKeys, userLogins); writeJsonComponents(json); writeJsonRules(json, ruleKeys); - Collection<BatchInput.User> users = userRepository.loadFromWs(new ArrayList<String>(userLogins)); + Collection<BatchInput.User> users = userRepository.loadFromWs(new ArrayList<>(userLogins)); writeUsers(json, users); json.endObject().close(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/ReportSummary.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/ReportSummary.java index 192d8f0d9d1..18e964fa262 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/ReportSummary.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/ReportSummary.java @@ -89,7 +89,7 @@ public class ReportSummary { } public List<RuleReport> getRuleReports() { - List<RuleReport> result = new ArrayList<RuleReport>(ruleReportByRuleKey.values()); + List<RuleReport> result = new ArrayList<>(ruleReportByRuleKey.values()); Collections.sort(result, new RuleReportComparator()); return result; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/ResourceReport.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/ResourceReport.java index 18a7fc8a1e3..e48ffc3e40a 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/ResourceReport.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/ResourceReport.java @@ -36,7 +36,7 @@ public final class ResourceReport { private final IssueVariation total = new IssueVariation(); private final Map<ReportRuleKey, RuleReport> ruleReportByRuleKey = Maps.newHashMap(); - private List<Issue> issues = new ArrayList<Issue>(); + private List<Issue> issues = new ArrayList<>(); private Map<Integer, List<Issue>> issuesPerLine = Maps.newHashMap(); private Map<Integer, List<Issue>> newIssuesPerLine = Maps.newHashMap(); private Map<Rule, AtomicInteger> issuesByRule = Maps.newHashMap(); @@ -146,7 +146,7 @@ public final class ResourceReport { } public List<RuleReport> getRuleReports() { - List<RuleReport> result = new ArrayList<RuleReport>(ruleReportByRuleKey.values()); + List<RuleReport> result = new ArrayList<>(ruleReportByRuleKey.values()); Collections.sort(result, new RuleReportComparator()); return result; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/SourceProvider.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/SourceProvider.java index 1f913e2b63f..bbe6106df06 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/SourceProvider.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/SourceProvider.java @@ -54,7 +54,7 @@ public class SourceProvider { try { InputFile inputFile = (InputFile) inputPathCache.getInputPath(component); List<String> lines = FileUtils.readLines(inputFile.file(), fs.encoding()); - List<String> escapedLines = new ArrayList<String>(lines.size()); + List<String> escapedLines = new ArrayList<>(lines.size()); for (String line : lines) { escapedLines.add(StringEscapeUtils.escapeHtml(line)); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameOutput.java b/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameOutput.java index d369b9efec1..399d2d3779f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameOutput.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameOutput.java @@ -49,7 +49,7 @@ class DefaultBlameOutput implements BlameOutput { private final BatchReportWriter writer; private final ResourceCache componentCache; - private final Set<InputFile> allFilesToBlame = new HashSet<InputFile>(); + private final Set<InputFile> allFilesToBlame = new HashSet<>(); private ProgressReport progressReport; private int count; private int total; diff --git a/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java b/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java index 526316f16f2..19e3abacd97 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java @@ -59,7 +59,7 @@ public final class ScmConfiguration implements Startable { private final ProjectReactor projectReactor; private final Settings settings; - private final Map<String, ScmProvider> providerPerKey = new LinkedHashMap<String, ScmProvider>(); + private final Map<String, ScmProvider> providerPerKey = new LinkedHashMap<>(); private final AnalysisMode analysisMode; private ScmProvider provider; diff --git a/sonar-batch/src/main/java/org/sonar/batch/scm/ScmSensor.java b/sonar-batch/src/main/java/org/sonar/batch/scm/ScmSensor.java index 51365f6d5c6..24492bbdc78 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scm/ScmSensor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scm/ScmSensor.java @@ -91,7 +91,7 @@ public final class ScmSensor implements Sensor { if (configuration.forceReloadAll()) { LOG.warn("Forced reloading of SCM data for all files."); } - List<InputFile> filesToBlame = new LinkedList<InputFile>(); + List<InputFile> filesToBlame = new LinkedList<>(); for (InputFile f : fs.inputFiles(fs.predicates().all())) { if (configuration.forceReloadAll()) { addIfNotEmpty(filesToBlame, f); diff --git a/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizers.java b/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizers.java index c8eb840272f..46dbef1bc93 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizers.java +++ b/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizers.java @@ -53,7 +53,7 @@ public class CodeColorizers { private final Map<String, CodeColorizerFormat> byLang; public CodeColorizers(List<CodeColorizerFormat> formats) { - byLang = new HashMap<String, CodeColorizerFormat>(); + byLang = new HashMap<>(); for (CodeColorizerFormat format : formats) { byLang.put(format.getLanguageKey(), format); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/source/DefaultSymbolTable.java b/sonar-batch/src/main/java/org/sonar/batch/source/DefaultSymbolTable.java index 2ab9999bf1b..e2bbf13bfa8 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/source/DefaultSymbolTable.java +++ b/sonar-batch/src/main/java/org/sonar/batch/source/DefaultSymbolTable.java @@ -41,7 +41,7 @@ public class DefaultSymbolTable implements Symbolizable.SymbolTable { @Override public List<Symbol> symbols() { - List<Symbol> result = new ArrayList<Symbol>(); + List<Symbol> result = new ArrayList<>(); for (Symbol symbol : referencesBySymbol.keySet()) { result.add((Symbol) symbol); } @@ -55,7 +55,7 @@ public class DefaultSymbolTable implements Symbolizable.SymbolTable { public static class Builder implements Symbolizable.SymbolTableBuilder { - private final Map<Symbol, Set<TextRange>> referencesBySymbol = new LinkedHashMap<Symbol, Set<TextRange>>(); + private final Map<Symbol, Set<TextRange>> referencesBySymbol = new LinkedHashMap<>(); private final DefaultInputFile inputFile; public Builder(DefaultInputFile inputFile) { @@ -66,7 +66,7 @@ public class DefaultSymbolTable implements Symbolizable.SymbolTable { public Symbol newSymbol(int fromOffset, int toOffset) { TextRange declarationRange = inputFile.newRange(fromOffset, toOffset); DefaultSymbol symbol = new DefaultSymbol(declarationRange, toOffset - fromOffset); - referencesBySymbol.put(symbol, new TreeSet<TextRange>(new Comparator<TextRange>() { + referencesBySymbol.put(symbol, new TreeSet<>(new Comparator<TextRange>() { @Override public int compare(TextRange o1, TextRange o2) { return o1.start().compareTo(o2.start()); diff --git a/sonar-batch/src/main/java/org/sonar/batch/source/HighlightingRenderer.java b/sonar-batch/src/main/java/org/sonar/batch/source/HighlightingRenderer.java index 6858d6de1f0..dca733fd1f8 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/source/HighlightingRenderer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/source/HighlightingRenderer.java @@ -32,7 +32,7 @@ import java.util.List; public class HighlightingRenderer { public void render(Reader code, List<? extends Channel<HtmlCodeBuilder>> tokenizers, NewHighlighting highlighting) { - List<Channel<HtmlCodeBuilder>> allTokenizers = new ArrayList<Channel<HtmlCodeBuilder>>(); + List<Channel<HtmlCodeBuilder>> allTokenizers = new ArrayList<>(); HighlightingCodeBuilder codeBuilder = new HighlightingCodeBuilder(highlighting); allTokenizers.addAll(tokenizers); diff --git a/sonar-batch/src/test/java/org/sonar/batch/design/DirectoryDsmDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/design/DirectoryDsmDecoratorTest.java index 7cc8ca87bc1..e24265ab7cf 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/design/DirectoryDsmDecoratorTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/design/DirectoryDsmDecoratorTest.java @@ -139,7 +139,7 @@ public class DirectoryDsmDecoratorTest { when(index.getOutgoingEdges(file1)).thenReturn(Arrays.asList(dependency)); when(index.getIncomingEdges(file2)).thenReturn(Arrays.asList(dependency)); - List<DecoratorContext> contexts = new ArrayList<DecoratorContext>(201); + List<DecoratorContext> contexts = new ArrayList<>(201); contexts.add(file1Context); contexts.add(file2Context); for (int i = 0; i < 199; i++) { diff --git a/sonar-batch/src/test/java/org/sonar/batch/design/DsmSerializerTest.java b/sonar-batch/src/test/java/org/sonar/batch/design/DsmSerializerTest.java index 5d9b0b508ef..5d807287771 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/design/DsmSerializerTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/design/DsmSerializerTest.java @@ -37,7 +37,7 @@ import static org.junit.Assert.assertThat; public class DsmSerializerTest { @Test public void serializeEmptyDsm() { - Dsm<Resource> dsm = new Dsm<Resource>(new DirectedGraph<Resource, Edge<Resource>>()); + Dsm<Resource> dsm = new Dsm<>(new DirectedGraph<Resource, Edge<Resource>>()); assertThat(DsmSerializer.serialize(dsm), is("[]")); } @@ -47,12 +47,12 @@ public class DsmSerializerTest { Resource bar = Directory.create("src/org/bar").setId(8); Dependency dep = new Dependency(foo, bar).setId(30l).setWeight(1); - DirectedGraph<Resource, Dependency> graph = new DirectedGraph<Resource, Dependency>(); + DirectedGraph<Resource, Dependency> graph = new DirectedGraph<>(); graph.addVertex(foo); graph.addVertex(bar); graph.addEdge(dep); - Dsm<Resource> dsm = new Dsm<Resource>(graph); + Dsm<Resource> dsm = new Dsm<>(graph); DsmManualSorter.sort(dsm, bar, foo); // for test reproductibility String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/batch/design/DsmSerializerTest/dsm.json")).trim(); assertThat(DsmSerializer.serialize(dsm), is(json)); diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java index 8849aadf68a..0fdd3d51534 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java @@ -341,7 +341,7 @@ public class ProjectReactorBuilderTest { @Test public void shouldFailIfMandatoryPropertiesAreNotPresent() { - Map<String, String> props = new HashMap<String, String>(); + Map<String, String> props = new HashMap<>(); props.put("foo1", "bla"); props.put("foo4", "bla"); @@ -353,7 +353,7 @@ public class ProjectReactorBuilderTest { @Test public void shouldFailIfMandatoryPropertiesAreNotPresentButWithProjectKey() { - Map<String, String> props = new HashMap<String, String>(); + Map<String, String> props = new HashMap<>(); props.put("foo1", "bla"); props.put("sonar.projectKey", "my-project"); @@ -365,7 +365,7 @@ public class ProjectReactorBuilderTest { @Test public void shouldNotFailIfMandatoryPropertiesArePresent() { - Map<String, String> props = new HashMap<String, String>(); + Map<String, String> props = new HashMap<>(); props.put("foo1", "bla"); props.put("foo4", "bla"); @@ -410,13 +410,13 @@ public class ProjectReactorBuilderTest { int i = (int) Math.random() * 10; String s1 = "value" + i; String s2 = "value" + i; - Map<String, String> parentProps = new HashMap<String, String>(); + Map<String, String> parentProps = new HashMap<>(); parentProps.put("toBeMergeProps", "fooParent"); parentProps.put("existingChildProp", "barParent"); parentProps.put("duplicatedProp", s1); parentProps.put("sonar.projectDescription", "Desc from Parent"); - Map<String, String> childProps = new HashMap<String, String>(); + Map<String, String> childProps = new HashMap<>(); childProps.put("existingChildProp", "barChild"); childProps.put("otherProp", "tutuChild"); childProps.put("duplicatedProp", s2); @@ -492,7 +492,7 @@ public class ProjectReactorBuilderTest { @Test public void shouldSetModuleKeyIfNotPresent() { - Map<String, String> props = new HashMap<String, String>(); + Map<String, String> props = new HashMap<>(); props.put("sonar.projectVersion", "1.0"); // should be set @@ -532,7 +532,7 @@ public class ProjectReactorBuilderTest { } public Map<String, String> toMap(Properties props) { - Map<String, String> result = new HashMap<String, String>(); + Map<String, String> result = new HashMap<>(); for (Map.Entry<Object, Object> entry : props.entrySet()) { result.put(entry.getKey().toString(), entry.getValue().toString()); } @@ -541,7 +541,7 @@ public class ProjectReactorBuilderTest { @Test public void shouldGetList() { - Map<String, String> props = new HashMap<String, String>(); + Map<String, String> props = new HashMap<>(); props.put("prop", " foo , bar , \n\ntoto,tutu"); assertThat(ProjectReactorBuilder.getListFromProperty(props, "prop")).containsOnly("foo", "bar", "toto", "tutu"); @@ -635,7 +635,7 @@ public class ProjectReactorBuilderTest { try (FileInputStream fileInputStream = new FileInputStream(TestUtils.getResource(this.getClass(), filePath))) { props.load(fileInputStream); } - Map<String, String> result = new HashMap<String, String>(); + Map<String, String> result = new HashMap<>(); for (Map.Entry<Object, Object> entry : props.entrySet()) { result.put(entry.getKey().toString(), entry.getValue().toString()); } diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlRenderer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlRenderer.java index a95a4348991..7e3d42436fa 100644 --- a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlRenderer.java +++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlRenderer.java @@ -45,7 +45,7 @@ public class HtmlRenderer extends Renderer { @Override public String render(Reader code, List<? extends Channel<HtmlCodeBuilder>> tokenizers) { try { - List<Channel<HtmlCodeBuilder>> allTokenizers = new ArrayList<Channel<HtmlCodeBuilder>>(); + List<Channel<HtmlCodeBuilder>> allTokenizers = new ArrayList<>(); HtmlCodeBuilder codeBuilder = new HtmlCodeBuilder(); HtmlDecorator htmlDecorator = new HtmlDecorator(options); diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/KeywordsTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/KeywordsTokenizer.java index 06025a33d37..3a175633d0a 100644 --- a/sonar-colorizer/src/main/java/org/sonar/colorizer/KeywordsTokenizer.java +++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/KeywordsTokenizer.java @@ -40,7 +40,7 @@ public class KeywordsTokenizer extends NotThreadSafeTokenizer { private final StringBuilder tmpBuilder = new StringBuilder(); private static final String DEFAULT_REGEX = "[a-zA-Z_][a-zA-Z0-9_]*+"; - private Set<String> keywords = new HashSet<String>(); + private Set<String> keywords = new HashSet<>(); public KeywordsTokenizer(String tagBefore, String tagAfter, Set<String> keywords) { this(tagBefore, tagAfter, keywords, DEFAULT_REGEX); diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java index ed30d457e95..d3a5c4cb217 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java @@ -102,7 +102,7 @@ public class CodeColorizerTest { } } - Collection<Callable<String>> tasks = new ArrayList<Callable<String>>(); + Collection<Callable<String>> tasks = new ArrayList<>(); for (int i = 0; i < taskCount; i++) { tasks.add(new ColorizerTask()); } diff --git a/sonar-core/src/main/java/org/sonar/core/component/ScanGraph.java b/sonar-core/src/main/java/org/sonar/core/component/ScanGraph.java index ce76fe74c2a..d02a13b01fb 100644 --- a/sonar-core/src/main/java/org/sonar/core/component/ScanGraph.java +++ b/sonar-core/src/main/java/org/sonar/core/component/ScanGraph.java @@ -69,7 +69,7 @@ public class ScanGraph extends BeanGraph { public Iterable<ComponentVertex> getComponents() { Iterable<Vertex> componentVertices = componentsRoot.getVertices(Direction.OUT, COMPONENT); - return new BeanIterable<ComponentVertex>(this, ComponentVertex.class, componentVertices); + return new BeanIterable<>(this, ComponentVertex.class, componentVertices); } public ComponentVertex addComponent(Component component) { diff --git a/sonar-core/src/main/java/org/sonar/core/graph/BeanVertex.java b/sonar-core/src/main/java/org/sonar/core/graph/BeanVertex.java index 749efd22222..d1f544b144b 100644 --- a/sonar-core/src/main/java/org/sonar/core/graph/BeanVertex.java +++ b/sonar-core/src/main/java/org/sonar/core/graph/BeanVertex.java @@ -25,10 +25,10 @@ import com.tinkerpop.blueprints.Vertex; public abstract class BeanVertex extends BeanElement<Vertex, BeanVertex> { protected final <T extends BeanEdge> Iterable<T> getEdges(Class<T> edgeClass, Direction direction, String... labels) { - return new BeanIterable<T>(beanGraph(), edgeClass, element().getEdges(direction, labels)); + return new BeanIterable<>(beanGraph(), edgeClass, element().getEdges(direction, labels)); } protected final <T extends BeanVertex> Iterable<T> getVertices(Class<T> vertexClass, Direction direction, String... labels) { - return new BeanIterable<T>(beanGraph(), vertexClass, element().getVertices(direction, labels)); + return new BeanIterable<>(beanGraph(), vertexClass, element().getVertices(direction, labels)); } } diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java index 61631162061..241d2645140 100644 --- a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java +++ b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java @@ -224,7 +224,7 @@ class GraphsonUtil { } static Map<String, Object> readProperties(JSONObject node, boolean ignoreReservedKeys, boolean hasEmbeddedTypes) { - Map<String, Object> map = new HashMap<String, Object>(); + Map<String, Object> map = new HashMap<>(); for (Object objKey : node.keySet()) { String key = (String) objKey; @@ -398,7 +398,7 @@ class GraphsonUtil { } private static Map createPropertyMap(Element element, Set<String> propertyKeys, ElementPropertiesRule rule) { - Map map = new HashMap<String, Object>(); + Map map = new HashMap<>(); if (propertyKeys == null) { for (String key : element.getPropertyKeys()) { diff --git a/sonar-core/src/main/java/org/sonar/core/permission/PermissionFacade.java b/sonar-core/src/main/java/org/sonar/core/permission/PermissionFacade.java index 0d8399f6cfd..5e849618486 100644 --- a/sonar-core/src/main/java/org/sonar/core/permission/PermissionFacade.java +++ b/sonar-core/src/main/java/org/sonar/core/permission/PermissionFacade.java @@ -214,7 +214,7 @@ public class PermissionFacade { */ private String getApplicablePermissionTemplateKey(DbSession session, final String componentKey, String qualifier) { List<PermissionTemplateDto> allPermissionTemplates = permissionTemplateDao.selectAllPermissionTemplates(session); - List<PermissionTemplateDto> matchingTemplates = new ArrayList<PermissionTemplateDto>(); + List<PermissionTemplateDto> matchingTemplates = new ArrayList<>(); for (PermissionTemplateDto permissionTemplateDto : allPermissionTemplates) { String keyPattern = permissionTemplateDto.getKeyPattern(); if (StringUtils.isNotBlank(keyPattern) && componentKey.matches(keyPattern)) { diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DbSession.java b/sonar-core/src/main/java/org/sonar/core/persistence/DbSession.java index 503d302112f..63a7f6b856d 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DbSession.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DbSession.java @@ -44,7 +44,7 @@ public class DbSession implements SqlSession { this.actionCount = 0; this.session = session; this.queue = queue; - this.actions = new ArrayList<ClusterAction>(); + this.actions = new ArrayList<>(); } public void enqueue(ClusterAction action) { diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java index a294dce2a6b..9f211cbd35a 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java @@ -134,7 +134,7 @@ public class PurgeDao { } private void disableOrphanResources(final ResourceDto project, final SqlSession session, final PurgeMapper purgeMapper, final PurgeListener purgeListener) { - final List<IdUuidPair> componentIdUuids = new ArrayList<IdUuidPair>(); + final List<IdUuidPair> componentIdUuids = new ArrayList<>(); session.select("org.sonar.core.purge.PurgeMapper.selectComponentIdUuidsToDisable", project.getId(), new ResultHandler() { @Override public void handleResult(ResultContext resultContext) { diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeProfiler.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeProfiler.java index e3552b5b66c..96c03fe4112 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeProfiler.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeProfiler.java @@ -33,7 +33,7 @@ import java.util.Map.Entry; public class PurgeProfiler { - private Map<String, Long> durations = new HashMap<String, Long>(); + private Map<String, Long> durations = new HashMap<>(); private long startTime; private String currentTable; private final Clock clock; @@ -67,7 +67,7 @@ public class PurgeProfiler { } public void dump(long totalTime, Logger logger) { - List<Entry<String, Long>> data = new ArrayList<Map.Entry<String, Long>>(durations.entrySet()); + List<Entry<String, Long>> data = new ArrayList<>(durations.entrySet()); Collections.sort(data, new Comparator<Entry<String, Long>>() { @Override public int compare(Entry<String, Long> o1, Entry<String, Long> o2) { @@ -85,7 +85,7 @@ public class PurgeProfiler { private List<Entry<String, Long>> truncateList(List<Entry<String, Long>> sortedFullList) { int maxSize = 10; - List<Entry<String, Long>> result = new ArrayList<Entry<String, Long>>(maxSize); + List<Entry<String, Long>> result = new ArrayList<>(maxSize); int i = 0; for (Entry<String, Long> item : sortedFullList) { if (i++ >= maxSize || item.getValue() == 0) { diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleParamDto.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleParamDto.java index 70bc208b4f4..630adc21a84 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleParamDto.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleParamDto.java @@ -96,7 +96,7 @@ public class ActiveRuleParamDto { } public static Map<String,ActiveRuleParamDto> groupByKey(Collection<ActiveRuleParamDto> params) { - Map<String, ActiveRuleParamDto> result = new HashMap<String, ActiveRuleParamDto>(); + Map<String, ActiveRuleParamDto> result = new HashMap<>(); for (ActiveRuleParamDto param : params) { result.put(param.getKey(), param); } diff --git a/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java b/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java index 564acb64baa..a027c98aa40 100644 --- a/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java @@ -120,7 +120,7 @@ public final class CacheRuleFinder implements RuleFinder { private Query createHqlQuery(DatabaseSession session, RuleQuery query) { StringBuilder hql = new StringBuilder().append("from ").append(Rule.class.getSimpleName()).append(" where status<>:status "); - Map<String, Object> params = new HashMap<String, Object>(); + Map<String, Object> params = new HashMap<>(); params.put("status", Rule.STATUS_REMOVED); if (StringUtils.isNotBlank(query.getRepositoryKey())) { hql.append("AND pluginName=:repositoryKey "); diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java index 9b1fff40e27..bbfd1f0b863 100644 --- a/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java @@ -328,13 +328,13 @@ public class RuleDto extends Dto<RuleKey> { public Set<String> getTags() { return tags == null ? new HashSet<String>() : - new TreeSet<String>(Arrays.asList(StringUtils.split(tags, ','))); + new TreeSet<>(Arrays.asList(StringUtils.split(tags, ','))); } public Set<String> getSystemTags() { return systemTags == null ? new HashSet<String>() : - new TreeSet<String>(Arrays.asList(StringUtils.split(systemTags, ','))); + new TreeSet<>(Arrays.asList(StringUtils.split(systemTags, ','))); } private String getTagsField() { diff --git a/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java b/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java index 1cc6d0b9cfb..1ed2f16042a 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java @@ -34,7 +34,7 @@ import static com.google.common.collect.Lists.newArrayList; public class MeasuresDao { private final DatabaseSession session; - private final Map<String, Metric> metricsByName = new HashMap<String, Metric>(); + private final Map<String, Metric> metricsByName = new HashMap<>(); public MeasuresDao(DatabaseSession session) { this.session = session; diff --git a/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java b/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java index e97b35176d7..ab43555dd4f 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java +++ b/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java @@ -213,7 +213,7 @@ public class JpaDatabaseSession extends DatabaseSession { return defaultValue; } else { - Set<T> uniqueResult = new HashSet<T>(result); + Set<T> uniqueResult = new HashSet<>(result); if (uniqueResult.size() > 1) { throw new NonUniqueResultException("Expected single result, but got : " + result.toString()); } else { diff --git a/sonar-core/src/main/java/org/sonar/jpa/session/ThreadLocalDatabaseSessionFactory.java b/sonar-core/src/main/java/org/sonar/jpa/session/ThreadLocalDatabaseSessionFactory.java index 9d4a05efcb0..661598b37cd 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/session/ThreadLocalDatabaseSessionFactory.java +++ b/sonar-core/src/main/java/org/sonar/jpa/session/ThreadLocalDatabaseSessionFactory.java @@ -23,7 +23,7 @@ import org.sonar.api.database.DatabaseSession; public class ThreadLocalDatabaseSessionFactory implements DatabaseSessionFactory { - private final ThreadLocal<JpaDatabaseSession> threadSession = new ThreadLocal<JpaDatabaseSession>(); + private final ThreadLocal<JpaDatabaseSession> threadSession = new ThreadLocal<>(); private final DatabaseConnector connector; public ThreadLocalDatabaseSessionFactory(DatabaseConnector connector) { diff --git a/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonReaderTest.java b/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonReaderTest.java index c877a1493bc..b63cd4de940 100644 --- a/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonReaderTest.java +++ b/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonReaderTest.java @@ -235,7 +235,7 @@ public class GraphsonReaderTest { StringWriter stream = new StringWriter(); - Set<String> edgeKeys = new HashSet<String>(); + Set<String> edgeKeys = new HashSet<>(); edgeKeys.add(GraphsonTokens._ID); edgeKeys.add(GraphsonTokens._IN_V); edgeKeys.add(GraphsonTokens._OUT_V); @@ -293,7 +293,7 @@ public class GraphsonReaderTest { StringWriter stream = new StringWriter(); - Set<String> edgeKeys = new HashSet<String>(); + Set<String> edgeKeys = new HashSet<>(); edgeKeys.add(GraphsonTokens._IN_V); edgeKeys.add(GraphsonTokens._OUT_V); edgeKeys.add(GraphsonTokens._LABEL); diff --git a/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonUtilTest.java b/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonUtilTest.java index 6fb3611a9ef..e021175f810 100644 --- a/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonUtilTest.java +++ b/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonUtilTest.java @@ -288,7 +288,7 @@ public class GraphsonUtilTest { @Test public void jsonFromElementVertexListPropertyNoKeysNoTypes() { Vertex v = this.graph.addVertex(1); - List<Object> list = new ArrayList<Object>(); + List<Object> list = new ArrayList<>(); list.add("this"); list.add("that"); list.add("other"); @@ -447,7 +447,7 @@ public class GraphsonUtilTest { @Test public void jsonFromElementVertexCatArrayPropertyNoKeysNoTypes() { Vertex v = this.graph.addVertex(1); - List<Cat> cats = new ArrayList<Cat>(); + List<Cat> cats = new ArrayList<>(); cats.add(new Cat("smithers")); cats.add(new Cat("mcallister")); @@ -521,7 +521,7 @@ public class GraphsonUtilTest { v.setProperty("y", "Y"); v.setProperty("z", "Z"); - Set<String> propertiesToInclude = new HashSet<String>(); + Set<String> propertiesToInclude = new HashSet<>(); propertiesToInclude.add("y"); JSONObject json = GraphsonUtil.jsonFromElement(v, propertiesToInclude, GraphsonMode.NORMAL); @@ -547,7 +547,7 @@ public class GraphsonUtilTest { v.setProperty("v", innerV); - Set<String> propertiesToInclude = new HashSet<String>(); + Set<String> propertiesToInclude = new HashSet<>(); propertiesToInclude.add("y"); propertiesToInclude.add("v"); @@ -624,7 +624,7 @@ public class GraphsonUtilTest { @Test public void jsonFromElementVertexListPropertiesNoKeysWithTypes() { Vertex v = this.graph.addVertex(1); - List<String> list = new ArrayList<String>(); + List<String> list = new ArrayList<>(); list.add("this"); list.add("this"); list.add("this"); @@ -659,7 +659,7 @@ public class GraphsonUtilTest { @Test public void jsonFromElementVertexBooleanListPropertiesNoKeysWithTypes() { Vertex v = this.graph.addVertex(1); - List<Boolean> list = new ArrayList<Boolean>(); + List<Boolean> list = new ArrayList<>(); list.add(true); list.add(true); list.add(true); @@ -694,7 +694,7 @@ public class GraphsonUtilTest { @Test public void jsonFromElementVertexLongListPropertiesNoKeysWithTypes() { Vertex v = this.graph.addVertex(1); - List<Long> list = new ArrayList<Long>(); + List<Long> list = new ArrayList<>(); list.add(1000L); list.add(1000L); list.add(1000L); @@ -729,7 +729,7 @@ public class GraphsonUtilTest { @Test public void jsonFromElementVertexIntListPropertiesNoKeysWithTypes() { Vertex v = this.graph.addVertex(1); - List<Integer> list = new ArrayList<Integer>(); + List<Integer> list = new ArrayList<>(); list.add(1); list.add(1); list.add(1); @@ -764,12 +764,12 @@ public class GraphsonUtilTest { @Test public void jsonFromElementVertexListOfListPropertiesNoKeysWithTypes() { Vertex v = this.graph.addVertex(1); - List<Integer> list = new ArrayList<Integer>(); + List<Integer> list = new ArrayList<>(); list.add(1); list.add(1); list.add(1); - List<List<Integer>> listList = new ArrayList<List<Integer>>(); + List<List<Integer>> listList = new ArrayList<>(); listList.add(list); v.setProperty("keyList", listList); @@ -846,17 +846,17 @@ public class GraphsonUtilTest { Vertex v = g.addVertex(1); v.setProperty("key", null); - Map<String, Object> map = new HashMap<String, Object>(); + Map<String, Object> map = new HashMap<>(); map.put("innerkey", null); - List<String> innerList = new ArrayList<String>(); + List<String> innerList = new ArrayList<>(); innerList.add(null); innerList.add("innerstring"); map.put("list", innerList); v.setProperty("keyMap", map); - List<String> list = new ArrayList<String>(); + List<String> list = new ArrayList<>(); list.add(null); list.add("string"); v.setProperty("keyList", list); @@ -888,17 +888,17 @@ public class GraphsonUtilTest { Vertex v = g.addVertex(1); v.setProperty("key", null); - Map<String, Object> map = new HashMap<String, Object>(); + Map<String, Object> map = new HashMap<>(); map.put("innerkey", null); - List<String> innerList = new ArrayList<String>(); + List<String> innerList = new ArrayList<>(); innerList.add(null); innerList.add("innerstring"); map.put("list", innerList); v.setProperty("keyMap", map); - List<String> list = new ArrayList<String>(); + List<String> list = new ArrayList<>(); list.add(null); list.add("string"); v.setProperty("keyList", list); @@ -998,7 +998,7 @@ public class GraphsonUtilTest { Graph g = new TinkerGraph(); ElementFactory factory = new ElementFactory(g); - Set<String> ignoreAge = new HashSet<String>(); + Set<String> ignoreAge = new HashSet<>(); ignoreAge.add("age"); ElementPropertyConfig config = ElementPropertyConfig.excludeProperties(ignoreAge, null); GraphsonUtil utility = new GraphsonUtil(GraphsonMode.NORMAL, factory, config); @@ -1062,7 +1062,7 @@ public class GraphsonUtilTest { Vertex v1 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphsonMode.NORMAL, null); Vertex v2 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2), factory, GraphsonMode.NORMAL, null); - Set<String> ignoreWeight = new HashSet<String>(); + Set<String> ignoreWeight = new HashSet<>(); ignoreWeight.add("weight"); ElementPropertyConfig config = ElementPropertyConfig.excludeProperties(null, ignoreWeight); GraphsonUtil utility = new GraphsonUtil(GraphsonMode.NORMAL, factory, config); diff --git a/sonar-deprecated/src/main/java/org/sonar/api/charts/ChartParameters.java b/sonar-deprecated/src/main/java/org/sonar/api/charts/ChartParameters.java index dbd6cc9addc..e898e621f21 100644 --- a/sonar-deprecated/src/main/java/org/sonar/api/charts/ChartParameters.java +++ b/sonar-deprecated/src/main/java/org/sonar/api/charts/ChartParameters.java @@ -67,7 +67,7 @@ public class ChartParameters { * @param queryString string */ public ChartParameters(String queryString) { - this.params = new HashMap<String, String>(); + this.params = new HashMap<>(); String[] groups = StringUtils.split(queryString, "&"); for (String group : groups) { String[] keyval = StringUtils.split(group, "="); diff --git a/sonar-deprecated/src/main/java/org/sonar/api/rules/XMLRuleParser.java b/sonar-deprecated/src/main/java/org/sonar/api/rules/XMLRuleParser.java index ed1752d49c5..b7a0a3772c3 100644 --- a/sonar-deprecated/src/main/java/org/sonar/api/rules/XMLRuleParser.java +++ b/sonar-deprecated/src/main/java/org/sonar/api/rules/XMLRuleParser.java @@ -98,7 +98,7 @@ public final class XMLRuleParser { try { SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader); rootC.advance(); // <rules> - List<Rule> rules = new ArrayList<Rule>(); + List<Rule> rules = new ArrayList<>(); SMInputCursor rulesC = rootC.childElementCursor("rule"); while (rulesC.getNext() != null) { diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/NoSonarFilterTest.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/NoSonarFilterTest.java index d2d098b9402..8656fa5d48a 100644 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/NoSonarFilterTest.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/checks/NoSonarFilterTest.java @@ -52,7 +52,7 @@ public class NoSonarFilterTest { @Test public void ignoreLinesCommentedWithNoSonar() { - Set<Integer> noSonarLines = new HashSet<Integer>(); + Set<Integer> noSonarLines = new HashSet<>(); noSonarLines.add(31); noSonarLines.add(55); filter.addResource(javaFile, noSonarLines); @@ -75,7 +75,7 @@ public class NoSonarFilterTest { public void should_accept_violations_from_no_sonar_rules() { // The "No Sonar" rule logs violations on the lines that are flagged with "NOSONAR" !! - Set<Integer> noSonarLines = new HashSet<Integer>(); + Set<Integer> noSonarLines = new HashSet<>(); noSonarLines.add(31); filter.addResource(javaFile, noSonarLines); diff --git a/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/SourceCode.java b/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/SourceCode.java index cf886d01122..57501d25d7a 100644 --- a/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/SourceCode.java +++ b/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/SourceCode.java @@ -50,7 +50,7 @@ public class SourceCode { if (c != null) { return c; } - this.code = new SoftReference<List<String>>(load()); + this.code = new SoftReference<>(load()); return code.get(); } @@ -62,7 +62,7 @@ public class SourceCode { LineNumberReader lnr = null; try { lnr = new LineNumberReader(getReader()); - List<String> lines = new ArrayList<String>(); + List<String> lines = new ArrayList<>(); String currentLine; while ((currentLine = lnr.readLine()) != null) { lines.add(currentLine); diff --git a/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java b/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java index be1bfb4bc83..395c9f9bdc2 100644 --- a/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java +++ b/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java @@ -34,7 +34,7 @@ import java.util.Map; */ public class TokenEntry implements Comparable<TokenEntry> { - private static final Map<String, Integer> TOKENS = new HashMap<String, Integer>(); + private static final Map<String, Integer> TOKENS = new HashMap<>(); private static int tokenCount = 0; /** diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/AbstractText.java b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/AbstractText.java index 0a13ccf1b29..6c3dde2496c 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/AbstractText.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/AbstractText.java @@ -27,7 +27,7 @@ public abstract class AbstractText implements Text { protected final List<Object> symbols; public AbstractText(int size) { - this.symbols = new ArrayList<Object>(size); + this.symbols = new ArrayList<>(size); } public AbstractText(List<Object> symbols) { diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/Node.java b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/Node.java index c94a89b407f..c6a95c9cae1 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/Node.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/Node.java @@ -54,7 +54,7 @@ public final class Node { public Node(SuffixTree suffixTree, Node suffixNode) { this.suffixTree = suffixTree; this.suffixNode = suffixNode; - edges = new HashMap<Object, Edge>(); + edges = new HashMap<>(); } public Object symbolAt(int index) { diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/index/CloneGroup.java b/sonar-duplications/src/main/java/org/sonar/duplications/index/CloneGroup.java index 01b7273da1c..05eab3dd108 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/index/CloneGroup.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/index/CloneGroup.java @@ -55,7 +55,7 @@ public class CloneGroup { private ClonePart origin; private int length; private int lengthInUnits; - private List<ClonePart> parts = new ArrayList<ClonePart>(); + private List<ClonePart> parts = new ArrayList<>(); public Builder setLength(int length) { this.length = length; diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChannel.java b/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChannel.java index d734b5dfa0a..39d45ede76b 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChannel.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChannel.java @@ -48,7 +48,7 @@ public final class StatementChannel { } public boolean consume(TokenQueue tokenQueue, List<Statement> output) { - List<Token> matchedTokenList = new ArrayList<Token>(); + List<Token> matchedTokenList = new ArrayList<>(); for (TokenMatcher tokenMatcher : tokenMatchers) { if (!tokenMatcher.matchToken(tokenQueue, matchedTokenList)) { tokenQueue.pushForward(matchedTokenList); diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChunker.java b/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChunker.java index 5223dbc96ed..3631d3e722b 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChunker.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChunker.java @@ -42,7 +42,7 @@ public final class StatementChunker { if (tokenQueue == null) { throw new IllegalArgumentException(); } - List<Statement> statements = new ArrayList<Statement>(); + List<Statement> statements = new ArrayList<>(); try { channelDispatcher.consume(tokenQueue, statements); return statements; @@ -58,7 +58,7 @@ public final class StatementChunker { */ public static final class Builder { - private List<StatementChannel> channels = new ArrayList<StatementChannel>(); + private List<StatementChannel> channels = new ArrayList<>(); private Builder() { } diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/statement/matcher/UptoTokenMatcher.java b/sonar-duplications/src/main/java/org/sonar/duplications/statement/matcher/UptoTokenMatcher.java index 1b0220009af..5e2928a1d61 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/statement/matcher/UptoTokenMatcher.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/statement/matcher/UptoTokenMatcher.java @@ -31,7 +31,7 @@ import org.sonar.duplications.token.TokenQueue; */ public class UptoTokenMatcher extends TokenMatcher { - private final Set<String> uptoMatchTokens = new HashSet<String>(); + private final Set<String> uptoMatchTokens = new HashSet<>(); public UptoTokenMatcher(String[] uptoMatchTokens) { if (uptoMatchTokens == null) { diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/token/TokenQueue.java b/sonar-duplications/src/main/java/org/sonar/duplications/token/TokenQueue.java index 433238f3db4..a6894bb46b9 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/token/TokenQueue.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/token/TokenQueue.java @@ -30,11 +30,11 @@ public class TokenQueue implements Iterable<Token> { private final Deque<Token> tokenQueue; public TokenQueue(List<Token> tokenList) { - tokenQueue = new LinkedList<Token>(tokenList); + tokenQueue = new LinkedList<>(tokenList); } public TokenQueue() { - tokenQueue = new LinkedList<Token>(); + tokenQueue = new LinkedList<>(); } /** diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/detector/suffixtree/StringSuffixTree.java b/sonar-duplications/src/test/java/org/sonar/duplications/detector/suffixtree/StringSuffixTree.java index b3074712146..346c5fba01c 100644 --- a/sonar-duplications/src/test/java/org/sonar/duplications/detector/suffixtree/StringSuffixTree.java +++ b/sonar-duplications/src/test/java/org/sonar/duplications/detector/suffixtree/StringSuffixTree.java @@ -38,7 +38,7 @@ public class StringSuffixTree { private StringSuffixTree(String text) { suffixTree = SuffixTree.create(new StringText(text)); - Queue<Node> queue = new LinkedList<Node>(); + Queue<Node> queue = new LinkedList<>(); queue.add(suffixTree.getRootNode()); while (!queue.isEmpty()) { Node node = queue.remove(); diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/token/TokenQueueTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/token/TokenQueueTest.java index 5561f117dce..9495eeace8c 100644 --- a/sonar-duplications/src/test/java/org/sonar/duplications/token/TokenQueueTest.java +++ b/sonar-duplications/src/test/java/org/sonar/duplications/token/TokenQueueTest.java @@ -34,7 +34,7 @@ public class TokenQueueTest { @Before public void initTest() { - List<Token> tokenList = new ArrayList<Token>(); + List<Token> tokenList = new ArrayList<>(); tokenList.add(new Token("a", 1, 0)); tokenList.add(new Token("bc", 1, 2)); tokenList.add(new Token("def", 1, 5)); @@ -58,7 +58,7 @@ public class TokenQueueTest { @Test public void shouldPushTokenAtBegining() { Token pushedToken = new Token("push", 1, 0); - List<Token> pushedTokenList = new ArrayList<Token>(); + List<Token> pushedTokenList = new ArrayList<>(); pushedTokenList.add(pushedToken); tokenQueue.pushForward(pushedTokenList); assertThat(tokenQueue.peek(), is(pushedToken)); diff --git a/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java b/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java index 29402fcc978..49a9b4c9f60 100644 --- a/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java +++ b/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java @@ -30,7 +30,7 @@ public class CycleDetector<V> { private Set<V> vertices; private DirectedGraphAccessor<V, ? extends Edge> graph; private Set<V> analyzedVertices; - private Set<Cycle> cycles = new LinkedHashSet<Cycle>(); + private Set<Cycle> cycles = new LinkedHashSet<>(); private Set<Edge> edgesToExclude; private long searchCyclesCalls = 0; private int maxSearchDepth = -1; @@ -55,8 +55,8 @@ public class CycleDetector<V> { private void init(DirectedGraphAccessor<V, ? extends Edge> graph, Collection<V> vertices, Set<Edge> edgesToExclude) { this.graph = graph; - this.vertices = new LinkedHashSet<V>(vertices); - this.analyzedVertices = new LinkedHashSet<V>(); + this.vertices = new LinkedHashSet<>(vertices); + this.analyzedVertices = new LinkedHashSet<>(); this.edgesToExclude = edgesToExclude; } @@ -87,7 +87,7 @@ public class CycleDetector<V> { try { for (V vertex : vertices) { if (maxSearchDepthActivated || !analyzedVertices.contains(vertex)) { - Set<V> tmpAnalyzedVertices = new LinkedHashSet<V>(); + Set<V> tmpAnalyzedVertices = new LinkedHashSet<>(); searchCycles(vertex, new ArrayList<V>(), tmpAnalyzedVertices); analyzedVertices.addAll(tmpAnalyzedVertices); } @@ -124,7 +124,7 @@ public class CycleDetector<V> { } private Cycle convertListOfVerticesToCycle(List<V> vertices) { - List<Edge> edges = new ArrayList<Edge>(); + List<Edge> edges = new ArrayList<>(); V firstVertex = vertices.get(0); V from = firstVertex; for (int index = 1; index < vertices.size(); index++) { diff --git a/sonar-graph/src/main/java/org/sonar/graph/DirectedGraph.java b/sonar-graph/src/main/java/org/sonar/graph/DirectedGraph.java index c0d63887b89..9dab7d83b5f 100644 --- a/sonar-graph/src/main/java/org/sonar/graph/DirectedGraph.java +++ b/sonar-graph/src/main/java/org/sonar/graph/DirectedGraph.java @@ -30,9 +30,9 @@ import java.util.Set; public class DirectedGraph<V, E extends Edge<V>> implements DirectedGraphAccessor<V, E> { private EdgeFactory<V, E> edgeFactory; - private Map<V, Map<V, E>> outgoingEdgesByVertex = new HashMap<V, Map<V, E>>(); - private Map<V, Map<V, E>> incomingEdgesByVertex = new HashMap<V, Map<V, E>>(); - private Set<V> vertices = new LinkedHashSet<V>(); + private Map<V, Map<V, E>> outgoingEdgesByVertex = new HashMap<>(); + private Map<V, Map<V, E>> incomingEdgesByVertex = new HashMap<>(); + private Set<V> vertices = new LinkedHashSet<>(); public DirectedGraph() { } @@ -42,7 +42,7 @@ public class DirectedGraph<V, E extends Edge<V>> implements DirectedGraphAccesso } public static DirectedGraph<String, StringEdge> createStringDirectedGraph() { - return new DirectedGraph<String, StringEdge>(new StringEdgeFactory()); + return new DirectedGraph<>(new StringEdgeFactory()); } public DirectedGraph<V, E> addEdge(V from, V to) { @@ -75,7 +75,7 @@ public class DirectedGraph<V, E extends Edge<V>> implements DirectedGraphAccesso private void addEdgeToMap(V vertexKey1, V vertexKey2, E edge, Map<V, Map<V, E>> edgesByVertex) { Map<V, E> edges = edgesByVertex.get(vertexKey1); if (edges == null) { - edges = new HashMap<V, E>(); + edges = new HashMap<>(); edgesByVertex.put(vertexKey1, edges); } if (edges.containsKey(vertexKey2)) { @@ -119,7 +119,7 @@ public class DirectedGraph<V, E extends Edge<V>> implements DirectedGraphAccesso } public List<E> getEdges(Collection<V> vertices) { - List<E> result = new ArrayList<E>(); + List<E> result = new ArrayList<>(); for (V vertice : vertices) { Collection<E> outgoingEdges = getOutgoingEdges(vertice); if (outgoingEdges != null) { @@ -133,7 +133,7 @@ public class DirectedGraph<V, E extends Edge<V>> implements DirectedGraphAccesso public Collection<E> getOutgoingEdges(V from) { Map<V, E> outgoingEdges = outgoingEdgesByVertex.get(from); if (outgoingEdges == null) { - return new LinkedHashSet<E>(); + return new LinkedHashSet<>(); } return outgoingEdges.values(); } @@ -142,7 +142,7 @@ public class DirectedGraph<V, E extends Edge<V>> implements DirectedGraphAccesso public Collection<E> getIncomingEdges(V to) { Map<V, E> incomingEdges = incomingEdgesByVertex.get(to); if (incomingEdges == null) { - return new LinkedHashSet<E>(); + return new LinkedHashSet<>(); } return incomingEdges.values(); } diff --git a/sonar-graph/src/main/java/org/sonar/graph/DsmManualSorter.java b/sonar-graph/src/main/java/org/sonar/graph/DsmManualSorter.java index de81d15096b..685dfbe348e 100644 --- a/sonar-graph/src/main/java/org/sonar/graph/DsmManualSorter.java +++ b/sonar-graph/src/main/java/org/sonar/graph/DsmManualSorter.java @@ -34,7 +34,7 @@ public final class DsmManualSorter<V> { } public static <V> void sort(Dsm<V> dsm, List<V> vertices) { - DsmManualSorter<V> sorter = new DsmManualSorter<V>(dsm, vertices); + DsmManualSorter<V> sorter = new DsmManualSorter<>(dsm, vertices); sorter.sort(); } diff --git a/sonar-graph/src/main/java/org/sonar/graph/DsmScanner.java b/sonar-graph/src/main/java/org/sonar/graph/DsmScanner.java index beb5318f74b..268edcc1b84 100644 --- a/sonar-graph/src/main/java/org/sonar/graph/DsmScanner.java +++ b/sonar-graph/src/main/java/org/sonar/graph/DsmScanner.java @@ -36,7 +36,7 @@ public final class DsmScanner { private static final char FEEDBACK_EDGE_FLAG = '*'; private final DirectedGraph<String, StringEdge> graph = DirectedGraph.createStringDirectedGraph(); private String[] vertices; - private Set<Edge> feedbackEdges = new LinkedHashSet<Edge>(); + private Set<Edge> feedbackEdges = new LinkedHashSet<>(); private DsmScanner(Reader reader) { this.reader = new LineNumberReader(reader); @@ -51,7 +51,7 @@ public final class DsmScanner { } catch (IOException e) { throw new RuntimeException("Unable to read DSM content.", e); // NOSONAR } - Dsm<String> dsm = new Dsm<String>(graph, graph.getVertices(), feedbackEdges); + Dsm<String> dsm = new Dsm<>(graph, graph.getVertices(), feedbackEdges); DsmManualSorter.sort(dsm, Arrays.asList(vertices)); return dsm; } diff --git a/sonar-graph/src/main/java/org/sonar/graph/DsmTopologicalSorter.java b/sonar-graph/src/main/java/org/sonar/graph/DsmTopologicalSorter.java index e910a8b4128..a55ec749fd8 100644 --- a/sonar-graph/src/main/java/org/sonar/graph/DsmTopologicalSorter.java +++ b/sonar-graph/src/main/java/org/sonar/graph/DsmTopologicalSorter.java @@ -32,7 +32,7 @@ public final class DsmTopologicalSorter<V> { } public static <V> void sort(Dsm<V> dsm) { - DsmTopologicalSorter<V> partitionner = new DsmTopologicalSorter<V>(dsm); + DsmTopologicalSorter<V> partitionner = new DsmTopologicalSorter<>(dsm); boolean dsmCanBeSorted = true; while (dsmCanBeSorted) { boolean dsmCanBeSortedOnLeft = partitionner.pushToLeftVerticesWithoutIncomingEdges(); diff --git a/sonar-graph/src/main/java/org/sonar/graph/FeedbackCycle.java b/sonar-graph/src/main/java/org/sonar/graph/FeedbackCycle.java index 7a22fcd0c0d..30822911df2 100644 --- a/sonar-graph/src/main/java/org/sonar/graph/FeedbackCycle.java +++ b/sonar-graph/src/main/java/org/sonar/graph/FeedbackCycle.java @@ -39,7 +39,7 @@ public final class FeedbackCycle implements Iterable<FeedbackEdge>, Comparable<F private final Cycle cycle; private FeedbackCycle(Cycle cycle) { - orderedFeedbackEdges = new ArrayList<FeedbackEdge>(); + orderedFeedbackEdges = new ArrayList<>(); totalOccurrencesOfEdgesInCycle = 0; this.cycle = cycle; } @@ -51,7 +51,7 @@ public final class FeedbackCycle implements Iterable<FeedbackEdge>, Comparable<F public static List<FeedbackCycle> buildFeedbackCycles(Set<Cycle> cycles) { Multiset<Edge> edgesBag = createBagWithAllEdgesOfCycles(cycles); - List<FeedbackCycle> feedbackCycles = new ArrayList<FeedbackCycle>(); + List<FeedbackCycle> feedbackCycles = new ArrayList<>(); for (Cycle cycle : cycles) { FeedbackCycle feedbackCycle = new FeedbackCycle(cycle); int totalOccurrences = 0; diff --git a/sonar-graph/src/main/java/org/sonar/graph/IncrementalCyclesAndFESSolver.java b/sonar-graph/src/main/java/org/sonar/graph/IncrementalCyclesAndFESSolver.java index cd814c615f4..4e8bda55c77 100644 --- a/sonar-graph/src/main/java/org/sonar/graph/IncrementalCyclesAndFESSolver.java +++ b/sonar-graph/src/main/java/org/sonar/graph/IncrementalCyclesAndFESSolver.java @@ -25,7 +25,7 @@ import java.util.Set; public class IncrementalCyclesAndFESSolver<V> { - private Set<Cycle> cycles = new LinkedHashSet<Cycle>(); + private Set<Cycle> cycles = new LinkedHashSet<>(); private long searchCyclesCalls = 0; private static final int DEFAULT_MAX_SEARCH_DEPTH_AT_FIRST = 3; private static final int DEFAULT_MAX_CYCLES_TO_FOUND_BY_ITERATION = 100; @@ -40,7 +40,7 @@ public class IncrementalCyclesAndFESSolver<V> { int maxCyclesToFoundByIteration) { iterations++; - CycleDetector<V> cycleDetector = new CycleDetector<V>(graph, vertices); + CycleDetector<V> cycleDetector = new CycleDetector<>(graph, vertices); cycleDetector.detectCyclesWithMaxSearchDepth(maxSearchDepthAtFirst); searchCyclesCalls += cycleDetector.getSearchCyclesCalls(); cycles.addAll(cycleDetector.getCycles()); @@ -49,7 +49,7 @@ public class IncrementalCyclesAndFESSolver<V> { do { iterations++; - cycleDetector = new CycleDetector<V>(graph, vertices, edgesToExclude); + cycleDetector = new CycleDetector<>(graph, vertices, edgesToExclude); cycleDetector.detectCyclesWithUpperLimit(maxCyclesToFoundByIteration); searchCyclesCalls += cycleDetector.getSearchCyclesCalls(); cycles.addAll(cycleDetector.getCycles()); diff --git a/sonar-graph/src/main/java/org/sonar/graph/MinimumFeedbackEdgeSetSolver.java b/sonar-graph/src/main/java/org/sonar/graph/MinimumFeedbackEdgeSetSolver.java index aaebdced22c..6f9ec3b1ce1 100644 --- a/sonar-graph/src/main/java/org/sonar/graph/MinimumFeedbackEdgeSetSolver.java +++ b/sonar-graph/src/main/java/org/sonar/graph/MinimumFeedbackEdgeSetSolver.java @@ -64,7 +64,7 @@ public class MinimumFeedbackEdgeSetSolver { * Get edges tagged as feedback. */ public Set<Edge> getEdges() { - Set<Edge> edges = new LinkedHashSet<Edge>(); + Set<Edge> edges = new LinkedHashSet<>(); for (FeedbackEdge fe : feedbackEdges) { edges.add(fe.getEdge()); } @@ -72,7 +72,7 @@ public class MinimumFeedbackEdgeSetSolver { } private void run() { - Set<FeedbackEdge> pendingFeedbackEdges = new LinkedHashSet<FeedbackEdge>(); + Set<FeedbackEdge> pendingFeedbackEdges = new LinkedHashSet<>(); if (cyclesNumber < maxNumberCyclesForSearchingMinimumFeedback) { searchFeedbackEdges(0, 0, pendingFeedbackEdges); } else { @@ -81,7 +81,7 @@ public class MinimumFeedbackEdgeSetSolver { } private void lightResearchForFeedbackEdges() { - feedbackEdges = new LinkedHashSet<FeedbackEdge>(); + feedbackEdges = new LinkedHashSet<>(); for (FeedbackCycle cycle : feedbackCycles) { for (FeedbackEdge edge : cycle) { feedbackEdges.add(edge); @@ -105,7 +105,7 @@ public class MinimumFeedbackEdgeSetSolver { if (level == cyclesNumber) { minimumFeedbackEdgesWeight = pendingWeight; - feedbackEdges = new LinkedHashSet<FeedbackEdge>(pendingFeedbackEdges); + feedbackEdges = new LinkedHashSet<>(pendingFeedbackEdges); return; } diff --git a/sonar-graph/src/test/java/org/sonar/graph/CycleDetectorTest.java b/sonar-graph/src/test/java/org/sonar/graph/CycleDetectorTest.java index 486f6dd20c8..244ae9f6ada 100644 --- a/sonar-graph/src/test/java/org/sonar/graph/CycleDetectorTest.java +++ b/sonar-graph/src/test/java/org/sonar/graph/CycleDetectorTest.java @@ -36,7 +36,7 @@ public class CycleDetectorTest { dag.addEdge("B", "D"); dag.addEdge("A", "D"); - CycleDetector<String> cycleDetector = new CycleDetector<String>(dag); + CycleDetector<String> cycleDetector = new CycleDetector<>(dag); cycleDetector.detectCycles(); assertThat(cycleDetector.isAcyclicGraph()).isTrue(); } @@ -46,7 +46,7 @@ public class CycleDetectorTest { DirectedGraph<String, StringEdge> dcg = DirectedGraph.createStringDirectedGraph(); dcg.addEdge("A", "B").addEdge("B", "C").addEdge("C", "A"); - CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg); + CycleDetector<String> cycleDetector = new CycleDetector<>(dcg); cycleDetector.detectCycles(); assertThat(cycleDetector.isAcyclicGraph()).isFalse(); } @@ -62,7 +62,7 @@ public class CycleDetectorTest { dcg.addEdge("E", "F"); dcg.addEdge("F", "C"); - CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg); + CycleDetector<String> cycleDetector = new CycleDetector<>(dcg); cycleDetector.detectCycles(); assertThat(cycleDetector.getCycles()).hasSize(8); assertThat(cycleDetector.getSearchCyclesCalls()).isEqualTo(11); @@ -75,11 +75,11 @@ public class CycleDetectorTest { dcg.addEdge("C", "A"); dcg.addEdge("B", "A"); - CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg); + CycleDetector<String> cycleDetector = new CycleDetector<>(dcg); cycleDetector.detectCyclesWithMaxSearchDepth(3); assertThat(cycleDetector.getCycles()).hasSize(2); - cycleDetector = new CycleDetector<String>(dcg); + cycleDetector = new CycleDetector<>(dcg); cycleDetector.detectCyclesWithMaxSearchDepth(2); assertThat(cycleDetector.getCycles()).hasSize(1); } @@ -91,11 +91,11 @@ public class CycleDetectorTest { dcg.addEdge("C", "A"); dcg.addEdge("B", "A"); - Set<Edge> excludedEdges = new HashSet<Edge>(); + Set<Edge> excludedEdges = new HashSet<>(); excludedEdges.add(dcg.getEdge("C", "A")); excludedEdges.add(dcg.getEdge("B", "A")); - CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg, excludedEdges); + CycleDetector<String> cycleDetector = new CycleDetector<>(dcg, excludedEdges); cycleDetector.detectCycles(); assertThat(cycleDetector.getCycles()).hasSize(1); } @@ -106,7 +106,7 @@ public class CycleDetectorTest { dcg.addEdge("A", "B").addEdge("B", "C").addEdge("C", "D").addEdge("D", "E"); dcg.addEdge("B", "A"); - CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg); + CycleDetector<String> cycleDetector = new CycleDetector<>(dcg); cycleDetector.detectCycles(); assertThat(cycleDetector.getCycles()).hasSize(1); Cycle cycle = cycleDetector.getCycles().iterator().next(); @@ -121,12 +121,12 @@ public class CycleDetectorTest { dcg.addEdge("A", "B").addEdge("B", "C").addEdge("C", "A"); // C must not be used to find cycles - CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg, Arrays.asList("A", "B")); + CycleDetector<String> cycleDetector = new CycleDetector<>(dcg, Arrays.asList("A", "B")); cycleDetector.detectCycles(); assertThat(cycleDetector.getCycles()).isEmpty(); // C is used to find cycles - cycleDetector = new CycleDetector<String>(dcg, Arrays.asList("A", "B", "C")); + cycleDetector = new CycleDetector<>(dcg, Arrays.asList("A", "B", "C")); cycleDetector.detectCycles(); assertThat(cycleDetector.getCycles().size()).isEqualTo(1); } @@ -136,7 +136,7 @@ public class CycleDetectorTest { DirectedGraph<String, StringEdge> dcg = DirectedGraph.createStringDirectedGraph(); dcg.addEdge("A", "B").addEdge("B", "C").addEdge("C", "A"); - CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg); + CycleDetector<String> cycleDetector = new CycleDetector<>(dcg); cycleDetector.detectCycles(); cycleDetector.detectCycles(); } @@ -147,7 +147,7 @@ public class CycleDetectorTest { dcg.addEdge("A", "B").addEdge("B", "C").addEdge("C", "D").addEdge("D", "A"); dcg.addEdge("B", "A"); - CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg); + CycleDetector<String> cycleDetector = new CycleDetector<>(dcg); assertThat(cycleDetector.detectCyclesWithUpperLimit(1)).hasSize(1); } } diff --git a/sonar-graph/src/test/java/org/sonar/graph/DsmManualSorterTest.java b/sonar-graph/src/test/java/org/sonar/graph/DsmManualSorterTest.java index 7ee4468915c..7735dd510c5 100644 --- a/sonar-graph/src/test/java/org/sonar/graph/DsmManualSorterTest.java +++ b/sonar-graph/src/test/java/org/sonar/graph/DsmManualSorterTest.java @@ -31,7 +31,7 @@ public class DsmManualSorterTest { graph.addEdge("A", "B", 2); graph.addEdge("A", "C", 3); graph.addEdge("C", "B", 1); - Dsm<String> dsm = new Dsm<String>(graph); + Dsm<String> dsm = new Dsm<>(graph); DsmManualSorter.sort(dsm, "B", "A", "C"); StringPrintWriter expectedDsm = new StringPrintWriter(); diff --git a/sonar-graph/src/test/java/org/sonar/graph/DsmPrinterTest.java b/sonar-graph/src/test/java/org/sonar/graph/DsmPrinterTest.java index 27bd1b36a1a..063e1955b89 100644 --- a/sonar-graph/src/test/java/org/sonar/graph/DsmPrinterTest.java +++ b/sonar-graph/src/test/java/org/sonar/graph/DsmPrinterTest.java @@ -37,7 +37,7 @@ public class DsmPrinterTest { graph.addEdge("A", "B", 3).addEdge("A", "C", 2); graph.addEdge("C", "B", 4).addEdge("C", "A", 1); HashSet<Edge> feedbackEdges = Sets.<Edge>newHashSet(graph.getEdge("C", "A")); - dsm = new Dsm<String>(graph, feedbackEdges); + dsm = new Dsm<>(graph, feedbackEdges); DsmManualSorter.sort(dsm, "A", "C", "B"); } diff --git a/sonar-graph/src/test/java/org/sonar/graph/DsmTopologicalSorterTest.java b/sonar-graph/src/test/java/org/sonar/graph/DsmTopologicalSorterTest.java index 494129a62d9..9a22ea4555b 100644 --- a/sonar-graph/src/test/java/org/sonar/graph/DsmTopologicalSorterTest.java +++ b/sonar-graph/src/test/java/org/sonar/graph/DsmTopologicalSorterTest.java @@ -91,12 +91,12 @@ public class DsmTopologicalSorterTest { public void sortCyclicGraphWithFlaggedFeedbackEdges() { DirectedGraph<String, StringEdge> dcg = DirectedGraph.createStringDirectedGraph(); dcg.addEdge("A", "B", 3).addEdge("B", "A", 1); - CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg); + CycleDetector<String> cycleDetector = new CycleDetector<>(dcg); cycleDetector.detectCycles(); MinimumFeedbackEdgeSetSolver solver = new MinimumFeedbackEdgeSetSolver(cycleDetector.getCycles()); - Dsm<String> dsm = new Dsm<String>(dcg, solver.getEdges()); + Dsm<String> dsm = new Dsm<>(dcg, solver.getEdges()); DsmTopologicalSorter.sort(dsm); StringPrintWriter expectedDsm = new StringPrintWriter(); diff --git a/sonar-graph/src/test/java/org/sonar/graph/FeedbackCycleTest.java b/sonar-graph/src/test/java/org/sonar/graph/FeedbackCycleTest.java index 604bf78a5a7..e14a97e691a 100644 --- a/sonar-graph/src/test/java/org/sonar/graph/FeedbackCycleTest.java +++ b/sonar-graph/src/test/java/org/sonar/graph/FeedbackCycleTest.java @@ -46,7 +46,7 @@ public class FeedbackCycleTest { @Test public void testBuildFeedbackCycles() { - Set<Cycle> cycles = new HashSet<Cycle>(); + Set<Cycle> cycles = new HashSet<>(); cycles.add(AB_Cycle); cycles.add(ABC_Cycle); cycles.add(BCDA_Cycle); diff --git a/sonar-graph/src/test/java/org/sonar/graph/IncrementalCyclesAndFESSolverTest.java b/sonar-graph/src/test/java/org/sonar/graph/IncrementalCyclesAndFESSolverTest.java index 40f18b2176b..104c11044a9 100644 --- a/sonar-graph/src/test/java/org/sonar/graph/IncrementalCyclesAndFESSolverTest.java +++ b/sonar-graph/src/test/java/org/sonar/graph/IncrementalCyclesAndFESSolverTest.java @@ -37,7 +37,7 @@ public class IncrementalCyclesAndFESSolverTest { dcg.addEdge("E", "F"); dcg.addEdge("F", "C"); - IncrementalCyclesAndFESSolver<String> cyclesAndFESSolver = new IncrementalCyclesAndFESSolver<String>(dcg, dcg.getVertices(), 3, + IncrementalCyclesAndFESSolver<String> cyclesAndFESSolver = new IncrementalCyclesAndFESSolver<>(dcg, dcg.getVertices(), 3, Integer.MAX_VALUE); assertThat(cyclesAndFESSolver.getCycles().size(), is(4)); assertThat(cyclesAndFESSolver.getFeedbackEdgeSet().size(), is(2)); @@ -49,7 +49,7 @@ public class IncrementalCyclesAndFESSolverTest { DirectedGraph<String, StringEdge> dcg = DirectedGraph.createStringDirectedGraph(); dcg.addEdge("A", "B").addEdge("B", "C").addEdge("C", "D").addEdge("D", "A"); - IncrementalCyclesAndFESSolver<String> cyclesAndFESSolver = new IncrementalCyclesAndFESSolver<String>(dcg, dcg.getVertices(), 2, + IncrementalCyclesAndFESSolver<String> cyclesAndFESSolver = new IncrementalCyclesAndFESSolver<>(dcg, dcg.getVertices(), 2, Integer.MAX_VALUE); assertThat(cyclesAndFESSolver.getCycles().size(), is(1)); assertThat(cyclesAndFESSolver.getFeedbackEdgeSet().size(), is(1)); @@ -63,7 +63,7 @@ public class IncrementalCyclesAndFESSolverTest { dcg.addEdge("E", "F").addEdge("F", "G").addEdge("G", "E"); dcg.addEdge("H", "I").addEdge("I", "H"); - IncrementalCyclesAndFESSolver<String> cyclesAndFESSolver = new IncrementalCyclesAndFESSolver<String>(dcg, dcg.getVertices(), 2, 1); + IncrementalCyclesAndFESSolver<String> cyclesAndFESSolver = new IncrementalCyclesAndFESSolver<>(dcg, dcg.getVertices(), 2, 1); assertThat(cyclesAndFESSolver.getCycles().size(), is(3)); assertThat(cyclesAndFESSolver.getIterations(), is(4)); cyclesAndFESSolver.getFeedbackEdgeSet(); diff --git a/sonar-graph/src/test/java/org/sonar/graph/MinimumFeedbackEdgeSetSolverTest.java b/sonar-graph/src/test/java/org/sonar/graph/MinimumFeedbackEdgeSetSolverTest.java index 09c0e66c9e9..580cc64f37f 100644 --- a/sonar-graph/src/test/java/org/sonar/graph/MinimumFeedbackEdgeSetSolverTest.java +++ b/sonar-graph/src/test/java/org/sonar/graph/MinimumFeedbackEdgeSetSolverTest.java @@ -33,7 +33,7 @@ public class MinimumFeedbackEdgeSetSolverTest { public void testGetFeedbackEdgesOnSimpleLoop() { DirectedGraph<String, StringEdge> dcg = DirectedGraph.createStringDirectedGraph(); dcg.addEdge("A", "B", 3).addEdge("B", "A", 1); - CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg); + CycleDetector<String> cycleDetector = new CycleDetector<>(dcg); cycleDetector.detectCycles(); MinimumFeedbackEdgeSetSolver solver = new MinimumFeedbackEdgeSetSolver(cycleDetector.getCycles()); @@ -45,7 +45,7 @@ public class MinimumFeedbackEdgeSetSolverTest { public void testFlagFeedbackEdgesOnSimpleLoop() { DirectedGraph<String, StringEdge> dcg = DirectedGraph.createStringDirectedGraph(); dcg.addEdge("A", "B", 3).addEdge("B", "A", 1); - CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg); + CycleDetector<String> cycleDetector = new CycleDetector<>(dcg); cycleDetector.detectCycles(); MinimumFeedbackEdgeSetSolver solver = new MinimumFeedbackEdgeSetSolver(cycleDetector.getCycles()); @@ -58,7 +58,7 @@ public class MinimumFeedbackEdgeSetSolverTest { DirectedGraph<String, StringEdge> dcg = DirectedGraph.createStringDirectedGraph(); dcg.addEdge("A", "B", 7).addEdge("B", "C", 3).addEdge("C", "D", 1).addEdge("D", "A", 3); dcg.addEdge("B", "A", 12); - CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg); + CycleDetector<String> cycleDetector = new CycleDetector<>(dcg); cycleDetector.detectCycles(); MinimumFeedbackEdgeSetSolver solver = new MinimumFeedbackEdgeSetSolver(cycleDetector.getCycles()); @@ -75,7 +75,7 @@ public class MinimumFeedbackEdgeSetSolverTest { dcg.addEdge("D", "E", 3).addEdge("E", "D", 5); dcg.addEdge("F", "G", 1).addEdge("G", "H", 4).addEdge("H", "F", 7); - CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg); + CycleDetector<String> cycleDetector = new CycleDetector<>(dcg); cycleDetector.detectCycles(); MinimumFeedbackEdgeSetSolver solver = new MinimumFeedbackEdgeSetSolver(cycleDetector.getCycles()); @@ -94,7 +94,7 @@ public class MinimumFeedbackEdgeSetSolverTest { dcg.addEdge("A", "B", 5).addEdge("B", "C", 9).addEdge("C", "A", 1); dcg.addEdge("D", "B", 5).addEdge("C", "D", 7); dcg.addEdge("F", "B", 5).addEdge("C", "F", 4); - CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg); + CycleDetector<String> cycleDetector = new CycleDetector<>(dcg); cycleDetector.detectCycles(); MinimumFeedbackEdgeSetSolver minimumSolver = new MinimumFeedbackEdgeSetSolver(cycleDetector.getCycles()); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java index 9f123486313..755eecc1d70 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java @@ -77,7 +77,7 @@ public class ProjectDefinition { private static final char SEPARATOR = ','; private File baseDir, workDir, buildDir; - private Map<String, String> properties = new HashMap<String, String>(); + private Map<String, String> properties = new HashMap<>(); private ProjectDefinition parent = null; private List<ProjectDefinition> subProjects = new ArrayList<>(); private List<Object> containerExtensions = new ArrayList<>(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFilePredicates.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFilePredicates.java index 7d3d34f7642..164febb9094 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFilePredicates.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFilePredicates.java @@ -129,7 +129,7 @@ public class DefaultFilePredicates implements FilePredicates { @Override public FilePredicate hasLanguages(Collection<String> languages) { - List<FilePredicate> list = new ArrayList<FilePredicate>(); + List<FilePredicate> list = new ArrayList<>(); for (String language : languages) { list.add(hasLanguage(language)); } @@ -138,7 +138,7 @@ public class DefaultFilePredicates implements FilePredicates { @Override public FilePredicate hasLanguages(String... languages) { - List<FilePredicate> list = new ArrayList<FilePredicate>(); + List<FilePredicate> list = new ArrayList<>(); for (String language : languages) { list.add(hasLanguage(language)); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java index 719dd2f8aac..2876fdfa9ba 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultFileSystem.java @@ -50,7 +50,7 @@ import java.util.TreeSet; public class DefaultFileSystem implements FileSystem { private final Cache cache; - private final SortedSet<String> languages = new TreeSet<String>(); + private final SortedSet<String> languages = new TreeSet<>(); private final Path baseDir; private Path workDir; private Charset encoding; @@ -256,12 +256,12 @@ public class DefaultFileSystem implements FileSystem { * Used only for testing */ private static class MapCache extends Cache { - private final Map<String, InputFile> fileMap = new HashMap<String, InputFile>(); - private final Map<String, InputDir> dirMap = new HashMap<String, InputDir>(); + private final Map<String, InputFile> fileMap = new HashMap<>(); + private final Map<String, InputDir> dirMap = new HashMap<>(); @Override public Iterable<InputFile> inputFiles() { - return new ArrayList<InputFile>(fileMap.values()); + return new ArrayList<>(fileMap.values()); } @Override diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/FileMetadata.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/FileMetadata.java index 0862cfca9e8..19b101720a4 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/FileMetadata.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/FileMetadata.java @@ -191,7 +191,7 @@ public class FileMetadata { private static class LineOffsetCounter extends CharHandler { private int currentOriginalOffset = 0; - private List<Integer> originalLineOffsets = new ArrayList<Integer>(); + private List<Integer> originalLineOffsets = new ArrayList<>(); private int lastValidOffset = 0; public LineOffsetCounter() { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/CheckFactory.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/CheckFactory.java index 93fca999844..924832e2d6a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/CheckFactory.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/CheckFactory.java @@ -37,6 +37,6 @@ public class CheckFactory { } public <C> Checks<C> create(String repository) { - return new Checks<C>(activeRules, repository); + return new Checks<>(activeRules, repository); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRules.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRules.java index 91b5cafda55..2104b3d4e50 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRules.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRules.java @@ -36,8 +36,8 @@ public class DefaultActiveRules implements ActiveRules { // TODO use disk-backed cache (persistit) instead of full in-memory cache ? private final ListMultimap<String, ActiveRule> activeRulesByRepository; - private final Map<String, Map<String, ActiveRule>> activeRulesByRepositoryAndKey = new HashMap<String, Map<String, ActiveRule>>(); - private final Map<String, Map<String, ActiveRule>> activeRulesByRepositoryAndInternalKey = new HashMap<String, Map<String, ActiveRule>>(); + private final Map<String, Map<String, ActiveRule>> activeRulesByRepositoryAndKey = new HashMap<>(); + private final Map<String, Map<String, ActiveRule>> activeRulesByRepositoryAndInternalKey = new HashMap<>(); private final ListMultimap<String, ActiveRule> activeRulesByLanguage; public DefaultActiveRules(Collection<NewActiveRule> newActiveRules) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewActiveRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewActiveRule.java index 07e85dc9a76..db91ca70fe4 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewActiveRule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewActiveRule.java @@ -35,7 +35,7 @@ public class NewActiveRule { final RuleKey ruleKey; String name; String severity = Severity.defaultSeverity(); - Map<String, String> params = new HashMap<String, String>(); + Map<String, String> params = new HashMap<>(); String internalKey, language, templateRuleKey; private final ActiveRulesBuilder builder; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java index 213236247d2..593f859c695 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java @@ -40,7 +40,7 @@ public class NewRule { String name, description, severity = DEFAULT_SEVERITY, internalKey, debtSubCharacteristic; DebtRemediationFunction debtRemediationFunction; RuleStatus status = RuleStatus.defaultStatus(); - Map<String, NewRuleParam> params = new HashMap<String, NewRuleParam>(); + Map<String, NewRuleParam> params = new HashMap<>(); NewRule(RuleKey key) { this.key = key; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/RulesBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/RulesBuilder.java index e43f864a291..c46cb987e9f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/RulesBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/RulesBuilder.java @@ -33,7 +33,7 @@ import java.util.Map; public class RulesBuilder { - private final Map<RuleKey, NewRule> map = new HashMap<RuleKey, NewRule>(); + private final Map<RuleKey, NewRule> map = new HashMap<>(); public NewRule add(RuleKey key) { if (map.containsKey(key)) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/internal/DefaultDuplication.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/internal/DefaultDuplication.java index d9836036646..6c00e8ba33a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/internal/DefaultDuplication.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/duplication/internal/DefaultDuplication.java @@ -40,7 +40,7 @@ import java.util.List; public class DefaultDuplication extends DefaultStorable implements NewDuplication, Duplication { private Block originBlock; - private List<Block> duplicates = new LinkedList<Duplication.Block>(); + private List<Block> duplicates = new LinkedList<>(); public DefaultDuplication() { super(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java index 70f80865045..13027e24426 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java @@ -224,7 +224,7 @@ public class SensorContextTester implements SensorContext { if (syntaxHighlightingData == null) { return Collections.emptyList(); } - List<TypeOfText> result = new ArrayList<TypeOfText>(); + List<TypeOfText> result = new ArrayList<>(); DefaultTextPointer location = new DefaultTextPointer(line, lineOffset); for (SyntaxHighlightingRule sortedRule : syntaxHighlightingData.getSyntaxHighlightingRuleSet()) { if (sortedRule.range().start().compareTo(location) <= 0 && sortedRule.range().end().compareTo(location) > 0) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java index 4907cda4609..b07a0d400eb 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java @@ -135,18 +135,18 @@ public final class PropertyDefinitions { * @since 3.7 */ public Map<Category, Map<SubCategory, Collection<PropertyDefinition>>> propertiesByCategory(@Nullable String qualifier) { - Map<Category, Map<SubCategory, Collection<PropertyDefinition>>> byCategory = new HashMap<Category, Map<SubCategory, Collection<PropertyDefinition>>>(); + Map<Category, Map<SubCategory, Collection<PropertyDefinition>>> byCategory = new HashMap<>(); if (qualifier == null) { // Special categories on global page - Map<SubCategory, Collection<PropertyDefinition>> emailSubCategories = new HashMap<SubCategory, Collection<PropertyDefinition>>(); + Map<SubCategory, Collection<PropertyDefinition>> emailSubCategories = new HashMap<>(); emailSubCategories.put(new SubCategory("email", true), new ArrayList<PropertyDefinition>()); byCategory.put(new Category(CoreProperties.CATEGORY_GENERAL, false), emailSubCategories); - HashMap<SubCategory, Collection<PropertyDefinition>> licenseSubCategories = new HashMap<SubCategory, Collection<PropertyDefinition>>(); + HashMap<SubCategory, Collection<PropertyDefinition>> licenseSubCategories = new HashMap<>(); licenseSubCategories.put(new SubCategory("server_id", true), new ArrayList<PropertyDefinition>()); byCategory.put(new Category(CoreProperties.CATEGORY_LICENSES, false), licenseSubCategories); - HashMap<SubCategory, Collection<PropertyDefinition>> encryptionSubCategories = new HashMap<SubCategory, Collection<PropertyDefinition>>(); + HashMap<SubCategory, Collection<PropertyDefinition>> encryptionSubCategories = new HashMap<>(); encryptionSubCategories.put(new SubCategory("encryption", true), new ArrayList<PropertyDefinition>()); byCategory.put(new Category(CoreProperties.CATEGORY_SECURITY, false), encryptionSubCategories); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java index ef79ca10051..42530abf132 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java @@ -40,7 +40,7 @@ public final class MeasuresFilters { return new MeasuresFilter<Collection<Measure>>() { @Override public Collection<Measure> filter(Collection<Measure> measures) { - Collection<Measure> all = new ArrayList<Measure>(); + Collection<Measure> all = new ArrayList<>(); for (Measure measure : measures) { if (measure != null) { all.add(measure); @@ -174,7 +174,7 @@ public final class MeasuresFilters { if (measures == null) { return null; } - List<RuleMeasure> result = new ArrayList<RuleMeasure>(); + List<RuleMeasure> result = new ArrayList<>(); for (Measure measure : measures) { if (apply(measure)) { result.add((RuleMeasure) measure); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java index e53c1471b44..574c3d87ea0 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java @@ -801,7 +801,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a this.bestValue = (direction == DIRECTION_BETTER ? 100.0 : 0.0); this.worstValue = (direction == DIRECTION_BETTER ? 0.0 : 100.0); } - return new Metric<G>(this); + return new Metric<>(this); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/PropertiesBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/PropertiesBuilder.java index 3bef4b9e0c2..8f498befcca 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/PropertiesBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/PropertiesBuilder.java @@ -32,17 +32,17 @@ public class PropertiesBuilder<K, V> { private Map<K, V> props; public PropertiesBuilder(Metric metric, Map<K, V> map) { - this.props = new TreeMap<K, V>(map); + this.props = new TreeMap<>(map); this.metric = metric; } public PropertiesBuilder(Metric metric) { - this.props = new TreeMap<K, V>(); + this.props = new TreeMap<>(); this.metric = metric; } public PropertiesBuilder() { - this.props = new TreeMap<K, V>(); + this.props = new TreeMap<>(); } public PropertiesBuilder<K, V> clear() { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java index b966968e547..2b4471ef5b7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java @@ -223,7 +223,7 @@ public class RangeDistributionBuilder implements MeasureBuilder { */ public Measure<String> build(boolean allowEmptyData) { if (isValid && (!isEmpty || allowEmptyData)) { - return new Measure<String>(metric, KeyValueFormat.format(countBag, -1)); + return new Measure<>(metric, KeyValueFormat.format(countBag, -1)); } return null; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java index 84b971dbe92..6ac3287dd6e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java @@ -116,7 +116,7 @@ public class XMLProfileParser { } private void processRules(SMInputCursor rulesCursor, RulesProfile profile, ValidationMessages messages) throws XMLStreamException { - Map<String, String> parameters = new HashMap<String, String>(); + Map<String, String> parameters = new HashMap<>(); while (rulesCursor.getNext() != null) { SMInputCursor ruleCursor = rulesCursor.childElementCursor(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Languages.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Languages.java index d0ae370809f..cf9fc43b040 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Languages.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Languages.java @@ -68,7 +68,7 @@ public class Languages { * @return the list of suffix files associates to languages included in the current object */ public String[] getSuffixes(String... keys) { - List<String> suffixes = new ArrayList<String>(); + List<String> suffixes = new ArrayList<>(); for (Map.Entry<String, Language> entry : map.entrySet()) { if (ArrayUtils.isEmpty(keys) || ArrayUtils.contains(keys, entry.getKey())) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java index 466902b61c9..14549bd4433 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java @@ -91,7 +91,7 @@ public class Project extends Resource implements Component { // modules tree private Project parent; - private List<Project> modules = new ArrayList<Project>(); + private List<Project> modules = new ArrayList<>(); public Project(String key) { setKey(key); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java index 493267a4b91..d9bc510c1fa 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java @@ -40,7 +40,7 @@ public class ActiveRule implements Cloneable { private Rule rule; private RulePriority severity; private RulesProfile rulesProfile; - private List<ActiveRuleParam> activeRuleParams = new ArrayList<ActiveRuleParam>(); + private List<ActiveRuleParam> activeRuleParams = new ArrayList<>(); private String inheritance; /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java index 6b7f1d79e01..0014f8df527 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java @@ -136,7 +136,7 @@ public class Rule { @org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN}) @OneToMany(mappedBy = "rule") - private List<RuleParam> params = new ArrayList<RuleParam>(); + private List<RuleParam> params = new ArrayList<>(); @Temporal(TemporalType.TIMESTAMP) @Column(name = "created_at", updatable = true, nullable = true) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java index 910f56fe2fb..398d1681c65 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java @@ -125,8 +125,8 @@ public class RulesDefinitionXmlLoader { private void processRule(RulesDefinition.NewRepository repo, SMInputCursor ruleC) throws XMLStreamException { String key = null, name = null, description = null, internalKey = null, severity = Severity.defaultSeverity(), status = null; Cardinality cardinality = Cardinality.SINGLE; - List<ParamStruct> params = new ArrayList<ParamStruct>(); - List<String> tags = new ArrayList<String>(); + List<ParamStruct> params = new ArrayList<>(); + List<String> tags = new ArrayList<>(); /* BACKWARD COMPATIBILITY WITH VERY OLD FORMAT */ String keyAttribute = ruleC.getAttrValue("key"); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/LocalizedMessages.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/LocalizedMessages.java index 00ba41a1d4b..23a904c46e6 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/LocalizedMessages.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/LocalizedMessages.java @@ -48,7 +48,7 @@ public class LocalizedMessages extends ResourceBundle { */ public LocalizedMessages(Locale locale, String... basenames) { this.locale = locale; - bundles = new ArrayList<ResourceBundle>(basenames.length); + bundles = new ArrayList<>(basenames.length); for (String basename : basenames) { bundles.add(getBundle("sonar.bundles." + basename, locale)); } @@ -108,7 +108,7 @@ public class LocalizedMessages extends ResourceBundle { } private class KeyEnumeration implements Enumeration<String> { - private Set<String> keys = new HashSet<String>(); + private Set<String> keys = new HashSet<>(); // Set iterator to simulate enumeration private Iterator<String> i; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ManifestUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ManifestUtils.java index 10f22a2523e..e8e13ce02d4 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ManifestUtils.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ManifestUtils.java @@ -41,7 +41,7 @@ public final class ManifestUtils { * @return the values, an empty list if the property is not found. */ public static List<String> getPropertyValues(ClassLoader classloader, String key) { - List<String> values = new ArrayList<String>(); + List<String> values = new ArrayList<>(); try { Enumeration<URL> resources = classloader.getResources("META-INF/MANIFEST.MF"); while (resources.hasMoreElements()) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ValidationMessages.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ValidationMessages.java index 967bcd67dbb..9b753335518 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ValidationMessages.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ValidationMessages.java @@ -28,9 +28,9 @@ import java.util.List; public final class ValidationMessages { - private List<String> errors = new ArrayList<String>(); - private List<String> warnings = new ArrayList<String>(); - private List<String> infos = new ArrayList<String>(); + private List<String> errors = new ArrayList<>(); + private List<String> warnings = new ArrayList<>(); + private List<String> infos = new ArrayList<>(); /** * Use the factory method <code>create()</code> diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java index 176edf7dbca..9d7aa27061e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java @@ -61,7 +61,7 @@ import org.apache.commons.lang.StringUtils; */ public class WildcardPattern { - private static final Map<String, WildcardPattern> CACHE = new HashMap<String, WildcardPattern>(); + private static final Map<String, WildcardPattern> CACHE = new HashMap<>(); private static final String SPECIAL_CHARS = "()[]^$.{}+|"; private Pattern pattern; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/XpathParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/XpathParser.java index e206847699b..ea3ef78527a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/XpathParser.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/XpathParser.java @@ -172,7 +172,7 @@ public class XpathParser { } public List<Element> getChildElements(String elementName) { - List<Element> rtrVal = new ArrayList<Element>(); + List<Element> rtrVal = new ArrayList<>(); NodeList childrens = getRoot().getElementsByTagName(elementName); for (int i = 0; i < childrens.getLength(); i++) { Node nde = childrens.item(i); @@ -184,7 +184,7 @@ public class XpathParser { } public List<Element> getChildElements(Element base, String elementName) { - List<Element> rtrVal = new ArrayList<Element>(); + List<Element> rtrVal = new ArrayList<>(); NodeList childrens = base.getElementsByTagName(elementName); for (int i = 0; i < childrens.getLength(); i++) { Node nde = childrens.item(i); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/DirectAcyclicGraph.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/DirectAcyclicGraph.java index 76595f08550..c9c7d2a598b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/DirectAcyclicGraph.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/DirectAcyclicGraph.java @@ -34,8 +34,8 @@ import java.util.Map; */ public class DirectAcyclicGraph { - private Map<Object, Node> registeredObjects = new HashMap<Object, Node>(); - private List<Node> nodes = new ArrayList<Node>(); + private Map<Object, Node> registeredObjects = new HashMap<>(); + private List<Node> nodes = new ArrayList<>(); public DirectAcyclicGraph(final Object... objects) { if (objects != null) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/Node.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/Node.java index db391a688f0..bb29ba99d87 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/Node.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/Node.java @@ -32,7 +32,7 @@ public class Node implements Comparable<Node> { private final Object object; private int order = 0; private boolean seen = false; - private final List<Node> dependencies = new ArrayList<Node>(); + private final List<Node> dependencies = new ArrayList<>(); public Node(final Object object) { if (object == null) { diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/PropertiesBuilderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/PropertiesBuilderTest.java index d540ddb1a61..f7e89fd07f3 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/PropertiesBuilderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/PropertiesBuilderTest.java @@ -27,7 +27,7 @@ import org.junit.Test; public class PropertiesBuilderTest { @Test public void buildMeasure() { - PropertiesBuilder<Integer, Integer> builder = new PropertiesBuilder<Integer, Integer>(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION); + PropertiesBuilder<Integer, Integer> builder = new PropertiesBuilder<>(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION); Measure measure = builder .add(1, 30) .add(2, 27) @@ -39,7 +39,7 @@ public class PropertiesBuilderTest { @Test public void sortKeys() { - PropertiesBuilder<String, String> builder = new PropertiesBuilder<String, String>(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION); + PropertiesBuilder<String, String> builder = new PropertiesBuilder<>(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION); Measure measure = builder .add("foo", "fooooo") .add("bar", "baaaaar") @@ -51,7 +51,7 @@ public class PropertiesBuilderTest { @Test public void valueIsOptional() { - PropertiesBuilder<String, String> builder = new PropertiesBuilder<String, String>(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION); + PropertiesBuilder<String, String> builder = new PropertiesBuilder<>(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION); Measure measure = builder .add("foo", null) .add("bar", "bar") @@ -63,7 +63,7 @@ public class PropertiesBuilderTest { @Test public void clearBeforeBuildingOtherMeasure() { - PropertiesBuilder<String, String> builder = new PropertiesBuilder<String, String>(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION); + PropertiesBuilder<String, String> builder = new PropertiesBuilder<>(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION); builder .add("foo", "foo") .add("bar", "bar") diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/user/UserQueryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/user/UserQueryTest.java index fa36ab4986b..ddc5e569528 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/user/UserQueryTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/user/UserQueryTest.java @@ -56,7 +56,7 @@ public class UserQueryTest { @Test public void should_limit_number_of_logins() { - List<String> logins = new ArrayList<String>(); + List<String> logins = new ArrayList<>(); for (int i = 0; i < 1010; i++) { logins.add(String.valueOf(i)); } |