Skip to content

Commit

Permalink
Merge pull request #65 from ccutrer/streamlining2
Browse files Browse the repository at this point in the history
Some streamlining
  • Loading branch information
andylintner authored Feb 12, 2019
2 parents e449fcf + b6501cc commit 0788d47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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

0 comments on commit 0788d47

Please sign in to comment.