Skip to content

Commit cfb6971

Browse files
committed
Rename actions to their verb
- Rename factory methods on resources to make it clear that the Worker is returned - Update execute method on actions to be the name of the action - Rename reader fitlers to be `set*`
1 parent fb79315 commit cfb6971

File tree

601 files changed

+2847
-2307
lines changed

Some content is hidden

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

601 files changed

+2847
-2307
lines changed

src/main/java/com/twilio/base/Creator.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public abstract class Creator<T extends Resource> {
1818
*
1919
* @return future that resolves to requested object
2020
*/
21-
public ListenableFuture<T> async() {
22-
return async(Twilio.getRestClient());
21+
public ListenableFuture<T> createAsync() {
22+
return createAsync(Twilio.getRestClient());
2323
}
2424

2525
/**
@@ -28,10 +28,10 @@ public ListenableFuture<T> async() {
2828
* @param client client used to make request
2929
* @return future that resolves to requested object
3030
*/
31-
public ListenableFuture<T> async(final TwilioRestClient client) {
31+
public ListenableFuture<T> createAsync(final TwilioRestClient client) {
3232
return Twilio.getExecutorService().submit(new Callable<T>() {
3333
public T call() {
34-
return execute(client);
34+
return create(client);
3535
}
3636
});
3737
}
@@ -41,8 +41,8 @@ public T call() {
4141
*
4242
* @return Requested object
4343
*/
44-
public T execute() {
45-
return execute(Twilio.getRestClient());
44+
public T create() {
45+
return create(Twilio.getRestClient());
4646
}
4747

4848
/**
@@ -51,5 +51,5 @@ public T execute() {
5151
* @param client client used to make request
5252
* @return Requested object
5353
*/
54-
public abstract T execute(final TwilioRestClient client);
54+
public abstract T create(final TwilioRestClient client);
5555
}

src/main/java/com/twilio/base/Deleter.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public abstract class Deleter<T extends Resource> {
1818
*
1919
* @return future that resolves to true if the object was deleted
2020
*/
21-
public ListenableFuture<Boolean> async() {
22-
return async(Twilio.getRestClient());
21+
public ListenableFuture<Boolean> deleteAsync() {
22+
return deleteAsync(Twilio.getRestClient());
2323
}
2424

2525
/**
@@ -28,10 +28,10 @@ public ListenableFuture<Boolean> async() {
2828
* @param client client used to make request
2929
* @return future that resolves to true if the object was deleted
3030
*/
31-
public ListenableFuture<Boolean> async(final TwilioRestClient client) {
31+
public ListenableFuture<Boolean> deleteAsync(final TwilioRestClient client) {
3232
return Twilio.getExecutorService().submit(new Callable<Boolean>() {
3333
public Boolean call() {
34-
return execute(client);
34+
return delete(client);
3535
}
3636
});
3737
}
@@ -41,8 +41,8 @@ public Boolean call() {
4141
*
4242
* @return true if the object was deleted
4343
*/
44-
public boolean execute() {
45-
return execute(Twilio.getRestClient());
44+
public boolean delete() {
45+
return delete(Twilio.getRestClient());
4646
}
4747

4848
/**
@@ -51,5 +51,5 @@ public boolean execute() {
5151
* @param client client used to make request
5252
* @return true if the object was deleted
5353
*/
54-
public abstract boolean execute(final TwilioRestClient client);
54+
public abstract boolean delete(final TwilioRestClient client);
5555
}

src/main/java/com/twilio/base/Fetcher.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public abstract class Fetcher<T extends Resource> {
1818
*
1919
* @return future that resolves to requested object
2020
*/
21-
public ListenableFuture<T> async() {
22-
return async(Twilio.getRestClient());
21+
public ListenableFuture<T> fetchAsync() {
22+
return fetchAsync(Twilio.getRestClient());
2323
}
2424

2525
/**
@@ -28,10 +28,10 @@ public ListenableFuture<T> async() {
2828
* @param client client used to make request
2929
* @return future that resolves to requested object
3030
*/
31-
public ListenableFuture<T> async(final TwilioRestClient client) {
31+
public ListenableFuture<T> fetchAsync(final TwilioRestClient client) {
3232
return Twilio.getExecutorService().submit(new Callable<T>() {
3333
public T call() {
34-
return execute(client);
34+
return fetch(client);
3535
}
3636
});
3737
}
@@ -41,8 +41,8 @@ public T call() {
4141
*
4242
* @return Requested object
4343
*/
44-
public T execute() {
45-
return execute(Twilio.getRestClient());
44+
public T fetch() {
45+
return fetch(Twilio.getRestClient());
4646
}
4747

4848
/**
@@ -51,5 +51,5 @@ public T execute() {
5151
* @param client client used to make request
5252
* @return Requested object
5353
*/
54-
public abstract T execute(final TwilioRestClient client);
54+
public abstract T fetch(final TwilioRestClient client);
5555
}

src/main/java/com/twilio/base/Reader.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public abstract class Reader<T extends Resource> {
2323
*
2424
* @return ResourceSet of objects
2525
*/
26-
public ResourceSet<T> execute() {
27-
return execute(Twilio.getRestClient());
26+
public ResourceSet<T> read() {
27+
return read(Twilio.getRestClient());
2828
}
2929

3030
/**
@@ -33,15 +33,15 @@ public ResourceSet<T> execute() {
3333
* @param client client used to make request
3434
* @return ResourceSet of objects
3535
*/
36-
public abstract ResourceSet<T> execute(final TwilioRestClient client);
36+
public abstract ResourceSet<T> read(final TwilioRestClient client);
3737

3838
/**
3939
* Execute an async request using default client.
4040
*
4141
* @return future that resolves to the ResourceSet of objects
4242
*/
43-
public ListenableFuture<ResourceSet<T>> async() {
44-
return async(Twilio.getRestClient());
43+
public ListenableFuture<ResourceSet<T>> readAsync() {
44+
return readAsync(Twilio.getRestClient());
4545
}
4646

4747
/**
@@ -50,10 +50,10 @@ public ListenableFuture<ResourceSet<T>> async() {
5050
* @param client client used to make request
5151
* @return future that resolves to the ResourceSet of objects
5252
*/
53-
public ListenableFuture<ResourceSet<T>> async(final TwilioRestClient client) {
53+
public ListenableFuture<ResourceSet<T>> readAsync(final TwilioRestClient client) {
5454
return Twilio.getExecutorService().submit(new Callable<ResourceSet<T>>() {
5555
public ResourceSet<T> call() {
56-
return execute(client);
56+
return read(client);
5757
}
5858
});
5959
}

src/main/java/com/twilio/base/Updater.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.google.common.util.concurrent.ListenableFuture;
44
import com.twilio.Twilio;
55
import com.twilio.http.TwilioRestClient;
6-
import com.twilio.base.Resource;
76

87
import java.util.concurrent.Callable;
98

@@ -19,8 +18,8 @@ public abstract class Updater<T extends Resource> {
1918
*
2019
* @return future that resolves to requested object
2120
*/
22-
public ListenableFuture<T> async() {
23-
return async(Twilio.getRestClient());
21+
public ListenableFuture<T> updateAsync() {
22+
return updateAsync(Twilio.getRestClient());
2423
}
2524

2625
/**
@@ -29,10 +28,10 @@ public ListenableFuture<T> async() {
2928
* @param client client used to make request
3029
* @return future that resolves to requested object
3130
*/
32-
public ListenableFuture<T> async(final TwilioRestClient client) {
31+
public ListenableFuture<T> updateAsync(final TwilioRestClient client) {
3332
return Twilio.getExecutorService().submit(new Callable<T>() {
3433
public T call() {
35-
return execute(client);
34+
return update(client);
3635
}
3736
});
3837
}
@@ -42,8 +41,8 @@ public T call() {
4241
*
4342
* @return Requested object
4443
*/
45-
public T execute() {
46-
return execute(Twilio.getRestClient());
44+
public T update() {
45+
return update(Twilio.getRestClient());
4746
}
4847

4948
/**
@@ -52,5 +51,5 @@ public T execute() {
5251
* @param client client used to make request
5352
* @return Requested object
5453
*/
55-
public abstract T execute(final TwilioRestClient client);
54+
public abstract T update(final TwilioRestClient client);
5655
}

src/main/java/com/twilio/example/Example.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static void main(String[] args) throws TwiMLException {
5252
PHONE_NUMBER,
5353
number.getPhoneNumber(),
5454
"Hello world!"
55-
).execute();
55+
).create();
5656

5757
System.out.println(message.getSid());
5858
System.out.println(message.getBody());
@@ -63,35 +63,35 @@ public static void main(String[] args) throws TwiMLException {
6363
PHONE_NUMBER,
6464
number.getPhoneNumber(),
6565
URI.create("https://twilio.com")
66-
).execute();
66+
).create();
6767
System.out.println(call.getSid());
6868

6969
// Print all the messages
70-
Iterable<Message> messages = new MessageReader().execute();
70+
Iterable<Message> messages = new MessageReader().read();
7171
for (Message m : messages) {
7272
System.out.println(m.getSid());
7373
System.out.println(m.getBody());
7474
}
7575

7676
// Get some calls
77-
Iterable<Call> calls = new CallReader().pageSize(2).execute();
77+
Iterable<Call> calls = new CallReader().pageSize(2).read();
7878
for (Call c : calls) {
7979
System.out.println(c.getSid());
8080
}
8181

8282
Trunk trunk = new TrunkCreator()
8383
.setFriendlyName("shiny trunk")
8484
.setSecure(false)
85-
.execute();
85+
.create();
8686

8787
System.out.println(trunk);
8888

8989
// Delete a resource
90-
Service service = Service.create().execute();
91-
boolean result = Service.delete(service.getSid()).execute();
90+
Service service = Service.creator().create();
91+
boolean result = Service.deleter(service.getSid()).delete();
9292
System.out.println(result);
9393

94-
Iterable<Service> services = Service.read().pageSize(2).execute();
94+
Iterable<Service> services = Service.reader().pageSize(2).read();
9595
int j = 0;
9696
for (Service s : services) {
9797
System.out.println("Service " + j + ": " + s.getSid());
@@ -108,7 +108,7 @@ public static void main(String[] args) throws TwiMLException {
108108

109109
private static IncomingPhoneNumber buyNumber() {
110110
// Look up some phone numbers
111-
Iterable<Local> numbers = new LocalReader(ACCOUNT_SID, "US").execute();
111+
Iterable<Local> numbers = new LocalReader(ACCOUNT_SID, "US").read();
112112

113113
// Buy the first phone number
114114
Iterator<Local> iter = numbers.iterator();
@@ -117,7 +117,7 @@ private static IncomingPhoneNumber buyNumber() {
117117
return new IncomingPhoneNumberCreator(
118118
ACCOUNT_SID,
119119
local.getPhoneNumber()
120-
).execute();
120+
).create();
121121
}
122122

123123
return null;

src/main/java/com/twilio/example/resource/CallCreatorExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ public static void main(final String[] args) {
2222
try {
2323

2424
CallCreator creator =
25-
Call.create(
25+
Call.creator(
2626
"AC123",
2727
new PhoneNumber("+14156085895"),
2828
new PhoneNumber("+14154888928"),
2929
new URI("http://twimlbin.com/4397e62f")
3030
);
3131

32-
Call call = creator.execute();
32+
Call call = creator.create();
3333

3434
System.out.println(call.getSid());
3535
System.out.println(call.getStatus().toString());

src/main/java/com/twilio/example/resource/CallDeleterExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public static void main(final String[] args) {
1717

1818
try {
1919

20-
CallDeleter deleter = Call.delete("AC123", "CA123");
21-
deleter.execute();
20+
CallDeleter deleter = Call.deleter("AC123", "CA123");
21+
deleter.delete();
2222

2323
} catch (ApiException e) {
2424

src/main/java/com/twilio/example/resource/CallFetcherExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public static void main(String[] args) {
1616

1717
try {
1818

19-
CallFetcher fetcher = Call.fetch("AC123", "CA123");
20-
Call call = fetcher.execute();
19+
CallFetcher fetcher = Call.fetcher("AC123", "CA123");
20+
Call call = fetcher.fetch();
2121

2222
System.out.print(call.getSid());
2323

src/main/java/com/twilio/example/resource/CallReaderExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public static void main(final String[] args) {
1717

1818
try {
1919

20-
CallReader reader = Call.read("AC123");
21-
ResourceSet<Call> calls = reader.execute();
20+
CallReader reader = Call.reader("AC123");
21+
ResourceSet<Call> calls = reader.read();
2222

2323
int idx = 1;
2424
for (Call call : calls) {

0 commit comments

Comments
 (0)