Skip to content

Commit d837d42

Browse files
olim7tadutra
authored andcommitted
JAVA-1925: Rename context getters
1 parent 05a3036 commit d837d42

134 files changed

Lines changed: 1034 additions & 598 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.

changelog/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### 4.0.0-beta2 (in progress)
66

7+
- [improvement] JAVA-1925: Rename context getters
78
- [improvement] JAVA-1544: Check API compatibility with Revapi
89
- [new feature] JAVA-1900: Add support for virtual tables
910

core/console.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ println("* implicit val session = builder.build *")
3535
println("********************************************")
3636

3737
def fire(event: AnyRef)(implicit session: CqlSession): Unit = {
38-
session.getContext.asInstanceOf[InternalDriverContext].eventBus().fire(event)
38+
session.getContext.asInstanceOf[InternalDriverContext].getEventBus().fire(event)
3939
}

core/revapi.json

Lines changed: 407 additions & 0 deletions
Large diffs are not rendered by default.

core/src/main/java/com/datastax/oss/driver/api/core/context/DriverContext.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,96 +44,96 @@ public interface DriverContext extends AttachmentPoint {
4444
* a reference to the context.
4545
*/
4646
@NonNull
47-
String sessionName();
47+
String getSessionName();
4848

4949
/** @return The driver's configuration; never {@code null}. */
5050
@NonNull
51-
DriverConfig config();
51+
DriverConfig getConfig();
5252

5353
/** @return The driver's configuration loader; never {@code null}. */
5454
@NonNull
55-
DriverConfigLoader configLoader();
55+
DriverConfigLoader getConfigLoader();
5656

5757
/** @return The driver's load balancing policies; may be empty but never {@code null}. */
5858
@NonNull
59-
Map<String, LoadBalancingPolicy> loadBalancingPolicies();
59+
Map<String, LoadBalancingPolicy> getLoadBalancingPolicies();
6060

6161
/**
6262
* @param profileName the profile name; never {@code null}.
6363
* @return The driver's load balancing policy for the given profile; never {@code null}.
6464
*/
6565
@NonNull
66-
default LoadBalancingPolicy loadBalancingPolicy(@NonNull String profileName) {
67-
LoadBalancingPolicy policy = loadBalancingPolicies().get(profileName);
66+
default LoadBalancingPolicy getLoadBalancingPolicy(@NonNull String profileName) {
67+
LoadBalancingPolicy policy = getLoadBalancingPolicies().get(profileName);
6868
// Protect against a non-existent name
6969
return (policy != null)
7070
? policy
71-
: loadBalancingPolicies().get(DriverExecutionProfile.DEFAULT_NAME);
71+
: getLoadBalancingPolicies().get(DriverExecutionProfile.DEFAULT_NAME);
7272
}
7373

7474
/** @return The driver's load balancing policies; may be empty but never {@code null}. */
7575
@NonNull
76-
Map<String, RetryPolicy> retryPolicies();
76+
Map<String, RetryPolicy> getRetryPolicies();
7777

7878
/**
7979
* @param profileName the profile name; never {@code null}.
8080
* @return The driver's retry policy for the given profile; never {@code null}.
8181
*/
8282
@NonNull
83-
default RetryPolicy retryPolicy(@NonNull String profileName) {
84-
RetryPolicy policy = retryPolicies().get(profileName);
85-
return (policy != null) ? policy : retryPolicies().get(DriverExecutionProfile.DEFAULT_NAME);
83+
default RetryPolicy getRetryPolicy(@NonNull String profileName) {
84+
RetryPolicy policy = getRetryPolicies().get(profileName);
85+
return (policy != null) ? policy : getRetryPolicies().get(DriverExecutionProfile.DEFAULT_NAME);
8686
}
8787

8888
/** @return The driver's load balancing policies; may be empty but never {@code null}. */
8989
@NonNull
90-
Map<String, SpeculativeExecutionPolicy> speculativeExecutionPolicies();
90+
Map<String, SpeculativeExecutionPolicy> getSpeculativeExecutionPolicies();
9191

9292
/**
9393
* @param profileName the profile name; never {@code null}.
9494
* @return The driver's speculative execution policy for the given profile; never {@code null}.
9595
*/
9696
@NonNull
97-
default SpeculativeExecutionPolicy speculativeExecutionPolicy(@NonNull String profileName) {
98-
SpeculativeExecutionPolicy policy = speculativeExecutionPolicies().get(profileName);
97+
default SpeculativeExecutionPolicy getSpeculativeExecutionPolicy(@NonNull String profileName) {
98+
SpeculativeExecutionPolicy policy = getSpeculativeExecutionPolicies().get(profileName);
9999
return (policy != null)
100100
? policy
101-
: speculativeExecutionPolicies().get(DriverExecutionProfile.DEFAULT_NAME);
101+
: getSpeculativeExecutionPolicies().get(DriverExecutionProfile.DEFAULT_NAME);
102102
}
103103

104104
/** @return The driver's timestamp generator; never {@code null}. */
105105
@NonNull
106-
TimestampGenerator timestampGenerator();
106+
TimestampGenerator getTimestampGenerator();
107107

108108
/** @return The driver's reconnection policy; never {@code null}. */
109109
@NonNull
110-
ReconnectionPolicy reconnectionPolicy();
110+
ReconnectionPolicy getReconnectionPolicy();
111111

112112
/** @return The driver's address translator; never {@code null}. */
113113
@NonNull
114-
AddressTranslator addressTranslator();
114+
AddressTranslator getAddressTranslator();
115115

116116
/** @return The authentication provider, if authentication was configured. */
117117
@NonNull
118-
Optional<AuthProvider> authProvider();
118+
Optional<AuthProvider> getAuthProvider();
119119

120120
/** @return The SSL engine factory, if SSL was configured. */
121121
@NonNull
122-
Optional<SslEngineFactory> sslEngineFactory();
122+
Optional<SslEngineFactory> getSslEngineFactory();
123123

124124
/** @return The driver's request tracker; never {@code null}. */
125125
@NonNull
126-
RequestTracker requestTracker();
126+
RequestTracker getRequestTracker();
127127

128128
/** @return The driver's request throttler; never {@code null}. */
129129
@NonNull
130-
RequestThrottler requestThrottler();
130+
RequestThrottler getRequestThrottler();
131131

132132
/** @return The driver's node state listener; never {@code null}. */
133133
@NonNull
134-
NodeStateListener nodeStateListener();
134+
NodeStateListener getNodeStateListener();
135135

136136
/** @return The driver's schema change listener; never {@code null}. */
137137
@NonNull
138-
SchemaChangeListener schemaChangeListener();
138+
SchemaChangeListener getSchemaChangeListener();
139139
}

core/src/main/java/com/datastax/oss/driver/api/core/cql/BatchStatement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ default int computeSizeInBytes(@NonNull DriverContext context) {
203203
for (BatchableStatement<?> batchableStatement : this) {
204204
size +=
205205
Sizes.sizeOfInnerBatchStatementInBytes(
206-
batchableStatement, context.protocolVersion(), context.codecRegistry());
206+
batchableStatement, context.getProtocolVersion(), context.getCodecRegistry());
207207
}
208208

209209
// per-query keyspace
@@ -212,7 +212,7 @@ default int computeSizeInBytes(@NonNull DriverContext context) {
212212
}
213213

214214
// timestamp
215-
if (!(context.timestampGenerator() instanceof ServerSideTimestampGenerator)
215+
if (!(context.getTimestampGenerator() instanceof ServerSideTimestampGenerator)
216216
|| getTimestamp() != Long.MIN_VALUE) {
217217

218218
size += PrimitiveSizes.LONG;

core/src/main/java/com/datastax/oss/driver/api/core/cql/BoundStatement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ default int computeSizeInBytes(@NonNull DriverContext context) {
8585
}
8686

8787
// timestamp
88-
if (!(context.timestampGenerator() instanceof ServerSideTimestampGenerator)
88+
if (!(context.getTimestampGenerator() instanceof ServerSideTimestampGenerator)
8989
|| getTimestamp() != Long.MIN_VALUE) {
9090
size += PrimitiveSizes.LONG;
9191
}

core/src/main/java/com/datastax/oss/driver/api/core/cql/SimpleStatement.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ default int computeSizeInBytes(@NonNull DriverContext context) {
264264

265265
// parameters
266266
size +=
267-
Sizes.sizeOfSimpleStatementValues(this, context.protocolVersion(), context.codecRegistry());
267+
Sizes.sizeOfSimpleStatementValues(
268+
this, context.getProtocolVersion(), context.getCodecRegistry());
268269

269270
// per-query keyspace
270271
if (getKeyspace() != null) {
@@ -280,7 +281,7 @@ default int computeSizeInBytes(@NonNull DriverContext context) {
280281
}
281282

282283
// timestamp
283-
if (!(context.timestampGenerator() instanceof ServerSideTimestampGenerator)
284+
if (!(context.getTimestampGenerator() instanceof ServerSideTimestampGenerator)
284285
|| getTimestamp() != Long.MIN_VALUE) {
285286
size += PrimitiveSizes.LONG;
286287
}

core/src/main/java/com/datastax/oss/driver/api/core/detach/AttachmentPoint.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ public interface AttachmentPoint {
2525
new AttachmentPoint() {
2626
@NonNull
2727
@Override
28-
public ProtocolVersion protocolVersion() {
28+
public ProtocolVersion getProtocolVersion() {
2929
return ProtocolVersion.DEFAULT;
3030
}
3131

3232
@NonNull
3333
@Override
34-
public CodecRegistry codecRegistry() {
34+
public CodecRegistry getCodecRegistry() {
3535
return CodecRegistry.DEFAULT;
3636
}
3737
};
3838

3939
@NonNull
40-
ProtocolVersion protocolVersion();
40+
ProtocolVersion getProtocolVersion();
4141

4242
@NonNull
43-
CodecRegistry codecRegistry();
43+
CodecRegistry getCodecRegistry();
4444
}

core/src/main/java/com/datastax/oss/driver/internal/core/addresstranslation/Ec2MultiRegionAddressTranslator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class Ec2MultiRegionAddressTranslator implements AddressTranslator {
6161

6262
public Ec2MultiRegionAddressTranslator(
6363
@SuppressWarnings("unused") @NonNull DriverContext context) {
64-
this.logPrefix = context.sessionName();
64+
this.logPrefix = context.getSessionName();
6565
@SuppressWarnings("JdkObsolete")
6666
Hashtable<Object, Object> env = new Hashtable<>();
6767
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory");

core/src/main/java/com/datastax/oss/driver/internal/core/auth/PlainTextAuthProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public class PlainTextAuthProvider implements AuthProvider {
5858

5959
/** Builds a new instance. */
6060
public PlainTextAuthProvider(DriverContext context) {
61-
this.logPrefix = context.sessionName();
62-
this.config = context.config().getDefaultProfile();
61+
this.logPrefix = context.getSessionName();
62+
this.config = context.getConfig().getDefaultProfile();
6363
}
6464

6565
@NonNull

0 commit comments

Comments
 (0)