Class Places

java.lang.Object
io.bloviate.datafaker.Places

public final class Places extends Object
Builds a RowContext of internally consistent Geo tuples for correlated geographic columns (issue #473). Unlike Datafaker's independent address parts (which yield "Springfield, WY 90210"), each row draws one real tuple from a bundled reference dataset, so the row's city, state, zip, and area_code columns agree.
RowContext<Geo> place = Places.unitedStates(seed);
Set.of(
    new ColumnConfiguration("city",      place.project(Geo::city)),
    new ColumnConfiguration("state",     place.project(Geo::stateAbbreviation)),
    new ColumnConfiguration("zip",       place.project(Geo::zip)),
    new ColumnConfiguration("area_code", place.project(Geo::areaCode)));

The tuple chosen for a row is a pure function of (seed, rowIndex), so the data is reproducible and order-independent under parallel/partitioned fills. The bundled dataset is a representative sample of US cities, not exhaustive; tuples repeat across rows (geography is not unique), so do not route UNIQUE columns through it.

Since:
2.12.0
See Also:
  • Method Details

    • unitedStates

      public static RowContext<Geo> unitedStates(long seed)
      A context of consistent US Geo tuples.
      Parameters:
      seed - the group seed; vary it for a different (still reproducible) sequence of places
      Returns:
      a row context wireable via RowContext.project(Function)