io.github.hapjava.server.impl.json.AccessoryController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hap Show documentation
Show all versions of hap Show documentation
Homekit Accessory Protocol for Java
package io.github.hapjava.server.impl.json;
import io.github.hapjava.accessories.HomekitAccessory;
import io.github.hapjava.characteristics.Characteristic;
import io.github.hapjava.server.impl.HomekitRegistry;
import io.github.hapjava.server.impl.http.HttpResponse;
import io.github.hapjava.services.Service;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
public class AccessoryController {
private final HomekitRegistry registry;
public AccessoryController(HomekitRegistry registry) {
this.registry = registry;
}
public HttpResponse listing() throws Exception {
JsonArrayBuilder accessories = Json.createArrayBuilder();
Map>> accessoryServiceFutures = new HashMap<>();
for (HomekitAccessory accessory : registry.getAccessories()) {
List> serviceFutures = new ArrayList<>();
Map servicesByInterfaceId = registry.getServices(accessory.getId());
Map