Skip to content

Inconsistent method names [DATACMNS-1303] #1745

Open
@spring-projects-issues

Description

@spring-projects-issues

Kui Liu opened DATACMNS-1303 and commented

The following two methods are adding given events to the "domainEvents", so that their names should be "addEvents" and "addEventsFrom". However, they are named as "andEvents" and "andEventsFrom" respectively, which seems confusing.

     /**
	 * Adds the given event to the aggregate for later publication when calling a Spring Data repository's save-method.
	 * Does the same as {@link #registerEvent(Object)} but returns the aggregate instead of the event.
	 *
	 * @param event must not be {@literal null}.
	 * @return the aggregate
	 * @see #registerEvent(Object)
	 */
	@SuppressWarnings("unchecked")
	protected final A andEvent(Object event) {

		registerEvent(event);

		return (A) this;
	}

      /**
	 * Adds all events contained in the given aggregate to the current one.
	 *
	 * @param aggregate must not be {@literal null}.
	 * @return the aggregate
	 */
	@SuppressWarnings("unchecked")
	protected final A andEventsFrom(A aggregate) {

		Assert.notNull(aggregate, "Aggregate must not be null!");

		this.domainEvents.addAll(aggregate.domainEvents());

		return (A) this;
	}

Attachments:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions