Skip to content

Commit cab09fa

Browse files
committed
CheckStyle normalization
1 parent e5161d0 commit cab09fa

48 files changed

Lines changed: 456 additions & 367 deletions

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/com/pubnub/api/PNConfiguration.java‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
@Setter
1515
@Accessors(chain = true)
1616
public class PNConfiguration {
17+
private static final int PRESENCE_TIMEOUT = 300;
18+
private static final int NON_SUBSCRIBE_REQUEST_TIMEOUT = 10;
19+
private static final int SUBSCRIBE_TIMEOUT = 310;
20+
private static final int CONNECT_TIMEOUT = 5;
1721

1822
/**
1923
* By default, the origin is pointing directly to PubNub servers. If a proxy origin is neeeded, set a custom
@@ -68,8 +72,8 @@ public class PNConfiguration {
6872
private int connectTimeout;
6973

7074
/**
71-
* Reference on number of seconds which is used by client during non-subscription operations to
72-
check whether response potentially failed with 'timeout' or not.
75+
* Reference on number of seconds which is used by client during non-subscription operations to
76+
* check whether response potentially failed with 'timeout' or not.
7377
*/
7478
private int nonSubscribeRequestTimeout;
7579

@@ -81,28 +85,30 @@ public class PNConfiguration {
8185
/**
8286
* filterExpression used as part of PSV2 specification.
8387
*/
84-
@Setter private String filterExpression;
88+
@Setter
89+
private String filterExpression;
8590

8691
/**
8792
* Initialize the PNConfiguration with default values
8893
*/
8994
public PNConfiguration() {
90-
setPresenceTimeout(300);
95+
setPresenceTimeout(PRESENCE_TIMEOUT);
9196

9297
uuid = UUID.randomUUID().toString();
9398

94-
nonSubscribeRequestTimeout = 10;
95-
subscribeTimeout = 310;
96-
connectTimeout = 5;
99+
nonSubscribeRequestTimeout = NON_SUBSCRIBE_REQUEST_TIMEOUT;
100+
subscribeTimeout = SUBSCRIBE_TIMEOUT;
101+
connectTimeout = CONNECT_TIMEOUT;
97102

98103
logVerbosity = PNLogVerbosity.NONE;
99104

100105
heartbeatNotificationOptions = PNHeartbeatNotificationOptions.Failures;
101106
}
102107

103108
/**
104-
* set presence configurations for timeout and announce interval.
105-
* @param timeout presence timeout; how long before the server considers this client to be gone.
109+
* set presence configurations for timeout and announce interval.
110+
*
111+
* @param timeout presence timeout; how long before the server considers this client to be gone.
106112
* @param interval presence announce interval, how often the client should announce itself.
107113
* @return returns itself.
108114
*/
@@ -115,11 +121,12 @@ public PNConfiguration setPresenceTimeoutWithCustomInterval(final int timeout, f
115121

116122
/**
117123
* set presence configurations for timeout and allow the client to pick the best interval
124+
*
118125
* @param timeout presence timeout; how long before the server considers this client to be gone.
119126
* @return returns itself.
120127
*/
121128
public PNConfiguration setPresenceTimeout(final int timeout) {
122-
return setPresenceTimeoutWithCustomInterval(timeout,(timeout / 2) - 1);
129+
return setPresenceTimeoutWithCustomInterval(timeout, (timeout / 2) - 1);
123130
}
124131

125132
}

‎src/main/java/com/pubnub/api/PubNub.java‎

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,20 @@
77
import com.pubnub.api.endpoints.Time;
88
import com.pubnub.api.endpoints.access.Audit;
99
import com.pubnub.api.endpoints.access.Grant;
10-
import com.pubnub.api.endpoints.channel_groups.*;
10+
import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup;
11+
import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup;
12+
import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup;
13+
import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup;
14+
import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup;
1115
import com.pubnub.api.endpoints.presence.GetState;
1216
import com.pubnub.api.endpoints.presence.HereNow;
1317
import com.pubnub.api.endpoints.presence.SetState;
1418
import com.pubnub.api.endpoints.presence.WhereNow;
1519
import com.pubnub.api.endpoints.pubsub.Publish;
16-
import com.pubnub.api.endpoints.push.*;
20+
import com.pubnub.api.endpoints.push.AddChannelsToPush;
21+
import com.pubnub.api.endpoints.push.RemoveChannelsFromPush;
22+
import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice;
23+
import com.pubnub.api.endpoints.push.ListPushProvisions;
1724
import com.pubnub.api.managers.BasePathManager;
1825
import com.pubnub.api.managers.PublishSequenceManager;
1926
import com.pubnub.api.managers.SubscriptionManager;
@@ -43,11 +50,14 @@ public class PubNub {
4350

4451
private String sdkVersion;
4552

53+
private static final int TIMESTAMP_DIVIDER = 1000;
54+
private static final int MAX_SEQUENCE = 65535;
55+
4656
public PubNub(final PNConfiguration initialConfig) {
4757
this.configuration = initialConfig;
4858
this.subscriptionManager = new SubscriptionManager(this);
4959
this.basePathManager = new BasePathManager(initialConfig);
50-
this.publishSequenceManager = new PublishSequenceManager(65535);
60+
this.publishSequenceManager = new PublishSequenceManager(MAX_SEQUENCE);
5161

5262
sdkVersion = fetchSDKVersion();
5363
}
@@ -70,7 +80,9 @@ public final SubscribeBuilder subscribe() {
7080
return new SubscribeBuilder(this.subscriptionManager);
7181
}
7282

73-
public final UnsubscribeBuilder unsubscribe() { return new UnsubscribeBuilder(this.subscriptionManager); }
83+
public final UnsubscribeBuilder unsubscribe() {
84+
return new UnsubscribeBuilder(this.subscriptionManager);
85+
}
7486

7587
// start push
7688

@@ -95,6 +107,7 @@ public final ListPushProvisions auditPushChannelProvisions() {
95107
public final WhereNow whereNow() {
96108
return new WhereNow(this);
97109
}
110+
98111
public final HereNow hereNow() {
99112
return new HereNow(this);
100113
}
@@ -103,19 +116,23 @@ public final Time time() {
103116
return new Time(this);
104117
}
105118

106-
public final History history() { return new History(this); }
119+
public final History history() {
120+
return new History(this);
121+
}
107122

108123

109124
public final Audit audit() {
110125
return new Audit(this);
111126
}
127+
112128
public final Grant grant() {
113129
return new Grant(this);
114130
}
115131

116132
public final GetState getPresenceState() {
117133
return new GetState(this);
118134
}
135+
119136
public final SetState setPresenceState() {
120137
return new SetState(this, subscriptionManager);
121138
}
@@ -148,6 +165,7 @@ public final DeleteChannelGroup deleteChannelGroup() {
148165

149166
/**
150167
* Perform Cryptographic decryption of an input string using cipher key provided by PNConfiguration
168+
*
151169
* @param inputString String to be encrypted
152170
* @return String containing the encryption of inputString using cipherKey
153171
*/
@@ -161,10 +179,11 @@ public final String decrypt(String inputString) throws PubNubException {
161179

162180
/**
163181
* Perform Cryptographic decryption of an input string using the cipher key
182+
*
164183
* @param inputString String to be encrypted
165-
* @param cipherKey cipher key to be used for encryption
166-
* @throws PubNubException throws exception in case of failed encryption
184+
* @param cipherKey cipher key to be used for encryption
167185
* @return String containing the encryption of inputString using cipherKey
186+
* @throws PubNubException throws exception in case of failed encryption
168187
*/
169188
public final String decrypt(final String inputString, final String cipherKey) throws PubNubException {
170189
if (inputString == null) {
@@ -176,6 +195,7 @@ public final String decrypt(final String inputString, final String cipherKey) th
176195

177196
/**
178197
* Perform Cryptographic encryption of an input string and the cipher key provided by PNConfiguration
198+
*
179199
* @param inputString String to be encrypted
180200
* @return String containing the encryption of inputString using cipherKey
181201
*/
@@ -189,10 +209,11 @@ public final String encrypt(final String inputString) throws PubNubException {
189209

190210
/**
191211
* Perform Cryptographic encryption of an input string and the cipher key.
212+
*
192213
* @param inputString String to be encrypted
193-
* @param cipherKey cipher key to be used for encryption
194-
* @throws PubNubException throws exception in case of failed encryption
214+
* @param cipherKey cipher key to be used for encryption
195215
* @return String containing the encryption of inputString using cipherKey
216+
* @throws PubNubException throws exception in case of failed encryption
196217
*/
197218
public final String encrypt(final String inputString, final String cipherKey) throws PubNubException {
198219
if (inputString == null) {
@@ -203,7 +224,7 @@ public final String encrypt(final String inputString, final String cipherKey) th
203224
}
204225

205226
public int getTimestamp() {
206-
return (int) ((new Date().getTime()) / 1000);
227+
return (int) ((new Date().getTime()) / TIMESTAMP_DIVIDER);
207228
}
208229

209230
/**
@@ -229,6 +250,7 @@ public final void reconnect() {
229250

230251
/**
231252
* fetch the SDK version from the resource files.
253+
*
232254
* @return Stringified representation of the SDK version.
233255
*/
234256
private String fetchSDKVersion() {

‎src/main/java/com/pubnub/api/PubNubException.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ public class PubNubException extends Exception {
1717

1818
@Getter(AccessLevel.NONE)
1919
private Call affectedCall;
20-
}
20+
}

‎src/main/java/com/pubnub/api/PubNubUtil.java‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,26 @@
1616
/**
1717
* Created by Frederick on 3/30/16.
1818
*/
19-
public class PubNubUtil {
19+
public final class PubNubUtil {
2020

21+
private PubNubUtil() {
22+
}
2123

22-
public static String joinString(List<String> val, String delim){
24+
public static String joinString(List<String> val, String delim) {
2325
StringBuilder builder = new StringBuilder();
24-
for(String l: val){
26+
for (String l : val) {
2527
builder.append(l);
2628
builder.append(",");
2729
}
2830

29-
return builder.toString().substring(0,builder.toString().length() - 1);
31+
return builder.toString().substring(0, builder.toString().length() - 1);
3032

3133
}
3234

3335
/**
3436
* Returns encoded String
3537
*
36-
* @param sUrl
37-
* , input string
38+
* @param sUrl , input string
3839
* @return , encoded string
3940
*/
4041
public static String pamEncode(String sUrl) {
@@ -59,8 +60,7 @@ public static String pamEncode(String sUrl) {
5960
/**
6061
* Returns encoded String
6162
*
62-
* @param sUrl
63-
* , input string
63+
* @param sUrl , input string
6464
* @return , encoded string
6565
*/
6666
public static String urlEncode(String sUrl) {
@@ -71,7 +71,7 @@ public static String urlEncode(String sUrl) {
7171
}
7272
}
7373

74-
public static String preparePamArguments(Map<String, String> pamArgs){
74+
public static String preparePamArguments(Map<String, String> pamArgs) {
7575
Set<String> pamKeys = new TreeSet(pamArgs.keySet());
7676
String stringifiedArguments = "";
7777
int i = 0;

‎src/main/java/com/pubnub/api/builder/PubSubBuilder.java‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@
1111

1212
public abstract class PubSubBuilder {
1313

14-
@Getter(AccessLevel.NONE)
15-
@Setter(AccessLevel.NONE)
16-
protected List<String> channelSubscriptions;
14+
@Getter(AccessLevel.PROTECTED)
15+
@Setter(AccessLevel.PROTECTED)
16+
private List<String> channelSubscriptions;
1717

18-
@Getter(AccessLevel.NONE)
19-
@Setter(AccessLevel.NONE)
20-
protected List<String> channelGroupSubscriptions;
18+
@Getter(AccessLevel.PROTECTED)
19+
@Setter(AccessLevel.PROTECTED)
20+
private List<String> channelGroupSubscriptions;
2121

22-
@Getter(AccessLevel.NONE)
23-
@Setter(AccessLevel.NONE)
24-
protected SubscriptionManager subscriptionManager;
22+
@Getter(AccessLevel.PROTECTED)
23+
@Setter(AccessLevel.PROTECTED)
24+
private SubscriptionManager subscriptionManager;
2525

26-
public PubSubBuilder(SubscriptionManager subscriptionManager) {
27-
this.subscriptionManager = subscriptionManager;
26+
public PubSubBuilder(SubscriptionManager subscriptionManagerInstance) {
27+
this.subscriptionManager = subscriptionManagerInstance;
2828
this.channelSubscriptions = new ArrayList<>();
2929
this.channelGroupSubscriptions = new ArrayList<>();
3030
}

‎src/main/java/com/pubnub/api/builder/SubscribeBuilder.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import java.util.List;
1010

1111
@Setter
12-
@Accessors(chain = true, fluent = true)
13-
public class SubscribeBuilder extends PubSubBuilder {
12+
@Accessors(chain = true, fluent = true)
13+
public class SubscribeBuilder extends PubSubBuilder {
1414

1515
/**
1616
* Allow users to specify if they would also like to include the presence channels for those subscriptions.
@@ -33,20 +33,20 @@ public SubscribeBuilder withPresence() {
3333
return this;
3434
}
3535

36-
public SubscribeBuilder withTimetoken(final Long timetoken) {
37-
this.timetoken = timetoken;
36+
public SubscribeBuilder withTimetoken(Long timetokenInstance) {
37+
this.timetoken = timetokenInstance;
3838
return this;
3939
}
4040

4141
public void execute() {
4242
SubscribeOperation subscribeOperation = SubscribeOperation.builder()
43-
.channels(channelSubscriptions)
44-
.channelGroups(channelGroupSubscriptions)
43+
.channels(this.getChannelSubscriptions())
44+
.channelGroups(this.getChannelGroupSubscriptions())
4545
.timetoken(timetoken)
4646
.presenceEnabled(presenceEnabled)
4747
.build();
4848

49-
this.subscriptionManager.adaptSubscribeBuilder(subscribeOperation);
49+
this.getSubscriptionManager().adaptSubscribeBuilder(subscribeOperation);
5050
}
5151

5252
public SubscribeBuilder channels(final List<String> channels) {

‎src/main/java/com/pubnub/api/builder/UnsubscribeBuilder.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ public UnsubscribeBuilder(final SubscriptionManager subscriptionManager) {
1616
public void execute() {
1717

1818
UnsubscribeOperation unsubscribeOperation = UnsubscribeOperation.builder()
19-
.channels(channelSubscriptions)
20-
.channelGroups(channelGroupSubscriptions)
19+
.channels(this.getChannelSubscriptions())
20+
.channelGroups(this.getChannelGroupSubscriptions())
2121
.build();
2222

23-
this.subscriptionManager.adaptUnsubscribeBuilder(unsubscribeOperation);
23+
this.getSubscriptionManager().adaptUnsubscribeBuilder(unsubscribeOperation);
2424
}
2525

2626
}

0 commit comments

Comments
 (0)