[infrastructure] add external null-annotations (#8848)
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
@@ -25,6 +25,7 @@ import javax.ws.rs.core.Response.ResponseBuilder;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.io.hueemulation.internal.dto.response.HueResponse;
|
||||
import org.openhab.io.hueemulation.internal.dto.response.HueResponse.HueErrorMessage;
|
||||
import org.openhab.io.hueemulation.internal.dto.response.HueResponseSuccessSimple;
|
||||
@@ -91,8 +92,9 @@ public class NetworkUtils {
|
||||
* @param message A message
|
||||
* @return
|
||||
*/
|
||||
public static Response singleError(Gson gson, UriInfo uri, int type, String message) {
|
||||
HueResponse e = new HueResponse(new HueErrorMessage(type, uri.getPath().replace("/api", ""), message));
|
||||
public static Response singleError(Gson gson, UriInfo uri, int type, @Nullable String message) {
|
||||
HueResponse e = new HueResponse(
|
||||
new HueErrorMessage(type, uri.getPath().replace("/api", ""), message != null ? message : ""));
|
||||
String str = gson.toJson(Collections.singleton(e), new TypeToken<List<?>>() {
|
||||
}.getType());
|
||||
int httpCode = 500;
|
||||
|
||||
@@ -308,10 +308,11 @@ public class Scenes implements RegistryChangeListener<Rule> {
|
||||
return NetworkUtils.singleError(cs.gson, uri, HueResponse.ARGUMENTS_INVALID, e.getMessage());
|
||||
}
|
||||
|
||||
List<String> lightsList = changeRequest.lights;
|
||||
return NetworkUtils.successList(cs.gson, Arrays.asList( //
|
||||
new HueSuccessGeneric(changeRequest.name, "/scenes/" + id + "/name"), //
|
||||
new HueSuccessGeneric(changeRequest.description, "/scenes/" + id + "/description"), //
|
||||
new HueSuccessGeneric(changeRequest.lights != null ? String.join(",", changeRequest.lights) : null,
|
||||
new HueSuccessGeneric(lightsList != null ? String.join(",", lightsList) : null,
|
||||
"/scenes/" + id + "/lights") //
|
||||
));
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.core.common.registry.RegistryChangeListener;
|
||||
import org.openhab.core.items.Item;
|
||||
import org.openhab.core.items.ItemNotFoundException;
|
||||
import org.openhab.core.items.ItemRegistry;
|
||||
import org.openhab.core.items.RegistryHook;
|
||||
|
||||
@@ -87,13 +88,21 @@ public class DummyItemRegistry implements ItemRegistry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItem(String name) {
|
||||
return items.get(name);
|
||||
public Item getItem(String name) throws ItemNotFoundException {
|
||||
Item item = items.get(name);
|
||||
if (item == null) {
|
||||
throw new ItemNotFoundException(name);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemByPattern(String name) {
|
||||
return items.get(name);
|
||||
public Item getItemByPattern(String name) throws ItemNotFoundException {
|
||||
Item item = items.get(name);
|
||||
if (item == null) {
|
||||
throw new ItemNotFoundException(name);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user