29
29
import java .util .ArrayList ;
30
30
import java .util .Arrays ;
31
31
import java .util .Collection ;
32
- import java .util .Collections ;
33
32
import java .util .Comparator ;
34
33
import java .util .HashSet ;
35
34
import java .util .List ;
@@ -55,7 +54,6 @@ public abstract class SuggestionProvider<T> implements Callback<ISuggestionReque
55
54
/**
56
55
* Create a default suggestion provider based on the toString() method of the generic objects
57
56
* @param possibleSuggestions All possible suggestions
58
- * @return
59
57
*/
60
58
public static <T > SuggestionProvider <T > create (Collection <T > possibleSuggestions ) {
61
59
return create (null , possibleSuggestions );
@@ -67,7 +65,6 @@ public static <T> SuggestionProvider<T> create(Collection<T> possibleSuggestions
67
65
*
68
66
* @param stringConverter A stringConverter which converts generic T into a string
69
67
* @param possibleSuggestions All possible suggestions
70
- * @return
71
68
*/
72
69
public static <T > SuggestionProvider <T > create (Callback <T , String > stringConverter , Collection <T > possibleSuggestions ) {
73
70
SuggestionProviderString <T > suggestionProvider = new SuggestionProviderString <>(stringConverter );
@@ -77,15 +74,13 @@ public static <T> SuggestionProvider<T> create(Callback<T, String> stringConvert
77
74
78
75
/**
79
76
* Add the given new possible suggestions to this SuggestionProvider
80
- * @param newPossible
81
77
*/
82
78
public void addPossibleSuggestions (@ SuppressWarnings ("unchecked" ) T ... newPossible ) {
83
79
addPossibleSuggestions (Arrays .asList (newPossible ));
84
80
}
85
81
86
82
/**
87
83
* Add the given new possible suggestions to this SuggestionProvider
88
- * @param newPossible
89
84
*/
90
85
public void addPossibleSuggestions (Collection <T > newPossible ) {
91
86
synchronized (possibleSuggestionsLock ) {
@@ -113,39 +108,21 @@ public final Collection<T> call(final ISuggestionRequest request) {
113
108
}
114
109
}
115
110
}
116
- Collections .sort (suggestions , getComparator ());
111
+ suggestions .sort (getComparator ());
117
112
}
118
113
return suggestions ;
119
114
}
120
115
121
-
122
- /***************************************************************************
123
- * *
124
- * Static methods *
125
- * *
126
- **************************************************************************/
127
-
128
116
/**
129
117
* Get the comparator to order the suggestions
130
- * @return
131
118
*/
132
119
protected abstract Comparator <T > getComparator ();
133
120
134
121
/**
135
122
* Check the given possible suggestion is a match (is a valid suggestion)
136
- * @param suggestion
137
- * @param request
138
- * @return
139
123
*/
140
124
protected abstract boolean isMatch (T suggestion , ISuggestionRequest request );
141
125
142
-
143
- /***************************************************************************
144
- * *
145
- * Default implementations *
146
- * *
147
- **************************************************************************/
148
-
149
126
/**
150
127
* This is a simple string based suggestion provider.
151
128
* All generic suggestions T are turned into strings for processing.
@@ -166,18 +143,14 @@ public int compare(T o1, T o2) {
166
143
167
144
/**
168
145
* Create a new SuggestionProviderString
169
- * @param stringConverter
170
146
*/
171
147
public SuggestionProviderString (Callback <T , String > stringConverter ) {
172
148
this .stringConverter = stringConverter ;
173
149
174
150
// In case no stringConverter was provided, use the default strategy
175
151
if (this .stringConverter == null ) {
176
- this .stringConverter = new Callback <T , String >() {
177
- @ Override
178
- public String call (T obj ) {
179
- return obj != null ? obj .toString () : "" ; //$NON-NLS-1$
180
- }
152
+ this .stringConverter = obj -> {
153
+ return obj != null ? obj .toString () : "" ; //$NON-NLS-1$
181
154
};
182
155
}
183
156
}
0 commit comments