Skip to content

Commit ee9699e

Browse files
authored
Format by google style guide (#68)
* Ensure formatting with google style guide * Format all files * Correct flags for posix compatibility
1 parent 91304f0 commit ee9699e

File tree

119 files changed

+14208
-11558
lines changed

Some content is hidden

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

119 files changed

+14208
-11558
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ env:
1010
- secure: TmI+K6gSOfDy5oa5EgLCGijimKdR5cHAwM6RASDegTjlRQ/sWVf8BNF4IPJHnAYFWNCgyX6vLdfPS3IJNrYS9iI1Er2a1Ctcq1TbCZfZpn4eIj8mcUXxr2Fo6hLJh2KeuXj3OQwfUy/Jul1Own/9R5YoVDJYD0ntnt1HJgFqq+0=
1111
- secure: DethMgIykOufLLQn9Jykmg7rdvZp4ONXD4A1XVQNaEVQytv20Fb2QidEPmVEocuDmpmU6SjWNMhAeBdlWnyGB4lECMG9594HJpSnNkyFQzzsfSWdOwHixiUCuD+rMJlEPRJDM4ayxhilPnK1gkycKBAZ1gtutriC4O/BdEOCN6A=
1212
- secure: F6jGxeoyhD1tmC0ovRW2RqeEQDN5t5Kfqktmtcj0Lz3S4ddgzMwC6RYKyYiiu9T3FSfh/hEMrx2SrMK+Neu2ctfYflNibUjgZJVPZHR7DA3S+g30teyj10XWspb6+OLC7U0DnGbdLee/w0KkuugQHYNv1aM9oEPtLWi+3VpvIIU=
13+
before_script:
14+
- wget -O google-java-format https://github.com/google/google-java-format/releases/download/google-java-format-1.7/google-java-format-1.7-all-deps.jar
15+
- find . -name "*.java" | xargs java -jar google-java-format --set-exit-if-changed --replace
1316
script:
1417
- gradle test
1518
#after_success:

example/Example.java

Lines changed: 601 additions & 506 deletions
Large diffs are not rendered by default.

src/main/java/io/getstream/client/AggregatedFeed.java

Lines changed: 692 additions & 344 deletions
Large diffs are not rendered by default.
Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,62 @@
11
package io.getstream.client;
22

3+
import static io.getstream.core.utils.Auth.buildAnalyticsRedirectToken;
4+
import static io.getstream.core.utils.Auth.buildAnalyticsToken;
5+
36
import com.google.common.collect.Iterables;
47
import io.getstream.core.StreamAnalytics;
58
import io.getstream.core.exceptions.StreamException;
69
import io.getstream.core.http.Token;
710
import io.getstream.core.models.Engagement;
811
import io.getstream.core.models.Impression;
912
import io.getstream.core.utils.Auth.TokenAction;
10-
import java8.util.concurrent.CompletableFuture;
11-
1213
import java.net.URL;
13-
14-
import static io.getstream.core.utils.Auth.buildAnalyticsRedirectToken;
15-
import static io.getstream.core.utils.Auth.buildAnalyticsToken;
14+
import java8.util.concurrent.CompletableFuture;
1615

1716
public final class AnalyticsClient {
18-
private final String secret;
19-
private final StreamAnalytics analytics;
20-
21-
AnalyticsClient(String secret, StreamAnalytics analytics) {
22-
this.secret = secret;
23-
this.analytics = analytics;
24-
}
25-
26-
public CompletableFuture<Void> trackEngagement(Iterable<Engagement> events) throws StreamException {
27-
return trackEngagement(Iterables.toArray(events, Engagement.class));
28-
}
29-
30-
public CompletableFuture<Void> trackEngagement(Engagement... events) throws StreamException {
31-
final Token token = buildAnalyticsToken(secret, TokenAction.WRITE);
32-
return analytics.trackEngagement(token, events);
33-
}
34-
35-
public CompletableFuture<Void> trackImpression(Impression event) throws StreamException {
36-
final Token token = buildAnalyticsToken(secret, TokenAction.WRITE);
37-
return analytics.trackImpression(token, event);
38-
}
39-
40-
public URL createRedirectURL(URL url, Engagement... engagements) throws StreamException {
41-
return createRedirectURL(url, new Impression[0], engagements);
42-
}
43-
44-
public URL createRedirectURL(URL url, Impression... impressions) throws StreamException {
45-
return createRedirectURL(url, impressions, new Engagement[0]);
46-
}
47-
48-
public URL createRedirectURL(URL url, Iterable<Impression> impressions, Iterable<Engagement> engagements) throws StreamException {
49-
return createRedirectURL(url, Iterables.toArray(impressions, Impression.class), Iterables.toArray(engagements, Engagement.class));
50-
}
51-
52-
public URL createRedirectURL(URL url, Impression[] impressions, Engagement[] engagements) throws StreamException {
53-
final Token token = buildAnalyticsRedirectToken(secret);
54-
return analytics.createRedirectURL(token, url, impressions, engagements);
55-
}
17+
private final String secret;
18+
private final StreamAnalytics analytics;
19+
20+
AnalyticsClient(String secret, StreamAnalytics analytics) {
21+
this.secret = secret;
22+
this.analytics = analytics;
23+
}
24+
25+
public CompletableFuture<Void> trackEngagement(Iterable<Engagement> events)
26+
throws StreamException {
27+
return trackEngagement(Iterables.toArray(events, Engagement.class));
28+
}
29+
30+
public CompletableFuture<Void> trackEngagement(Engagement... events) throws StreamException {
31+
final Token token = buildAnalyticsToken(secret, TokenAction.WRITE);
32+
return analytics.trackEngagement(token, events);
33+
}
34+
35+
public CompletableFuture<Void> trackImpression(Impression event) throws StreamException {
36+
final Token token = buildAnalyticsToken(secret, TokenAction.WRITE);
37+
return analytics.trackImpression(token, event);
38+
}
39+
40+
public URL createRedirectURL(URL url, Engagement... engagements) throws StreamException {
41+
return createRedirectURL(url, new Impression[0], engagements);
42+
}
43+
44+
public URL createRedirectURL(URL url, Impression... impressions) throws StreamException {
45+
return createRedirectURL(url, impressions, new Engagement[0]);
46+
}
47+
48+
public URL createRedirectURL(
49+
URL url, Iterable<Impression> impressions, Iterable<Engagement> engagements)
50+
throws StreamException {
51+
return createRedirectURL(
52+
url,
53+
Iterables.toArray(impressions, Impression.class),
54+
Iterables.toArray(engagements, Engagement.class));
55+
}
56+
57+
public URL createRedirectURL(URL url, Impression[] impressions, Engagement[] engagements)
58+
throws StreamException {
59+
final Token token = buildAnalyticsRedirectToken(secret);
60+
return analytics.createRedirectURL(token, url, impressions, engagements);
61+
}
5662
}
Lines changed: 118 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,131 @@
11
package io.getstream.client;
22

3+
import static io.getstream.core.utils.Auth.*;
4+
35
import com.google.common.collect.Iterables;
6+
import io.getstream.core.KeepHistory;
47
import io.getstream.core.StreamBatch;
58
import io.getstream.core.exceptions.StreamException;
69
import io.getstream.core.http.Token;
710
import io.getstream.core.models.*;
8-
import io.getstream.core.KeepHistory;
911
import io.getstream.core.utils.DefaultOptions;
12+
import java.util.List;
1013
import java8.util.J8Arrays;
1114
import java8.util.concurrent.CompletableFuture;
1215

13-
import java.util.List;
14-
15-
import static io.getstream.core.utils.Auth.*;
16-
1716
public final class BatchClient {
18-
private final String secret;
19-
private final StreamBatch batch;
20-
21-
BatchClient(String secret, StreamBatch batch) {
22-
this.secret = secret;
23-
this.batch = batch;
24-
}
25-
26-
public CompletableFuture<Void> addToMany(Activity activity, FeedID... feeds) throws StreamException {
27-
final Token token = buildFeedToken(secret, TokenAction.WRITE);
28-
return batch.addToMany(token, activity, feeds);
29-
}
30-
31-
public CompletableFuture<Void> followMany(int activityCopyLimit, FollowRelation... follows) throws StreamException {
32-
final Token token = buildFollowToken(secret, TokenAction.WRITE);
33-
return batch.followMany(token, activityCopyLimit, follows);
34-
}
35-
36-
public CompletableFuture<Void> followMany(int activityCopyLimit, Iterable<FollowRelation> follows) throws StreamException {
37-
return followMany(activityCopyLimit, Iterables.toArray(follows, FollowRelation.class));
38-
}
39-
40-
public CompletableFuture<Void> followMany(FollowRelation... follows) throws StreamException {
41-
return followMany(DefaultOptions.DEFAULT_ACTIVITY_COPY_LIMIT, follows);
42-
}
43-
44-
public CompletableFuture<Void> followMany(Iterable<FollowRelation> follows) throws StreamException {
45-
return followMany(Iterables.toArray(follows, FollowRelation.class));
46-
}
47-
48-
public CompletableFuture<Void> unfollowMany(FollowRelation... follows) throws StreamException {
49-
final Token token = buildFollowToken(secret, TokenAction.WRITE);
50-
final UnfollowOperation[] ops = J8Arrays.stream(follows)
51-
.map(follow -> new UnfollowOperation(follow, io.getstream.core.KeepHistory.YES))
52-
.toArray(UnfollowOperation[]::new);
53-
return batch.unfollowMany(token, ops);
54-
}
55-
56-
public CompletableFuture<Void> unfollowMany(KeepHistory keepHistory, FollowRelation... follows) throws StreamException {
57-
final Token token = buildFollowToken(secret, TokenAction.WRITE);
58-
final UnfollowOperation[] ops = J8Arrays.stream(follows)
59-
.map(follow -> new UnfollowOperation(follow, keepHistory))
60-
.toArray(UnfollowOperation[]::new);
61-
return batch.unfollowMany(token, ops);
62-
}
63-
64-
public CompletableFuture<Void> unfollowMany(UnfollowOperation... unfollows) throws StreamException {
65-
final Token token = buildFollowToken(secret, TokenAction.WRITE);
66-
return batch.unfollowMany(token, unfollows);
67-
}
68-
69-
public CompletableFuture<List<Activity>> getActivitiesByID(Iterable<String> activityIDs) throws StreamException {
70-
return getActivitiesByID(Iterables.toArray(activityIDs, String.class));
71-
}
72-
73-
public CompletableFuture<List<Activity>> getActivitiesByID(String... activityIDs) throws StreamException {
74-
final Token token = buildActivityToken(secret, TokenAction.READ);
75-
return batch.getActivitiesByID(token, activityIDs);
76-
}
77-
78-
public CompletableFuture<List<EnrichedActivity>> getEnrichedActivitiesByID(Iterable<String> activityIDs) throws StreamException {
79-
return getEnrichedActivitiesByID(Iterables.toArray(activityIDs, String.class));
80-
}
81-
82-
public CompletableFuture<List<EnrichedActivity>> getEnrichedActivitiesByID(String... activityIDs) throws StreamException {
83-
final Token token = buildActivityToken(secret, TokenAction.READ);
84-
return batch.getEnrichedActivitiesByID(token, activityIDs);
85-
}
86-
87-
public CompletableFuture<List<Activity>> getActivitiesByForeignID(Iterable<ForeignIDTimePair> activityIDTimePairs) throws StreamException {
88-
return getActivitiesByForeignID(Iterables.toArray(activityIDTimePairs, ForeignIDTimePair.class));
89-
}
90-
91-
public CompletableFuture<List<Activity>> getActivitiesByForeignID(ForeignIDTimePair... activityIDTimePairs) throws StreamException {
92-
final Token token = buildActivityToken(secret, TokenAction.READ);
93-
return batch.getActivitiesByForeignID(token, activityIDTimePairs);
94-
}
95-
96-
public CompletableFuture<List<EnrichedActivity>> getEnrichedActivitiesByForeignID(Iterable<ForeignIDTimePair> activityIDTimePairs) throws StreamException {
97-
return getEnrichedActivitiesByForeignID(Iterables.toArray(activityIDTimePairs, ForeignIDTimePair.class));
98-
}
99-
100-
public CompletableFuture<List<EnrichedActivity>> getEnrichedActivitiesByForeignID(ForeignIDTimePair... activityIDTimePairs) throws StreamException {
101-
final Token token = buildActivityToken(secret, TokenAction.READ);
102-
return batch.getEnrichedActivitiesByForeignID(token, activityIDTimePairs);
103-
}
104-
105-
public CompletableFuture<Void> updateActivities(Iterable<Activity> activities) throws StreamException {
106-
return updateActivities(Iterables.toArray(activities, Activity.class));
107-
}
108-
109-
public CompletableFuture<Void> updateActivities(Activity... activities) throws StreamException {
110-
final Token token = buildActivityToken(secret, TokenAction.WRITE);
111-
return batch.updateActivities(token, activities);
112-
}
17+
private final String secret;
18+
private final StreamBatch batch;
19+
20+
BatchClient(String secret, StreamBatch batch) {
21+
this.secret = secret;
22+
this.batch = batch;
23+
}
24+
25+
public CompletableFuture<Void> addToMany(Activity activity, FeedID... feeds)
26+
throws StreamException {
27+
final Token token = buildFeedToken(secret, TokenAction.WRITE);
28+
return batch.addToMany(token, activity, feeds);
29+
}
30+
31+
public CompletableFuture<Void> followMany(int activityCopyLimit, FollowRelation... follows)
32+
throws StreamException {
33+
final Token token = buildFollowToken(secret, TokenAction.WRITE);
34+
return batch.followMany(token, activityCopyLimit, follows);
35+
}
36+
37+
public CompletableFuture<Void> followMany(int activityCopyLimit, Iterable<FollowRelation> follows)
38+
throws StreamException {
39+
return followMany(activityCopyLimit, Iterables.toArray(follows, FollowRelation.class));
40+
}
41+
42+
public CompletableFuture<Void> followMany(FollowRelation... follows) throws StreamException {
43+
return followMany(DefaultOptions.DEFAULT_ACTIVITY_COPY_LIMIT, follows);
44+
}
45+
46+
public CompletableFuture<Void> followMany(Iterable<FollowRelation> follows)
47+
throws StreamException {
48+
return followMany(Iterables.toArray(follows, FollowRelation.class));
49+
}
50+
51+
public CompletableFuture<Void> unfollowMany(FollowRelation... follows) throws StreamException {
52+
final Token token = buildFollowToken(secret, TokenAction.WRITE);
53+
final UnfollowOperation[] ops =
54+
J8Arrays.stream(follows)
55+
.map(follow -> new UnfollowOperation(follow, io.getstream.core.KeepHistory.YES))
56+
.toArray(UnfollowOperation[]::new);
57+
return batch.unfollowMany(token, ops);
58+
}
59+
60+
public CompletableFuture<Void> unfollowMany(KeepHistory keepHistory, FollowRelation... follows)
61+
throws StreamException {
62+
final Token token = buildFollowToken(secret, TokenAction.WRITE);
63+
final UnfollowOperation[] ops =
64+
J8Arrays.stream(follows)
65+
.map(follow -> new UnfollowOperation(follow, keepHistory))
66+
.toArray(UnfollowOperation[]::new);
67+
return batch.unfollowMany(token, ops);
68+
}
69+
70+
public CompletableFuture<Void> unfollowMany(UnfollowOperation... unfollows)
71+
throws StreamException {
72+
final Token token = buildFollowToken(secret, TokenAction.WRITE);
73+
return batch.unfollowMany(token, unfollows);
74+
}
75+
76+
public CompletableFuture<List<Activity>> getActivitiesByID(Iterable<String> activityIDs)
77+
throws StreamException {
78+
return getActivitiesByID(Iterables.toArray(activityIDs, String.class));
79+
}
80+
81+
public CompletableFuture<List<Activity>> getActivitiesByID(String... activityIDs)
82+
throws StreamException {
83+
final Token token = buildActivityToken(secret, TokenAction.READ);
84+
return batch.getActivitiesByID(token, activityIDs);
85+
}
86+
87+
public CompletableFuture<List<EnrichedActivity>> getEnrichedActivitiesByID(
88+
Iterable<String> activityIDs) throws StreamException {
89+
return getEnrichedActivitiesByID(Iterables.toArray(activityIDs, String.class));
90+
}
91+
92+
public CompletableFuture<List<EnrichedActivity>> getEnrichedActivitiesByID(String... activityIDs)
93+
throws StreamException {
94+
final Token token = buildActivityToken(secret, TokenAction.READ);
95+
return batch.getEnrichedActivitiesByID(token, activityIDs);
96+
}
97+
98+
public CompletableFuture<List<Activity>> getActivitiesByForeignID(
99+
Iterable<ForeignIDTimePair> activityIDTimePairs) throws StreamException {
100+
return getActivitiesByForeignID(
101+
Iterables.toArray(activityIDTimePairs, ForeignIDTimePair.class));
102+
}
103+
104+
public CompletableFuture<List<Activity>> getActivitiesByForeignID(
105+
ForeignIDTimePair... activityIDTimePairs) throws StreamException {
106+
final Token token = buildActivityToken(secret, TokenAction.READ);
107+
return batch.getActivitiesByForeignID(token, activityIDTimePairs);
108+
}
109+
110+
public CompletableFuture<List<EnrichedActivity>> getEnrichedActivitiesByForeignID(
111+
Iterable<ForeignIDTimePair> activityIDTimePairs) throws StreamException {
112+
return getEnrichedActivitiesByForeignID(
113+
Iterables.toArray(activityIDTimePairs, ForeignIDTimePair.class));
114+
}
115+
116+
public CompletableFuture<List<EnrichedActivity>> getEnrichedActivitiesByForeignID(
117+
ForeignIDTimePair... activityIDTimePairs) throws StreamException {
118+
final Token token = buildActivityToken(secret, TokenAction.READ);
119+
return batch.getEnrichedActivitiesByForeignID(token, activityIDTimePairs);
120+
}
121+
122+
public CompletableFuture<Void> updateActivities(Iterable<Activity> activities)
123+
throws StreamException {
124+
return updateActivities(Iterables.toArray(activities, Activity.class));
125+
}
126+
127+
public CompletableFuture<Void> updateActivities(Activity... activities) throws StreamException {
128+
final Token token = buildActivityToken(secret, TokenAction.WRITE);
129+
return batch.updateActivities(token, activities);
130+
}
113131
}

0 commit comments

Comments
 (0)