Skip to content

Commit 65367fd

Browse files
committed
Convert some Predicate to lambdas
Remove some useless javadoc tags while editing the files.
1 parent 342e0bc commit 65367fd

File tree

4 files changed

+26
-70
lines changed

4 files changed

+26
-70
lines changed

chemclipse/plugins/org.eclipse.chemclipse.converter/src/org/eclipse/chemclipse/converter/core/IConverterSupport.java

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*******************************************************************************
2-
* Copyright (c) 2008, 2025 Lablicate GmbH.
2+
* Copyright (c) 2008, 2026 Lablicate GmbH.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
66
* which is available at https://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
9+
*
1010
* Contributors:
1111
* Philip Wenig - initial API and implementation
1212
* Christoph Läubrich - simplify API, deprecate individual getters in favor to a new filter approach
@@ -37,8 +37,6 @@ public interface IConverterSupport {
3737
* The filter extension are the specific chromatogram file extensions.
3838
* Agilent has for example an filter extension (.D) which represents a
3939
* chromatogram.
40-
*
41-
* @return String[]
4240
*/
4341
default String[] getFilterExtensions(Predicate<? super ISupplier> filter) {
4442

@@ -64,8 +62,6 @@ default String[] getFilterExtensions(Predicate<? super ISupplier> filter) {
6462
* The filter names are the specific chromatogram file names to be displayed
6563
* for example in the SWT FileDialog. Agilent has for example an filter name
6664
* "Agilent Chromatogram (.D)".
67-
*
68-
* @return String[]
6965
*/
7066
default String[] getFilterNames(Predicate<? super ISupplier> filter) {
7167

@@ -80,22 +76,10 @@ default String[] getFilterNames(Predicate<? super ISupplier> filter) {
8076
* Returns the converter id "org.eclipse.chemclipse.msd.converter.supplier.agilent" available in the list defined by its name, e.g. "Agilent Chromatogram (*.D/DATA.MS)".
8177
* If more converter with the given name "Agilent Chromatogram (*.D/DATA.MS)" are stored, the first match will be returned. If exportConverterOnly is true, only a converter
8278
* that is able to export the file will be returned.
83-
*
84-
* @param name
85-
* @param exportConverterOnly
86-
* @return String
87-
* @throws NoConverterAvailableException
8879
*/
8980
default String getConverterId(String name, boolean exportConverterOnly) throws NoConverterAvailableException {
9081

91-
Collection<ISupplier> supplier = getSupplier(new Predicate<ISupplier>() {
92-
93-
@Override
94-
public boolean test(ISupplier supplier) {
95-
96-
return supplier.getFilterName().equals(name) && (!exportConverterOnly || supplier.isExportable());
97-
}
98-
});
82+
Collection<ISupplier> supplier = getSupplier(s -> s.getFilterName().equals(name) && (!exportConverterOnly || s.isExportable()));
9983
if(supplier.isEmpty()) {
10084
throw new NoConverterAvailableException();
10185
} else {
@@ -110,10 +94,6 @@ public boolean test(ISupplier supplier) {
11094
* The same thing if the file is a file and not a directory.<br/>
11195
* The header of {@link MethodConverter} lists some file format
11296
* endings.
113-
*
114-
* @param file
115-
* @return List<String>
116-
* @throws NoConverterAvailableException
11797
*/
11898
default List<String> getAvailableConverterIds(File file) throws NoConverterAvailableException {
11999

@@ -132,8 +112,6 @@ default List<String> getAvailableConverterIds(File file) throws NoConverterAvail
132112

133113
/**
134114
* Returns the list of all available suppliers
135-
*
136-
* @return Collection<ISupplier>
137115
*/
138116
default Collection<ISupplier> getSupplier(Predicate<? super ISupplier> filter) {
139117

@@ -151,10 +129,6 @@ default Collection<ISupplier> getSupplier(Predicate<? super ISupplier> filter) {
151129
/**
152130
* Returns the supplier with the given id.<br/>
153131
* If no supplier with the given id is available, throw an exception.
154-
*
155-
* @param id
156-
* @throws NoConverterAvailableException
157-
* @return supplier
158132
*/
159133
default ISupplier getSupplier(String id) throws NoConverterAvailableException {
160134

@@ -169,13 +143,13 @@ default ISupplier getSupplier(String id) throws NoConverterAvailableException {
169143
DataCategory getDataCategory();
170144

171145
/**
172-
*
146+
*
173147
* @return a name of this converter so a user can identify this among others
174148
*/
175149
String getName();
176150

177151
/**
178-
*
152+
*
179153
* @return an id that can be used to store a reference to this converter support
180154
*/
181155
default String getID() {

chemclipse/plugins/org.eclipse.chemclipse.model/src/org/eclipse/chemclipse/model/targets/TargetReference.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* which is available at https://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
9+
*
1010
* Contributors:
1111
* Christoph Läubrich - initial API and implementation
1212
* Philip Wenig - refactoring target label support
@@ -141,30 +141,23 @@ public static List<TargetReference> getPeakReferences(Collection<? extends IPeak
141141

142142
/**
143143
* Create the visibility filter.
144-
*
145-
* @param targetDisplaySettings
146-
* @return {@link Predicate}
147144
*/
148145
public static Predicate<ITargetReference> createVisibilityFilter(ITargetDisplaySettings targetDisplaySettings) {
149146

150147
if(targetDisplaySettings == null) {
151148
return always -> true;
152149
}
153150

154-
return new Predicate<ITargetReference>() {
155-
156-
@Override
157-
public boolean test(ITargetReference targetReference) {
151+
return targetReference -> {
158152

159-
if(targetDisplaySettings.isVisible(targetReference)) {
160-
if(TargetReferenceType.PEAK.equals(targetReference.getType())) {
161-
return targetDisplaySettings.isShowPeakLabels();
162-
} else if(TargetReferenceType.SCAN.equals(targetReference.getType())) {
163-
return targetDisplaySettings.isShowScanLabels();
164-
}
153+
if(targetDisplaySettings.isVisible(targetReference)) {
154+
if(TargetReferenceType.PEAK.equals(targetReference.getType())) {
155+
return targetDisplaySettings.isShowPeakLabels();
156+
} else if(TargetReferenceType.SCAN.equals(targetReference.getType())) {
157+
return targetDisplaySettings.isShowScanLabels();
165158
}
166-
return false;
167159
}
160+
return false;
168161
};
169162
}
170163
}

chemclipse/plugins/org.eclipse.chemclipse.processing/src/org/eclipse/chemclipse/processing/supplier/IProcessSupplierContext.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*******************************************************************************
2-
* Copyright (c) 2019, 2025 Lablicate GmbH.
2+
* Copyright (c) 2019, 2026 Lablicate GmbH.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
66
* which is available at https://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
9+
*
1010
* Contributors:
1111
* Christoph Läubrich - initial API and implementation
1212
* Philip Wenig - refactorings
@@ -24,14 +24,11 @@ public interface IProcessSupplierContext {
2424

2525
/**
2626
* Gets the {@link IProcessSupplier} for the given id from this context or <code>null</code> if no supplier exits for the id
27-
*
28-
* @param id
29-
* @return
3027
*/
3128
<T> IProcessSupplier<T> getSupplier(String id);
3229

3330
/**
34-
*
31+
*
3532
* iterates all available {@link IProcessSupplier}
3633
*/
3734
void visitSupplier(Consumer<? super IProcessSupplier<?>> consumer);
@@ -54,18 +51,14 @@ static Predicate<IProcessSupplier<?>> forDataTypes(Iterable<DataCategory> dataTy
5451
return test -> true;
5552
}
5653

57-
return new Predicate<IProcessSupplier<?>>() {
58-
59-
@Override
60-
public boolean test(IProcessSupplier<?> processSupplier) {
54+
return processSupplier -> {
6155

62-
for(DataCategory dataType : dataTypes) {
63-
if(processSupplier.getSupportedDataTypes().contains(dataType)) {
64-
return true;
65-
}
56+
for(DataCategory dataType : dataTypes) {
57+
if(processSupplier.getSupportedDataTypes().contains(dataType)) {
58+
return true;
6659
}
67-
return false;
6860
}
61+
return false;
6962
};
7063
}
7164

chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/internal/support/PreferencesProcessSupport.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* which is available at https://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
9+
*
1010
* Contributors:
1111
* Philip Wenig - initial API and implementation
1212
*******************************************************************************/
@@ -39,16 +39,12 @@ public class PreferencesProcessSupport {
3939
public PreferencesProcessSupport(DataCategory dataCategory) {
4040

4141
this.dataCategory = dataCategory;
42-
this.predicateProcessSupplier = new Predicate<IProcessSupplier<?>>() {
43-
44-
@Override
45-
public boolean test(IProcessSupplier<?> processSupplier) {
42+
this.predicateProcessSupplier = processSupplier -> {
4643

47-
if(processSupplier.getSupportedDataTypes().contains(DataCategory.AUTO_DETECT)) {
48-
return true;
49-
}
50-
return processSupplier.getSupportedDataTypes().contains(getDataCategory());
44+
if(processSupplier.getSupportedDataTypes().contains(DataCategory.AUTO_DETECT)) {
45+
return true;
5146
}
47+
return processSupplier.getSupportedDataTypes().contains(getDataCategory());
5248
};
5349

5450
updateProcessSuppliers();

0 commit comments

Comments
 (0)