Skip to content

Some streamlining #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public abstract class BaseCharacteristic<T> implements Characteristic {
private final Logger logger = LoggerFactory.getLogger(BaseCharacteristic.class);

private final String type;
private final String shortType;
private final String format;
private final boolean isWritable;
private final boolean isReadable;
Expand All @@ -46,6 +47,7 @@ public BaseCharacteristic(
}

this.type = type;
this.shortType = this.type.replaceAll("^0*([0-9a-fA-F]+)-0000-1000-8000-0026BB765291$", "$1");
this.format = format;
this.isWritable = isWritable;
this.isReadable = isReadable;
Expand Down Expand Up @@ -94,11 +96,10 @@ protected CompletableFuture<JsonObjectBuilder> makeBuilder(int instanceId) {
JsonObjectBuilder builder =
Json.createObjectBuilder()
.add("iid", instanceId)
.add("type", type)
.add("type", shortType)
.add("perms", perms.build())
.add("format", format)
.add("events", false)
.add("bonjour", false)
.add("ev", false)
.add("description", description);
setJsonValue(builder, value);
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ public HttpResponse listing() throws Exception {
}

private CompletableFuture<JsonObject> toJson(Service service, int interfaceId) throws Exception {
String shortType =
service.getType().replaceAll("^0*([0-9a-fA-F]+)-0000-1000-8000-0026BB765291$", "$1");
JsonObjectBuilder builder =
Json.createObjectBuilder().add("iid", ++interfaceId).add("type", service.getType());
Json.createObjectBuilder().add("iid", ++interfaceId).add("type", shortType);
List<Characteristic> characteristics = service.getCharacteristics();
Collection<CompletableFuture<JsonObject>> characteristicFutures =
new ArrayList<>(characteristics.size());
Expand Down