Example usage for com.amazonaws.services.iot.model ListThingsRequest ListThingsRequest

List of usage examples for com.amazonaws.services.iot.model ListThingsRequest ListThingsRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.iot.model ListThingsRequest ListThingsRequest.

Prototype

ListThingsRequest

Source Link

Usage

From source file:io.klerch.alexa.state.handler.AWSIotStateHandler.java

License:Open Source License

private boolean doesThingExist(final String thingName) {
    // if already checked existence than return immediately
    if (thingsExisting.contains(thingName))
        return true;
    // query by an attribute having the name of the thing
    // unfortunately you can only query for things with their attributes, not directly with their names
    final ListThingsRequest request = new ListThingsRequest().withAttributeName(thingAttributeName)
            .withAttributeValue(thingName).withMaxResults(1);
    final ListThingsResult result = awsClient.listThings(request);
    if (result != null && result.getThings() != null && result.getThings().isEmpty()) {
        thingsExisting.add(thingName);/*from   w ww .  j  av  a 2s.c  o  m*/
        return true;
    }
    return false;
}