From 1477884b6d8928cb82dfaa799688ce7565acb12c Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Fri, 22 Nov 2024 14:07:09 +0200 Subject: [PATCH 1/3] Add example of a factory method in naming conventions --- doc/dev/decisionrecords/NamingConventions.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/dev/decisionrecords/NamingConventions.md b/doc/dev/decisionrecords/NamingConventions.md index 16b37a799bf..324d8275712 100644 --- a/doc/dev/decisionrecords/NamingConventions.md +++ b/doc/dev/decisionrecords/NamingConventions.md @@ -44,6 +44,7 @@ Here is a list of common prefixes used and what to expect. | `listStops() : List/Stream` | List ALL stops in context; return a Collection or Stream (List is preferred). | | `withStop(Stop stop) : Builder` | Set Stop in builder, replacing existing value; return `this` builder. | | `initStop(Stop stop) : void` | Set property _once_; a second call throws an exception. | +| `createStop(String name) : Stop` | Factory methods for creating objects should start with `create` prefix. | | `addStop(Stop stop) : void/Builder` | Add a Stop to a collection of Stops. | | `addStops(Collection stops) : void/Builder` | Add set of Stops to existing set. | | `withBike(Consumer body) : Builder` | For nested builders, use lambdas. | From 3034d811064e3b9b6486c8ec91acbf8c8f0fbcef Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Fri, 22 Nov 2024 23:05:28 +0200 Subject: [PATCH 2/3] Update doc/dev/decisionrecords/NamingConventions.md Co-authored-by: Thomas Gran --- doc/dev/decisionrecords/NamingConventions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/dev/decisionrecords/NamingConventions.md b/doc/dev/decisionrecords/NamingConventions.md index 324d8275712..b5fa11628ec 100644 --- a/doc/dev/decisionrecords/NamingConventions.md +++ b/doc/dev/decisionrecords/NamingConventions.md @@ -44,7 +44,8 @@ Here is a list of common prefixes used and what to expect. | `listStops() : List/Stream` | List ALL stops in context; return a Collection or Stream (List is preferred). | | `withStop(Stop stop) : Builder` | Set Stop in builder, replacing existing value; return `this` builder. | | `initStop(Stop stop) : void` | Set property _once_; a second call throws an exception. | -| `createStop(String name) : Stop` | Factory methods for creating objects should start with `create` prefix. | +| `createStop(String name, ...) : Stop` | Factory methods for creating objects should start with `create` prefix. | +| | See (Builder Conventions)[RecordsPOJOsBuilders.md#builder-conventions] for creating objects with builders. | | `addStop(Stop stop) : void/Builder` | Add a Stop to a collection of Stops. | | `addStops(Collection stops) : void/Builder` | Add set of Stops to existing set. | | `withBike(Consumer body) : Builder` | For nested builders, use lambdas. | From bbcac591c68354ad119b8f19725057045a18bbf1 Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Fri, 22 Nov 2024 23:22:41 +0200 Subject: [PATCH 3/3] Add doc for of, copyOf and build and reorder --- doc/dev/decisionrecords/NamingConventions.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/dev/decisionrecords/NamingConventions.md b/doc/dev/decisionrecords/NamingConventions.md index b5fa11628ec..6aef8d7f7e1 100644 --- a/doc/dev/decisionrecords/NamingConventions.md +++ b/doc/dev/decisionrecords/NamingConventions.md @@ -42,13 +42,16 @@ Here is a list of common prefixes used and what to expect. | `findStop(Criteria criteria) : Optional` | Find one or zero stops; return `Optional`. | | `findStops(Criteria criteria) : List/Stream` | Find 0, 1, or many stops; return a Collection or Stream (List is preferred). | | `listStops() : List/Stream` | List ALL stops in context; return a Collection or Stream (List is preferred). | -| `withStop(Stop stop) : Builder` | Set Stop in builder, replacing existing value; return `this` builder. | | `initStop(Stop stop) : void` | Set property _once_; a second call throws an exception. | -| `createStop(String name, ...) : Stop` | Factory methods for creating objects should start with `create` prefix. | -| | See (Builder Conventions)[RecordsPOJOsBuilders.md#builder-conventions] for creating objects with builders. | +| `createStop(String name, ...) : Stop` | Factory methods for creating objects should start with `create` prefix. | +| | See (Builder Conventions)[RecordsPOJOsBuilders.md#builder-conventions] for creating objects with builders. | | `addStop(Stop stop) : void/Builder` | Add a Stop to a collection of Stops. | | `addStops(Collection stops) : void/Builder` | Add set of Stops to existing set. | | `withBike(Consumer body) : Builder` | For nested builders, use lambdas. | +| `withStop(Stop stop) : Builder` | Set Stop in builder, replacing existing value; return `this` builder. | +| `of(FeedScopedId id) : Builder` | Create new builder instance from `Stop` class. | +| `copyOf() : Builder` | Initialize a new builder instance from `Stop` instance with identical values. | +| `build() : Stop` | Finish building stop with a builder. | These prefixes are also "allowed" but not preferred; they have some kind of negative "force" to them.