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++;
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;
}
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 ?
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();
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) {
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) {
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);
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) {
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);
@Test
public void fail_missing_attributes_field() {
- Map<String, Object> params = new HashMap<String, Object>();
+ Map<String, Object> params = new HashMap<>();
// Missing everything
try {
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");
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");
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");
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");
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");
}
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;
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);
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);
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();
}
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());
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));
}
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];
}
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);
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;
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);
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;
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()) ||
}
public static <T> Result<T> of() {
- return new Result<T>(null);
+ return new Result<>(null);
}
public Result<T> set(@Nullable T object) {
}
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);
* 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);
}
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());
}
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());
@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) {
@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));
}
@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());
}
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;
}
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()));
}
.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()
@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());
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());
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());
}
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);
}
}
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);
}
}
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);
}
@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) {
@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));
}
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()) {
/* 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(),
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());
}
}
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);
esSearch.setQuery(QueryBuilders.filteredQuery(qb, fb));
SearchResponse esResult = esSearch.get();
- return new Result<Rule>(this, esResult);
+ return new Result<>(this, esResult);
}
@Override
}
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)
@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());
}
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());
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) {
}
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));
}
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",
}
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");
}
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");
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) {
}
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())
}
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)) {
}
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());
public IndexClient(Index<?, ?, ?>... indexComponents) {
- this.indexComponents = new HashMap<Class<?>, Index<?, ?, ?>>();
+ this.indexComponents = new HashMap<>();
for (Index<?, ?, ?> indexComponent : indexComponents) {
this.indexComponents.put(indexComponent.getClass(), indexComponent);
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);
}
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);
}
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()));
@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)
@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));
@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) {
@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));
public CharactersReader(BufferedReader stringBuffer) {
this.stringBuffer = stringBuffer;
- this.openTags = new ArrayDeque<String>();
+ this.openTags = new ArrayDeque<>();
}
boolean readNextChar() throws IOException {
@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);
@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);
}
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;
@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");
}
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;
}
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");
}
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;
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 {
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 {
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 {
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 {
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 {
}
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;
@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);
@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();
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(
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) {
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() {
}
*/
public class BulkChangeQuery {
- private final Map<String, Object> params = new HashMap<String, Object>();
+ private final Map<String, Object> params = new HashMap<>();
private BulkChangeQuery() {
}
*/
public class IssueQuery {
- private final Map<String, Object> params = new HashMap<String, Object>();
+ private final Map<String, Object> params = new HashMap<>();
private IssueQuery() {
}
*/
public class NewActionPlan {
- private final Map<String, Object> params = new HashMap<String, Object>();
+ private final Map<String, Object> params = new HashMap<>();
private NewActionPlan() {
}
*/
public class NewIssue {
- private final Map<String, Object> params = new HashMap<String, Object>();
+ private final Map<String, Object> params = new HashMap<>();
private NewIssue() {
}
*/
public class UpdateActionPlan {
- private final Map<String, Object> params = new HashMap<String, Object>();
+ private final Map<String, Object> params = new HashMap<>();
private UpdateActionPlan() {
}
@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) {
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() {
*/
@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) {
@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));
*/
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
}
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) {
}
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) {
}
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) {
private final Map<String, Object> params;
private PermissionParameters(){
- params = new HashMap<String, Object>();
+ params = new HashMap<>();
}
public static PermissionParameters create() {
private final Map<String, Object> params;
private NewProject() {
- params = new HashMap<String, Object>();
+ params = new HashMap<>();
}
public static NewProject create() {
@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) {
@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) {
private final Map<String, Object> params;
private NewCondition() {
- params = new HashMap<String, Object>();
+ params = new HashMap<>();
}
public static NewCondition create(long qGateId) {
private final Map<String, Object> params;
private UpdateCondition() {
- params = new HashMap<String, Object>();
+ params = new HashMap<>();
}
public static UpdateCondition create(long id) {
@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);
}
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;
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));
@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) {
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("=");
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() {
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;
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();
@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);
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) {
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);
public class UserParameters {
- private final Map<String, Object> params = new HashMap<String, Object>();
+ private final Map<String, Object> params = new HashMap<>();
private UserParameters() {
}
*/
public class UserQuery {
- private final Map<String, Object> params = new HashMap<String, Object>();
+ private final Map<String, Object> params = new HashMap<>();
private UserQuery() {
}
@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) {
@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);
}
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);
}
}
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());
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) {
}
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));
}
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));
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;
}
}
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;
}
}
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(),
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;
}
}
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(),
}
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));
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;
}
}
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(),
}
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));
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;
}
}
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(),
}
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));
}
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());
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) {
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;
}
}
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(),
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;
}
}
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());
}
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));
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());
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;
}
}
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(),
}
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));
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;
}
}
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(),
}
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));
}
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));
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());
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;
}
}
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(),
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;
}
}
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(),
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());
}
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));
}
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());
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) {
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;
}
}
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;
}
}
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(),
}
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));
}
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));
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;
}
}
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(),
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;
}
}
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(),
}
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());
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) {
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;
}
}
}
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));
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;
}
}
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(),
}
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));
}
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());
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) {
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;
}
}
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;
}
}
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(),
}
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));
}
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());
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) {
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;
}
}
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;
}
}
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(),
}
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));
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;
}
}
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(),
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) {
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;
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) {
* 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;
}
* 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;
}
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();
}
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();
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) {
}
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) {
@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());
}
@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);
}
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;
}
}
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) {
private String scope;
- List<InputDependency> dependencies = new ArrayList<InputDependency>();
+ List<InputDependency> dependencies = new ArrayList<>();
public InputDependency(String key, String version) {
this.key = key;
@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);
@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());
}
@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);
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) {
* 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) {
}
originExchange.append(Key.BEFORE);
Exchange iteratorExchange = new Exchange(originExchange);
- return new ValueIterator<T>(iteratorExchange, filter);
+ return new ValueIterator<>(iteratorExchange, filter);
}
}
}
originExchange.append(Key.BEFORE);
Exchange iteratorExchange = new Exchange(originExchange);
- return new EntryIterator<T>(iteratorExchange, filter);
+ return new EntryIterator<>(iteratorExchange, filter);
}
}
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();
}
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) {
} 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);
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);
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);
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) {
.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);
}
}
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) {
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);
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;
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());
}
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) {
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) {
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);
@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;
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;
@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()));
}
@Override
public List<ActiveRule> getActiveRules() {
- List<ActiveRule> activeRules = new ArrayList<ActiveRule>();
+ List<ActiveRule> activeRules = new ArrayList<>();
for (RulesProfile profile : profiles) {
activeRules.addAll(profile.getActiveRules());
}
@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));
}
@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));
}
}
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);
}
}
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()) {
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));
}
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);
}
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()) {
}
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);
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);
}
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) {
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();
}
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;
}
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();
}
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;
}
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));
}
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;
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;
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);
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);
}
@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);
}
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) {
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());
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);
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++) {
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("[]"));
}
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));
@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");
@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");
@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");
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);
@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
}
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());
}
@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");
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());
}
@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);
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);
}
}
- 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());
}
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) {
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));
}
}
}
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;
}
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()) {
*/
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)) {
this.actionCount = 0;
this.session = session;
this.queue = queue;
- this.actions = new ArrayList<ClusterAction>();
+ this.actions = new ArrayList<>();
}
public void enqueue(ClusterAction action) {
}
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) {
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;
}
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) {
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) {
}
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);
}
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 ");
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() {
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;
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 {
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) {
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);
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);
@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");
@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"));
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);
v.setProperty("v", innerV);
- Set<String> propertiesToInclude = new HashSet<String>();
+ Set<String> propertiesToInclude = new HashSet<>();
propertiesToInclude.add("y");
propertiesToInclude.add("v");
@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");
@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);
@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);
@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);
@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);
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);
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);
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);
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);
* @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, "=");
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) {
@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);
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);
if (c != null) {
return c;
}
- this.code = new SoftReference<List<String>>(load());
+ this.code = new SoftReference<>(load());
return code.get();
}
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);
*/
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;
/**
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) {
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) {
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;
}
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);
if (tokenQueue == null) {
throw new IllegalArgumentException();
}
- List<Statement> statements = new ArrayList<Statement>();
+ List<Statement> statements = new ArrayList<>();
try {
channelDispatcher.consume(tokenQueue, statements);
return statements;
*/
public static final class Builder {
- private List<StatementChannel> channels = new ArrayList<StatementChannel>();
+ private List<StatementChannel> channels = new ArrayList<>();
private Builder() {
}
*/
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) {
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<>();
}
/**
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();
@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));
@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));
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;
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;
}
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);
}
}
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++) {
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() {
}
}
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) {
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)) {
}
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) {
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();
}
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();
}
}
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();
}
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);
} 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;
}
}
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();
private final Cycle cycle;
private FeedbackCycle(Cycle cycle) {
- orderedFeedbackEdges = new ArrayList<FeedbackEdge>();
+ orderedFeedbackEdges = new ArrayList<>();
totalOccurrencesOfEdgesInCycle = 0;
this.cycle = cycle;
}
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;
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;
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());
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());
* 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());
}
}
private void run() {
- Set<FeedbackEdge> pendingFeedbackEdges = new LinkedHashSet<FeedbackEdge>();
+ Set<FeedbackEdge> pendingFeedbackEdges = new LinkedHashSet<>();
if (cyclesNumber < maxNumberCyclesForSearchingMinimumFeedback) {
searchFeedbackEdges(0, 0, pendingFeedbackEdges);
} else {
}
private void lightResearchForFeedbackEdges() {
- feedbackEdges = new LinkedHashSet<FeedbackEdge>();
+ feedbackEdges = new LinkedHashSet<>();
for (FeedbackCycle cycle : feedbackCycles) {
for (FeedbackEdge edge : cycle) {
feedbackEdges.add(edge);
if (level == cyclesNumber) {
minimumFeedbackEdgesWeight = pendingWeight;
- feedbackEdges = new LinkedHashSet<FeedbackEdge>(pendingFeedbackEdges);
+ feedbackEdges = new LinkedHashSet<>(pendingFeedbackEdges);
return;
}
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();
}
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();
}
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);
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);
}
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);
}
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();
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);
}
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();
}
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);
}
}
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();
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");
}
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();
@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);
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));
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));
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();
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());
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());
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());
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());
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());
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<>();
@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));
}
@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));
}
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;
* 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
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() {
}
public <C> Checks<C> create(String repository) {
- return new Checks<C>(activeRules, repository);
+ return new Checks<>(activeRules, repository);
}
}
// 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) {
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;
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;
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)) {
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();
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) {
* @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);
}
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);
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);
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);
}
}
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() {
*/
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;
}
}
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();
* @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())) {
// modules tree
private Project parent;
- private List<Project> modules = new ArrayList<Project>();
+ private List<Project> modules = new ArrayList<>();
public Project(String key) {
setKey(key);
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;
/**
@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)
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");
*/
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));
}
}
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;
* @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()) {
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>
*/
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;
}
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);
}
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);
*/
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) {
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) {
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)
@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")
@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")
@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")
@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));
}