Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
adapt ConfigOptionProvider javadoc to reality (#3761)
Browse files Browse the repository at this point in the history
...as several implementations return null. Also, it does not make
much sense to instantiate empty collections all the time, as the
majority of call will be returned with no results.

Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
  • Loading branch information
sjsf authored and maggu2810 committed Jun 30, 2017
1 parent 9a6b043 commit d3de694
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Expand Up @@ -28,8 +28,7 @@ public interface ConfigOptionProvider {
* the parameter name for which the requested options shall be returned
* @param locale
* locale
* @return the configuration options provided by this provider (not
* null, could be empty)
* @return the configuration options provided by this provider if any or {@code null} otherwise
*/
Collection<ParameterOption> getParameterOptions(URI uri, String param, Locale locale);
}
Expand Up @@ -89,13 +89,14 @@ public Set<PersistenceService> getAll() {

@Override
public Collection<ParameterOption> getParameterOptions(URI uri, String param, Locale locale) {
Set<ParameterOption> options = new HashSet<>();
if (uri.toString().equals("system:persistence") && param.equals("default")) {
Set<ParameterOption> options = new HashSet<>();
for (PersistenceService service : getAll()) {
options.add(new ParameterOption(service.getId(), service.getLabel(locale)));
}
return options;
}
return options;
return null;
}

}
Expand Up @@ -11,7 +11,6 @@
import java.math.BigDecimal;
import java.net.URI;
import java.util.Collection;
import java.util.Collections;
import java.util.Locale;

import org.eclipse.smarthome.config.core.ParameterOption;
Expand All @@ -26,7 +25,7 @@ public class MagicServiceImpl implements MagicService {
@Override
public Collection<ParameterOption> getParameterOptions(URI uri, String param, Locale locale) {
if (!uri.equals(CONFIG_URI)) {
return Collections.emptyList();
return null;
}

if (param.equals(PARAMETER_BACKEND_DECIMAL)) {
Expand All @@ -35,7 +34,7 @@ public Collection<ParameterOption> getParameterOptions(URI uri, String param, Lo
new ParameterOption(BigDecimal.valueOf(21d).toPlainString(), "21"));
}

return Collections.emptyList();
return null;
}

}

0 comments on commit d3de694

Please sign in to comment.