Skip to content

Commit

Permalink
GH-122: Fix auto-wiring ambiguity in the spring-twitter-supplier
Browse files Browse the repository at this point in the history
Fixes: #122
  • Loading branch information
artembilan committed Dec 19, 2024
1 parent d7a6c1e commit 40cff6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Cursor cursor() {
return new Cursor();
}

@Bean
@Bean("userRetriever")
@ConditionalOnProperty(name = "twitter.friendships.source.type", havingValue = "followers")
public Supplier<List<User>> followersSupplier(TwitterFriendshipsSupplierProperties properties, Twitter twitter,
Cursor cursorState) {
Expand Down Expand Up @@ -98,7 +98,7 @@ public Supplier<List<User>> followersSupplier(TwitterFriendshipsSupplierProperti
};
}

@Bean
@Bean("userRetriever")
@ConditionalOnProperty(name = "twitter.friendships.source.type", havingValue = "friends")
public Supplier<List<User>> friendsSupplier(TwitterFriendshipsSupplierProperties properties, Twitter twitter,
Cursor cursorState) {
Expand Down Expand Up @@ -147,10 +147,10 @@ public Function<List<User>, List<User>> userDeduplicate(MetadataStore metadataSt
}

@Bean
public Supplier<Message<byte[]>> deduplicatedFriendsJsonSupplier(Function<List<User>, List<User>> userDeduplication,
public Supplier<Message<byte[]>> deduplicatedFriendsJsonSupplier(Function<List<User>, List<User>> userDeduplicate,
Supplier<List<User>> userRetriever, Function<Object, Message<byte[]>> managedJson) {

return () -> userDeduplication.andThen(managedJson).apply(userRetriever.get());
return () -> userDeduplicate.andThen(managedJson).apply(userRetriever.get());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ public Function<List<DirectMessage>, List<DirectMessage>> messageDeduplicate(Met
@Bean
public Supplier<Message<byte[]>> twitterMessageSupplier(
Function<List<DirectMessage>, List<DirectMessage>> messageDeduplicate,
Function<Object, Message<byte[]>> managedJson, Supplier<List<DirectMessage>> directMessagesSupplier) {
Function<Object, Message<byte[]>> managedJson, Supplier<List<DirectMessage>> twitterMessagesSupplier) {

return () -> messageDeduplicate.andThen(managedJson).apply(directMessagesSupplier.get());
return () -> messageDeduplicate.andThen(managedJson).apply(twitterMessagesSupplier.get());
}

public static class MessageCursor {
Expand All @@ -142,14 +142,7 @@ public String toString() {

}

@SuppressWarnings("serial")
private static final class DirectMessageAdapter implements DirectMessage {

private final DirectMessage delegate;

private DirectMessageAdapter(DirectMessage delegate) {
this.delegate = delegate;
}
private record DirectMessageAdapter(DirectMessage delegate) implements DirectMessage {

@Override
public long getId() {
Expand Down

0 comments on commit 40cff6c

Please sign in to comment.