Как удалить эти скобки вокруг этого лямбда-выражения?JAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Как удалить эти скобки вокруг этого лямбда-выражения?

Сообщение Anonymous »

Sonarlint, который я использую с IntelliJ, отправляет мне предупреждение S1602 «Удалите ненужные фигурные скобки вокруг оператора» в этом операторе:

Код: Выделить всё

communes.foreachPartition(
partition -> {
partition.forEachRemaining(commune -> this.validator.validerRowCommune(historique, commune));
}
);
(где:

Код: Выделить всё

communes
— это org.apache.spark.sql.Dataset

Код: Выделить всё

partition
— это итератор

а commune — это строка)
В следующем функция:

Код: Выделить всё

public Dataset rowCommunes(OptionsCreationLecture optionsCreationLecture, HistoriqueExecution historique, int anneeCOG, boolean inclureCommunesDelegueesAssociees, Verification... verifications) {
OptionsCreationLecture options = optionsCreationLecture != null ? optionsCreationLecture : optionsCreationLecture();

if (historique != null) {
historique.addReglesValidation(this.session, this.validator);
}

Supplier worker = () -> {
super.setStageDescription(this.messageSource, "row.cog.libelle.long", "row.cog.libelle.court", anneeCOG, inclureCommunesDelegueesAssociees);
LOGGER.info(this.messageSource.getMessage("row.cog.libelle.long", new Object[] {anneeCOG, inclureCommunesDelegueesAssociees}, Locale.getDefault()));

// Lier les codes communes et codes communes parents à leurs siren
Dataset c = this.cogCsvLoader.loadOpenData(anneeCOG, inclureCommunesDelegueesAssociees);
Dataset s = this.datasetSirenCommunaux.rowSirenCommunes(options, new SirenCommunesTriDepartementCommuneSiren(), anneeCOG);
Dataset communes = lierCommunesEtSiren(c,s).union(lierCommunesParentesEtSiren(c,s));

communes = communes.dropDuplicates("codeCommune", "typeCommune", "nomCommune");

communes = populationEtStrateCommunale(communes);
communes = liercontoursCommunes(communes, anneeCOG, verifications);

// Associer à chaque commune son code intercommunalité, si elle en a un (les communes-communautés peuvent ne pas en avoir).
Dataset perimetres = this.datasetPerimetres.rowPerimetres(this.session, anneeCOG, EPCIPerimetreDataset.TriPerimetresEPCI.CODE_COMMUNE_MEMBRE).selectExpr("sirenCommuneMembre", "sirenGroupement as codeEPCI", "nomGroupement as nomEPCI");
Column conditionJoinPerimetres = communes.col("sirenCommune").equalTo(perimetres.col("sirenCommuneMembre"));

verificateur().verifications("jonction communes et périmètres", communes, null, perimetres, conditionJoinPerimetres, verifications, Verification.SHOW_REJETS, Verification.COMPTAGES_ET_STATISTIQUES);
communes = communes.join(perimetres, conditionJoinPerimetres, "left");

// Y associer les départements.
communes = this.datasetDepartements.withDepartement("codeDepartementRetabli", communes, "codeDepartement", null, true, anneeCOG)
.drop("codeRegionDepartement")
.drop("codeDepartementRetabli");

communes.foreachPartition(
partition -> {
partition.forEachRemaining(commune -> this.validator.validerRowCommune(historique, commune));
}
);

return communes;
};

return constitutionStandard(options, worker,
new CacheParqueteur(options, this.session,
"cog-communes", "FILTRE-annee_{0,number,#0}_COMD-COMA_{1}",
new CogTriDepartementCommune(), anneeCOG, inclureCommunesDelegueesAssociees));
}
Я много раз пытался, но так и не нашел способа снять эти скобки.
Например, это не так:

Код: Выделить всё

communes.foreachPartition(
partition -> partition.forEachRemaining(commune -> this.validator.validerRowCommune(historique, commune));
);
Изображение



Подробнее здесь: https://stackoverflow.com/questions/783 ... expression
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»