Esempio n. 1
0
  // TODO get action should be able to return futures with sub-types of entity
  // wrapper
  public CompletableFuture<EntityWrapper<?>> get(String username) {
    // yes this is very inefficient. The plan is to get it working and then
    // get it right

    Stream<EntityRelationship> children;
    children = getEntities().stream();

    Stream<EntityRelationship> filtered =
        children.filter(
            child -> {
              String childUsername =
                  child.resolve(Account.class).join().getProperties().getUsername();
              return childUsername == null && username == null || childUsername.equals(username);
            });

    EntityRelationship entityRelationship = filtered.findAny().get();
    return (CompletableFuture) entityRelationship.resolve(Account.class);
  }
Esempio n. 2
0
 public static <T> boolean isEmpty(@Nullable Stream<T> items) {
   return items == null || !items.findAny().isPresent();
 }