Skip to content

refactor!: adjust library api for easier extension - #41

Merged
Laupetin merged 2 commits into
mainfrom
refactor/adjust-library-api-for-easier-extension
Aug 31, 2026
Merged

Laupetin merged 2 commits into
mainfrom
refactor/adjust-library-api-for-easier-extension

Conversation

@Laupetin

Copy link
Copy Markdown
Collaborator

The following restructurings have been made that require migration:

1. MatrixEventConsumer receives an event object instead of multiple parameters

Previously, event listeners received multiple parameters with details about the event that happened.
This is a bit annoying for future extension however as changing parameters is a breaking change.
Instead, methods on the listener receive an event object specific to the event triggered that contains details.
This event object can be extended in the future without breaking API.

Previously:

default void onMessage(MatrixState state, MatrixRoom room, MatrixMessage message) {}

Now:

default void onMessage(MatrixState state, MatrixMessageEvent event) {}

2. MatrixMessage no longer contains information about a message event

Previously, MatrixMessage contained information about a sender and its event id.
This however is information exclusively relevant and available for received messages.
This made it impossible to reuse these classes for sending messages.

Now MatrixMessage only holds information about the message itself, while information about an incoming message event is separated in MatrixMessageEvent.

3. Adjusted packages for public API

Several parts of the public API have been moved into appropriate packages and have been converted to interfaces to better allow hidden implementation details.

  • MatrixState:
    - package org.synyx.matrix.bot
    + package org.synyx.matrix.bot.domain.state
  • MatrixRoom:
    - package org.synyx.matrix.bot.domain
    + package org.synyx.matrix.bot.domain.state
  • MatrixUser:
    - package org.synyx.matrix.bot.domain
    + package org.synyx.matrix.bot.domain.state
  • MatrixMessage:
    - package org.synyx.matrix.bot.domain
    + package org.synyx.matrix.bot.domain.message
  • MatrixTextMessage:
    - package org.synyx.matrix.bot.domain
    + package org.synyx.matrix.bot.domain.message
  • MatrixEmoteMessage:
    - package org.synyx.matrix.bot.domain
    + package org.synyx.matrix.bot.domain.message
  • MatrixNoticeMessage:
    - package org.synyx.matrix.bot.domain
    + package org.synyx.matrix.bot.domain.message

@Laupetin
Laupetin merged commit 8ba0e53 into main Aug 31, 2026
2 checks passed
@Laupetin
Laupetin deleted the refactor/adjust-library-api-for-easier-extension branch August 31, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant