Skip to content

Commit a22d337

Browse files
committed
Run google java format.
- Moved various files to subpackages to reorder by their use - Add new interfaces to the events tree, this finally allow us to call sendStateEvent (more to come from this) Won't make any commit like this in the future hopefully...
1 parent 5d6ed5b commit a22d337

155 files changed

Lines changed: 4984 additions & 4512 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/main/java/io/github/hikingc/matrixsdk/api/Auth.java‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
///
88
/// @apiNote This is a Work-In-Progress interface
99
///
10-
/// @see <a href="https://spec.matrix.org/v1.19/client-server-api/#client-authentication">Matrix Client-Server API Specification for Authentication</a>
11-
/// @see <a href="https://spec.matrix.org/v1.19/client-server-api/#server-discovery">Matrix Client-Server API Specification for Server Discovery</a>
10+
/// @see <a href="https://spec.matrix.org/v1.19/client-server-api/#client-authentication">Matrix
11+
/// Client-Server API Specification for Authentication</a>
12+
/// @see <a href="https://spec.matrix.org/v1.19/client-server-api/#server-discovery">Matrix
13+
/// Client-Server API Specification for Server Discovery</a>
1214
public interface Auth {
1315

14-
AuthMetadata getAuthMetadata();
15-
16-
WhoAmI getCurrentAccountInformation();
16+
AuthMetadata getAuthMetadata();
1717

18+
WhoAmI getCurrentAccountInformation();
1819
}
Lines changed: 123 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,138 @@
11
package io.github.hikingc.matrixsdk.api;
22

33
import io.github.hikingc.matrixsdk.api.events.*;
4-
import io.github.hikingc.matrixsdk.api.events.messages.RoomMessageEvent;
5-
import io.github.hikingc.matrixsdk.api.events.types.RoomMemberEvent;
4+
import io.github.hikingc.matrixsdk.api.events.content.StateEventContent;
5+
import io.github.hikingc.matrixsdk.api.events.model.RoomMemberEvent;
6+
import io.github.hikingc.matrixsdk.api.events.queries.ChronologicalDirection;
7+
import io.github.hikingc.matrixsdk.api.events.queries.Membership;
8+
import io.github.hikingc.matrixsdk.api.events.queries.QueryParametersMessages;
9+
import io.github.hikingc.matrixsdk.api.events.queries.QueryParametersSync;
10+
import io.github.hikingc.matrixsdk.api.events.sync.Sync;
611
import io.github.hikingc.matrixsdk.api.identifiers.RoomID;
712
import io.github.hikingc.matrixsdk.exceptions.MatrixIOException;
813
import io.github.hikingc.matrixsdk.exceptions.MatrixNetworkException;
9-
1014
import java.nio.file.Path;
1115
import java.util.List;
1216

1317
/// Core interface for executing protocol operations against Room events.
1418
///
15-
/// All operations in this interface are blocking. Implementations must ensure
16-
/// thread safety and avoid synchronization blocks that cause carrier thread pinning
17-
/// during network I/O.
19+
/// All operations in this interface are blocking. Implementations must ensure thread safety and
20+
/// avoid synchronization blocks that cause carrier thread pinning during network I/O.
1821
///
19-
/// @see <a href="https://spec.matrix.org/v1.19/client-server-api/#events">Matrix Client-Server API Specification for Events</a>
22+
/// @see <a href="https://spec.matrix.org/v1.19/client-server-api/#events">Matrix Client-Server API
23+
/// Specification for Events</a>
2024
public interface Event {
2125

22-
/// Gets an event from a room.
23-
///
24-
/// @param roomId the room ID where the event is.
25-
/// @param eventId the event ID to retrieve.
26-
/// @return the full event.
27-
DeserializedEvent getEvent(RoomID roomId, String eventId);
28-
29-
/// Returns currently-joined members
30-
///
31-
/// @param roomId the room ID to fetch data from.
32-
/// @return a list of room members.
33-
RoomMembers getJoinedMembers(RoomID roomId);
34-
35-
/// Returns a filterable list of members and their current membership state in a room.
36-
///
37-
/// @param roomId the room ID to fetch data from.
38-
/// @param at the point in time (pagination token) to return members for in the room. This token can be obtained from a `prev_batch` token returned for each room by the sync API.
39-
/// @param membership the kind of membership to filter for. When specified alongside notMembership, the two parameters create an `or` condition
40-
/// @param notMembership the kind of membership to exclude from the results. Defaults to no filtering if unspecified.
41-
/// @return a list of [DeserializedEvent]s with the membership information of room members.
42-
List<RoomMemberEvent> getMembers(RoomID roomId, String at, Membership membership, Membership notMembership);
43-
44-
/// Get the state events for the current state of a room.
45-
///
46-
/// @param roomId the room ID to fetch data from.
47-
/// @return the current state of the room
48-
List<DeserializedEvent<?>> getStateEvents(RoomID roomId);
49-
50-
/// Looks up the contents of a state event in a room. If the user is joined to the room then the state is taken from the current state of the room.
51-
/// If the user has left the room then the state is taken from the state of the room when they left.
52-
///
53-
/// @param roomId the room ID to fetch data from.
54-
/// @param eventType the type of state to look up.
55-
/// @param stateKey the room to look up the state in.
56-
/// @return the content of the event, including all additional metadata fields.
57-
DeserializedEvent getStateEvent(RoomID roomId, String eventType, String stateKey);
58-
59-
/// Returns a list of message and state events for a room. It uses pagination query parameters to paginate
60-
/// history in the room.
61-
/// The content is not parsed or escaped which means newlines (`\n`) and such escape sequences will not be parsed.
62-
///
63-
/// @param roomId the room ID to fetch data from.
64-
/// @param params the [QueryParametersMessages] for the operation.
65-
/// @param dir the [ChronologicalDirection] in which to search
66-
/// @return [Messages] with available data.
67-
/// @throws MatrixIOException when the payload cannot be processed.
68-
/// @throws NullPointerException when the roomId is null.
69-
Messages getMessages(RoomID roomId, ChronologicalDirection dir, QueryParametersMessages params);
70-
71-
/// Gets an event from a room closest to the given timestamp, in the direction specified by the `dir` parameter.
72-
///
73-
/// @param roomId the room ID to fetch data from.
74-
/// @param dir the [ChronologicalDirection] in which to search
75-
/// @param timestamp the timestamp to search from, as given in milliseconds since the Unix epoch.
76-
/// @return [EventMetadata] if an event was found.
77-
EventMetadata getEventClosestToTimestamp(RoomID roomId, ChronologicalDirection dir, int timestamp);
78-
79-
/// Get a copy of the current state and the most recent messages in a room.
80-
/// Exclusively used for "peeking", otherwise use [#sync(QueryParametersSync)].
81-
///
82-
/// @param roomId the room ID to fetch data from.
83-
/// @return [RoomInfo] with current state of the room.
84-
RoomInfo getInitialSync(RoomID roomId);
85-
86-
/// @deprecated Experimental API that will suffer changes. It is likely this method will be deprecated
87-
@Deprecated(since = "2026-07-31")
88-
String sendStateEvent(RoomID roomId, String eventType, String stateKey, DeserializedEvent<?> matrixRoomMessageEvent);
89-
90-
/// Creates a `m.room.message` event to a Matrix room.
91-
///
92-
/// @param roomId the room ID where to send the event.
93-
/// @param roomMessageEvent a well constructed [RoomMessageEvent].
94-
/// @return a [String] representing a unique identifier of the event.
95-
/// @throws MatrixIOException when the payload cannot be processed.
96-
/// @throws MatrixNetworkException when the response status is not successful.
97-
String sendMessageEvent(RoomID roomId, RoomMessageEvent roomMessageEvent);
98-
99-
/// Strips all information out of an event which isn’t critical to the integrity of the server-side representation of the room.
100-
///
101-
/// **This cannot be undone.**
102-
///
103-
/// If the server advertises support for sending a state event using `m.room.redact`,
104-
/// use [#sendStateEvent(RoomID, String, String, DeserializedEvent)]
105-
///
106-
/// @param roomId the room ID where to redact the event.
107-
/// @param eventId the event ID of the event to target and redact.
108-
/// @param txnId the transaction ID of the event.
109-
/// @param reason the reason of the redaction.
110-
/// @return a [String] representing a unique identifier of the event.
111-
String redactEvent(RoomID roomId, String eventId, String txnId, String reason);
112-
113-
/// Synchronously uploads a local multimedia resource to the Matrix media server.
114-
///
115-
/// @param resource the [Path] of the resource to upload.
116-
/// @return a [String] containing the MXC upon a successful upload.
117-
String uploadResource(Path resource);
118-
119-
/// Sends a `/sync` request, this method is not responsible for any type of HTTP Polling.
120-
///
121-
/// @param params the [QueryParametersSync] for the query, not all are required.
122-
/// @return [Sync] with all the corresponding information.
123-
/// @throws MatrixIOException when the payload cannot be processed.
124-
/// @throws MatrixNetworkException when the response status is not successful.
125-
Sync sync(QueryParametersSync params);
126-
127-
26+
/// Gets an event from a room.
27+
///
28+
/// @param roomId the room ID where the event is.
29+
/// @param eventId the event ID to retrieve.
30+
/// @return the full event.
31+
ClientEvent getEvent(RoomID roomId, String eventId);
32+
33+
/// Returns currently-joined members
34+
///
35+
/// @param roomId the room ID to fetch data from.
36+
/// @return a list of room members.
37+
RoomMembers getJoinedMembers(RoomID roomId);
38+
39+
/// Returns a filterable list of members and their current membership state in a room.
40+
///
41+
/// @param roomId the room ID to fetch data from.
42+
/// @param at the point in time (pagination token) to return members for in the room. This token
43+
/// can be obtained from a `prev_batch` token returned for each room by the sync API.
44+
/// @param membership the kind of membership to filter for. When specified alongside
45+
/// notMembership, the two parameters create an `or` condition
46+
/// @param notMembership the kind of membership to exclude from the results. Defaults to no
47+
/// filtering if unspecified.
48+
/// @return a list of [ClientEvent]s with the membership information of room members.
49+
List<RoomMemberEvent> getMembers(
50+
RoomID roomId, String at, Membership membership, Membership notMembership);
51+
52+
/// Get the state events for the current state of a room.
53+
///
54+
/// @param roomId the room ID to fetch data from.
55+
/// @return the current state of the room
56+
List<ClientEvent<?>> getStateEvents(RoomID roomId);
57+
58+
/// Looks up the contents of a state event in a room. If the user is joined to the room then the
59+
/// state is taken from the current state of the room. If the user has left the room then the
60+
/// state is taken from the state of the room when they left.
61+
///
62+
/// @param roomId the room ID to fetch data from.
63+
/// @param eventType the type of state to look up.
64+
/// @param stateKey the room to look up the state in.
65+
/// @return the content of the event, including all additional metadata fields.
66+
@SuppressWarnings("java:S1452")
67+
// Caller doesn't know content type ahead of time; polymorphic dispatch via @JsonTypeInfo resolves
68+
// it
69+
ClientEvent<?> getStateEvent(RoomID roomId, String eventType, String stateKey);
70+
71+
/// Returns a list of message and state events for a room. It uses pagination query parameters to
72+
/// paginate history in the room. The content is not parsed or escaped which means newlines (`\n`)
73+
/// and such escape sequences will not be parsed.
74+
///
75+
/// @param roomId the room ID to fetch data from.
76+
/// @param params the [QueryParametersMessages] for the operation.
77+
/// @param dir the [ChronologicalDirection] in which to search
78+
/// @return [Messages] with available data.
79+
/// @throws MatrixIOException when the payload cannot be processed.
80+
/// @throws NullPointerException when the roomId is null.
81+
Messages getMessages(RoomID roomId, ChronologicalDirection dir, QueryParametersMessages params);
82+
83+
/// Gets an event from a room closest to the given timestamp, in the direction specified by the
84+
/// `dir` parameter.
85+
///
86+
/// @param roomId the room ID to fetch data from.
87+
/// @param dir the [ChronologicalDirection] in which to search
88+
/// @param timestamp the timestamp to search from, as given in milliseconds since the Unix epoch.
89+
/// @return [EventMetadata] if an event was found.
90+
EventMetadata getEventClosestToTimestamp(
91+
RoomID roomId, ChronologicalDirection dir, int timestamp);
92+
93+
/// Get a copy of the current state and the most recent messages in a room. Exclusively used for
94+
/// "peeking", otherwise use [#sync(QueryParametersSync)].
95+
///
96+
/// @param roomId the room ID to fetch data from.
97+
/// @return [RoomInfo] with current state of the room.
98+
RoomInfo getInitialSync(RoomID roomId);
99+
100+
/// @param roomId the room ID where to send the event.
101+
/// @param stateKey if required to be set the state key, otherwise an empty [String] ("").
102+
/// @param roomStateContent any type of state event.
103+
/// @return a [String] representing a unique identifier of the event.
104+
/// @throws MatrixIOException when the payload cannot be processed.
105+
/// @throws MatrixNetworkException when the response status is not successful.
106+
String sendStateEvent(RoomID roomId, String stateKey, StateEventContent roomStateContent);
107+
108+
String sendEvent(RoomID roomId, MessageEventContent content, String txnId);
109+
110+
/// Strips all information out of an event which isn’t critical to the integrity of the
111+
/// server-side representation of the room.
112+
///
113+
/// **This cannot be undone.**
114+
///
115+
/// If the server advertises support for sending a state event using `m.room.redact`, use
116+
/// [#sendEvent(RoomID, MessageEventContent , String)]
117+
///
118+
/// @param roomId the room ID where to redact the event.
119+
/// @param eventId the event ID of the event to target and redact.
120+
/// @param txnId the transaction ID of the event.
121+
/// @param reason the reason of the redaction.
122+
/// @return a [String] representing a unique identifier of the event.
123+
String redactEvent(RoomID roomId, String eventId, String txnId, String reason);
124+
125+
/// Synchronously uploads a local multimedia resource to the Matrix media server.
126+
///
127+
/// @param resource the [Path] of the resource to upload.
128+
/// @return a [String] containing the MXC upon a successful upload.
129+
String uploadResource(Path resource);
130+
131+
/// Sends a `/sync` request, this method is not responsible for any type of HTTP Polling.
132+
///
133+
/// @param params the [QueryParametersSync] for the query, not all are required.
134+
/// @return [Sync] with all the corresponding information.
135+
/// @throws MatrixIOException when the payload cannot be processed.
136+
/// @throws MatrixNetworkException when the response status is not successful.
137+
Sync sync(QueryParametersSync params);
128138
}

‎src/main/java/io/github/hikingc/matrixsdk/api/Filter.java‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55

66
/// Core interface for executing protocol operations for filtering.
77
///
8-
/// All operations in this interface are blocking. Implementations must ensure
9-
/// thread safety and avoid synchronization blocks that cause carrier thread pinning
10-
/// during network I/O.
8+
/// All operations in this interface are blocking. Implementations must ensure thread safety and
9+
/// avoid synchronization blocks that cause carrier thread pinning during network I/O.
1110
///
12-
/// @see <a href="https://spec.matrix.org/v1.19/client-server-api/#filtering>Matrix Client-Server API Specification for Filters</a>
11+
/// @see <a href="https://spec.matrix.org/v1.19/client-server-api/#filtering>Matrix Client-Server
12+
/// API Specification for Filters</a>
1313
public interface Filter {
1414

15-
/// Uploads a new filter definition to the homeserver.
16-
/// Returns a filter ID that may be used in future requests to restrict which events are returned to the client.
17-
///
18-
/// @param userId the [UserID] of whoever is uploading the server.
19-
/// @param filter the definition of the filter.
20-
/// @return an ID of the filter definition, usable in supported endpoints.
21-
String publishFilter(UserID userId, FilterDefinition filter);
15+
/// Uploads a new filter definition to the homeserver. Returns a filter ID that may be used in
16+
/// future requests to restrict which events are returned to the client.
17+
///
18+
/// @param userId the [UserID] of whoever is uploading the server.
19+
/// @param filter the definition of the filter.
20+
/// @return an ID of the filter definition, usable in supported endpoints.
21+
String publishFilter(UserID userId, FilterDefinition filter);
2222

23-
/// Retrieve a [FilterDefinition] from the homeserver.
24-
///
25-
/// @param userId the [UserID] to download a filter for.
26-
/// @param filterId the filter ID to download.
27-
/// @return a [FilterDefinition] with all uploaded data.
28-
FilterDefinition getFilter(UserID userId, String filterId);
29-
}
23+
/// Retrieve a [FilterDefinition] from the homeserver.
24+
///
25+
/// @param userId the [UserID] to download a filter for.
26+
/// @param filterId the filter ID to download.
27+
/// @return a [FilterDefinition] with all uploaded data.
28+
FilterDefinition getFilter(UserID userId, String filterId);
29+
}

0 commit comments

Comments
 (0)