code: static Entity.Builder asBuilderOrNew(Optional<Entity> entityOpt, Key key) {
      return entityOpt
          .map(c -> Entity.newBuilder(key, c))
          .orElse(Entity.newBuilder(key));
    }
docs: Convert an optional {@link Entity} into a builder if it exists, otherwise create a new builder.
  
  @param entityOpt  The optional entity
  @param key        The key for which to create a new builder if the entity is not present
  @return an entity builder either based of the given entity or a new one using the key.