code: @SuppressWarnings("unchecked")
    public static <E> PartitionKey partitionKeyForEntity(PartitionStrategy strategy,
        E entity, EntityAccessor<E> accessor, @Nullable PartitionKey reuseKey) {
      List<FieldPartitioner> fieldPartitioners =
          Accessor.getDefault().getFieldPartitioners(strategy);
  
      PartitionKey key = (reuseKey == null ?
          new PartitionKey(new Object[fieldPartitioners.size()]) : reuseKey);
  
      for (int i = 0; i < fieldPartitioners.size(); i++) {
        FieldPartitioner fp = fieldPartitioners.get(i);
        key.set(i, fp.apply(accessor.get(entity, fp.getSourceName())));
      }
      return key;
    }
docs: <p>
  Construct a partition key for the given entity, reusing the supplied key if
  not null.
  </p>
  <p>
  This is a convenient way to find the partition that a given entity is
  written to, or to find a partition using objects from the entity domain.
  </p>