Class RowContext<E>

java.lang.Object
io.bloviate.datafaker.RowContext<E>
Type Parameters:
E - the entity type projected by the participating columns

public final class RowContext<E> extends Object
Materializes one coherent entity per row (a Person, a geo tuple, …) and lets several columns project fields out of it, so correlated columns agree — issue #473 "referential realism".

This is how Bloviate keeps cross-column consistency without breaking its two core invariants. The entity for a row is a pure function of (groupSeed, rowIndex) (supplied as the entityFactory), so it is the same no matter the order columns are generated or how the table is partitioned across threads — sequential and parallel fills produce identical data. The result is cached per thread for the current row, so the participating columns of a row materialize the entity once between them, not once each.

Wire correlated columns by sharing one context and registering each as a projection:

RowContext<Person> person = People.context(seed, Locale.ENGLISH);
Set.of(
    new ColumnConfiguration("first_name", person.project(Person::firstName)),
    new ColumnConfiguration("last_name",  person.project(Person::lastName)),
    new ColumnConfiguration("email",      person.project(Person::email)));   // jane.doe…@example.com
Since:
2.12.0
See Also:
  • Constructor Details

    • RowContext

      public RowContext(LongFunction<E> entityFactory)
      Creates a context that materializes one entity per row from the given factory.
      Parameters:
      entityFactory - a pure mapping from row index to the row's entity; must depend only on the row index (and a fixed seed it closes over) so output is order-independent
  • Method Details

    • at

      public E at(long rowIndex)
      Returns the entity for the given absolute row index, computing it at most once per row per thread.
      Parameters:
      rowIndex - the absolute, 0-based row index
      Returns:
      the row's entity
    • project

      public ColumnGeneratorFactory project(Function<E,String> selector)
      A ColumnGeneratorFactory that projects one field of this context's entity for each row. All projections of the same context stay in lockstep and consistent. The engine-supplied per-column random is intentionally ignored — the value comes from the shared entity.
      Parameters:
      selector - picks the field to emit (e.g. Person::email)
      Returns:
      a factory wireable through ColumnConfiguration