Skip to content

Commit

Permalink
Performed renaming of "Observable" to "Flowable"
Browse files Browse the repository at this point in the history
  • Loading branch information
snazha-blkio committed Oct 23, 2018
1 parent 9e38172 commit 5904769
Show file tree
Hide file tree
Showing 28 changed files with 272 additions and 282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -837,20 +837,20 @@ TypeSpec buildEventResponseObject(
return builder.build();
}

MethodSpec buildEventObservableFunction(
MethodSpec buildEventFlowableFunction(
String responseClassName,
String functionName,
List<org.web3j.codegen.SolidityFunctionWrapper.NamedTypeName> indexedParameters,
List<org.web3j.codegen.SolidityFunctionWrapper.NamedTypeName> nonIndexedParameters)
throws ClassNotFoundException {

String generatedFunctionName =
Strings.lowercaseFirstLetter(functionName) + "EventObservable";
Strings.lowercaseFirstLetter(functionName) + "EventFlowable";
ParameterizedTypeName parameterizedTypeName =
ParameterizedTypeName.get(ClassName.get(Flowable.class),
ClassName.get("", responseClassName));

MethodSpec.Builder observableMethodBuilder =
MethodSpec.Builder flowableMethodBuilder =
MethodSpec.methodBuilder(generatedFunctionName)
.addModifiers(Modifier.PUBLIC)
.addParameter(EthFilter.class, FILTER)
Expand All @@ -877,37 +877,37 @@ MethodSpec buildEventObservableFunction(
.build())
.build();

observableMethodBuilder
.addStatement("return web3j.ethLogObservable(filter).map($L)", converter);
flowableMethodBuilder
.addStatement("return web3j.ethLogFlowable(filter).map($L)", converter);

return observableMethodBuilder
return flowableMethodBuilder
.build();
}

MethodSpec buildDefaultEventObservableFunction(
MethodSpec buildDefaultEventFlowableFunction(
String responseClassName,
String functionName) {

String generatedFunctionName =
Strings.lowercaseFirstLetter(functionName) + "EventObservable";
Strings.lowercaseFirstLetter(functionName) + "EventFlowable";
ParameterizedTypeName parameterizedTypeName =
ParameterizedTypeName.get(ClassName.get(Flowable.class),
ClassName.get("", responseClassName));

MethodSpec.Builder observableMethodBuilder =
MethodSpec.Builder flowableMethodBuilder =
MethodSpec.methodBuilder(generatedFunctionName)
.addModifiers(Modifier.PUBLIC)
.addParameter(DefaultBlockParameter.class, START_BLOCK)
.addParameter(DefaultBlockParameter.class, END_BLOCK)
.returns(parameterizedTypeName);

observableMethodBuilder.addStatement("$1T filter = new $1T($2L, $3L, "
flowableMethodBuilder.addStatement("$1T filter = new $1T($2L, $3L, "
+ "getContractAddress())", EthFilter.class, START_BLOCK, END_BLOCK)
.addStatement("filter.addSingleTopic($T.encode("
+ buildEventDefinitionName(functionName) + "))", EventEncoder.class)
.addStatement("return " + generatedFunctionName + "(filter)");

return observableMethodBuilder
return flowableMethodBuilder
.build();
}

Expand Down Expand Up @@ -983,9 +983,9 @@ List<MethodSpec> buildEventFunctions(
methods.add(buildEventTransactionReceiptFunction(responseClassName,
functionName, indexedParameters, nonIndexedParameters));

methods.add(buildEventObservableFunction(responseClassName, functionName,
methods.add(buildEventFlowableFunction(responseClassName, functionName,
indexedParameters, nonIndexedParameters));
methods.add(buildDefaultEventObservableFunction(responseClassName,
methods.add(buildDefaultEventFlowableFunction(responseClassName,
functionName));
return methods;
}
Expand All @@ -994,7 +994,7 @@ CodeBlock buildTypedResponse(
String objectName,
List<org.web3j.codegen.SolidityFunctionWrapper.NamedTypeName> indexedParameters,
List<org.web3j.codegen.SolidityFunctionWrapper.NamedTypeName> nonIndexedParameters,
boolean observable) {
boolean flowable) {
String nativeConversion;

if (useNativeJavaTypes) {
Expand All @@ -1004,7 +1004,7 @@ CodeBlock buildTypedResponse(
}

CodeBlock.Builder builder = CodeBlock.builder();
if (observable) {
if (flowable) {
builder.addStatement("$L.log = log", objectName);
} else {
builder.addStatement(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ public void testBuildEventConstantMultipleValueReturn() throws Exception {
+ " return responses;\n"
+ " }\n"
+ "\n"
+ " public io.reactivex.Flowable<TransferEventResponse> transferEventObservable(org.web3j.protocol.core.methods.request.EthFilter filter) {\n"
+ " return web3j.ethLogObservable(filter).map(new io.reactivex.functions.Function<org.web3j.protocol.core.methods.response.Log, TransferEventResponse>() {\n"
+ " public io.reactivex.Flowable<TransferEventResponse> transferEventFlowable(org.web3j.protocol.core.methods.request.EthFilter filter) {\n"
+ " return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<org.web3j.protocol.core.methods.response.Log, TransferEventResponse>() {\n"
+ " @java.lang.Override\n"
+ " public TransferEventResponse apply(org.web3j.protocol.core.methods.response.Log log) {\n"
+ " org.web3j.tx.Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(TRANSFER_EVENT, log);\n"
Expand All @@ -407,10 +407,10 @@ public void testBuildEventConstantMultipleValueReturn() throws Exception {
+ " });\n"
+ " }\n"
+ "\n"
+ " public io.reactivex.Flowable<TransferEventResponse> transferEventObservable(org.web3j.protocol.core.DefaultBlockParameter startBlock, org.web3j.protocol.core.DefaultBlockParameter endBlock) {\n"
+ " public io.reactivex.Flowable<TransferEventResponse> transferEventFlowable(org.web3j.protocol.core.DefaultBlockParameter startBlock, org.web3j.protocol.core.DefaultBlockParameter endBlock) {\n"
+ " org.web3j.protocol.core.methods.request.EthFilter filter = new org.web3j.protocol.core.methods.request.EthFilter(startBlock, endBlock, getContractAddress());\n"
+ " filter.addSingleTopic(org.web3j.abi.EventEncoder.encode(TRANSFER_EVENT));\n"
+ " return transferEventObservable(filter);\n"
+ " return transferEventFlowable(filter);\n"
+ " }\n"
+ "\n"
+ " public static class TransferEventResponse {\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface ERC20BasicInterface<T> {

List<T> getTransferEvents(TransactionReceipt transactionReceipt);

Flowable<T> transferEventObservable(DefaultBlockParameter startBlock,
Flowable<T> transferEventFlowable(DefaultBlockParameter startBlock,
DefaultBlockParameter endBlock);

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface ERC20Interface<R, T> extends ERC20BasicInterface<T> {

List<R> getApprovalEvents(TransactionReceipt transactionReceipt);

Flowable<R> approvalEventObservable(DefaultBlockParameter startBlock,
Flowable<R> approvalEventFlowable(DefaultBlockParameter startBlock,
DefaultBlockParameter endBlock);

}
16 changes: 8 additions & 8 deletions core/src/main/java/org/web3j/ens/contracts/generated/ENS.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ public List<NewOwnerEventResponse> getNewOwnerEvents(TransactionReceipt transact
return responses;
}

public Flowable<NewOwnerEventResponse> newOwnerEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
public Flowable<NewOwnerEventResponse> newOwnerEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("NewOwner",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Bytes32>(true) {},
new TypeReference<Address>() {}));
EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
filter.addSingleTopic(EventEncoder.encode(event));
return web3j.ethLogObservable(filter).map(log -> {
return web3j.ethLogFlowable(filter).map(log -> {
EventValues eventValues = extractEventParameters(event, log);
NewOwnerEventResponse typedResponse = new NewOwnerEventResponse();
typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
Expand All @@ -94,13 +94,13 @@ public List<TransferEventResponse> getTransferEvents(TransactionReceipt transact
return responses;
}

public Flowable<TransferEventResponse> transferEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
public Flowable<TransferEventResponse> transferEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("Transfer",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {},
new TypeReference<Address>() {}));
EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
filter.addSingleTopic(EventEncoder.encode(event));
return web3j.ethLogObservable(filter).map(log -> {
return web3j.ethLogFlowable(filter).map(log -> {
EventValues eventValues = extractEventParameters(event, log);
TransferEventResponse typedResponse = new TransferEventResponse();
typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
Expand All @@ -124,13 +124,13 @@ public List<NewResolverEventResponse> getNewResolverEvents(TransactionReceipt tr
return responses;
}

public Flowable<NewResolverEventResponse> newResolverEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
public Flowable<NewResolverEventResponse> newResolverEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("NewResolver",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {},
new TypeReference<Address>() {}));
EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
filter.addSingleTopic(EventEncoder.encode(event));
return web3j.ethLogObservable(filter).map(log -> {
return web3j.ethLogFlowable(filter).map(log -> {
EventValues eventValues = extractEventParameters(event, log);
NewResolverEventResponse typedResponse = new NewResolverEventResponse();
typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
Expand All @@ -154,13 +154,13 @@ public List<NewTTLEventResponse> getNewTTLEvents(TransactionReceipt transactionR
return responses;
}

public Flowable<NewTTLEventResponse> newTTLEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
public Flowable<NewTTLEventResponse> newTTLEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("NewTTL",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {},
new TypeReference<Uint64>() {}));
EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
filter.addSingleTopic(EventEncoder.encode(event));
return web3j.ethLogObservable(filter).map(log -> {
return web3j.ethLogFlowable(filter).map(log -> {
EventValues eventValues = extractEventParameters(event, log);
NewTTLEventResponse typedResponse = new NewTTLEventResponse();
typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public List<AddrChangedEventResponse> getAddrChangedEvents(TransactionReceipt tr
return responses;
}

public Flowable<AddrChangedEventResponse> addrChangedEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
public Flowable<AddrChangedEventResponse> addrChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("AddrChanged",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Address>() {}));
EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
filter.addSingleTopic(EventEncoder.encode(event));
return web3j.ethLogObservable(filter).map(log -> {
return web3j.ethLogFlowable(filter).map(log -> {
EventValues eventValues = extractEventParameters(event, log);
AddrChangedEventResponse typedResponse = new AddrChangedEventResponse();
typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
Expand All @@ -94,12 +94,12 @@ public List<ContentChangedEventResponse> getContentChangedEvents(TransactionRece
return responses;
}

public Flowable<ContentChangedEventResponse> contentChangedEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
public Flowable<ContentChangedEventResponse> contentChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("ContentChanged",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Bytes32>() {}));
EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
filter.addSingleTopic(EventEncoder.encode(event));
return web3j.ethLogObservable(filter).map(log -> {
return web3j.ethLogFlowable(filter).map(log -> {
EventValues eventValues = extractEventParameters(event, log);
ContentChangedEventResponse typedResponse = new ContentChangedEventResponse();
typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
Expand All @@ -122,12 +122,12 @@ public List<NameChangedEventResponse> getNameChangedEvents(TransactionReceipt tr
return responses;
}

public Flowable<NameChangedEventResponse> nameChangedEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
public Flowable<NameChangedEventResponse> nameChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("NameChanged",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Utf8String>() {}));
EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
filter.addSingleTopic(EventEncoder.encode(event));
return web3j.ethLogObservable(filter).map(log -> {
return web3j.ethLogFlowable(filter).map(log -> {
EventValues eventValues = extractEventParameters(event, log);
NameChangedEventResponse typedResponse = new NameChangedEventResponse();
typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
Expand All @@ -150,12 +150,12 @@ public List<ABIChangedEventResponse> getABIChangedEvents(TransactionReceipt tran
return responses;
}

public Flowable<ABIChangedEventResponse> aBIChangedEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
public Flowable<ABIChangedEventResponse> aBIChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("ABIChanged",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Uint256>(true) {}));
EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
filter.addSingleTopic(EventEncoder.encode(event));
return web3j.ethLogObservable(filter).map(log -> {
return web3j.ethLogFlowable(filter).map(log -> {
EventValues eventValues = extractEventParameters(event, log);
ABIChangedEventResponse typedResponse = new ABIChangedEventResponse();
typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
Expand All @@ -179,12 +179,12 @@ public List<PubkeyChangedEventResponse> getPubkeyChangedEvents(TransactionReceip
return responses;
}

public Flowable<PubkeyChangedEventResponse> pubkeyChangedEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
public Flowable<PubkeyChangedEventResponse> pubkeyChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("PubkeyChanged",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Bytes32>() {}, new TypeReference<Bytes32>() {}));
EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
filter.addSingleTopic(EventEncoder.encode(event));
return web3j.ethLogObservable(filter).map(log -> {
return web3j.ethLogFlowable(filter).map(log -> {
EventValues eventValues = extractEventParameters(event, log);
PubkeyChangedEventResponse typedResponse = new PubkeyChangedEventResponse();
typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
Expand All @@ -209,12 +209,12 @@ public List<TextChangedEventResponse> getTextChangedEvents(TransactionReceipt tr
return responses;
}

public Flowable<TextChangedEventResponse> textChangedEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
public Flowable<TextChangedEventResponse> textChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final Event event = new Event("TextChanged",
Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>(true) {}, new TypeReference<Utf8String>(true) {}, new TypeReference<Utf8String>() {}));
EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
filter.addSingleTopic(EventEncoder.encode(event));
return web3j.ethLogObservable(filter).map(log -> {
return web3j.ethLogFlowable(filter).map(log -> {
EventValues eventValues = extractEventParameters(event, log);
TextChangedEventResponse typedResponse = new TextChangedEventResponse();
typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/org/web3j/protocol/Web3jService.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ <T extends Response> CompletableFuture<T> sendAsync(
* the unsubscribe method. Different WebSocket implementations use different pair of
* subscribe/unsubscribe methods.
*
* <p>This method creates an Observable that can be used to subscribe to new notifications.
* When a client unsubscribes from this Observable the service unsubscribes from
* <p>This method creates an Flowable that can be used to subscribe to new notifications.
* When a client unsubscribes from this Flowable the service unsubscribes from
* the underlying stream of events.
*
* @param request JSON-RPC request that will be send to subscribe to a stream of
Expand All @@ -54,7 +54,7 @@ <T extends Response> CompletableFuture<T> sendAsync(
* stream of notifications
* @param responseType class of incoming events objects in a stream
* @param <T> type of incoming event objects
* @return a @{@link Flowable} instance that emits incoming events
* @return a {@link Flowable} instance that emits incoming events
*/
<T extends Notification<?>> Flowable<T> subscribe(
Request request,
Expand Down
Loading

0 comments on commit 5904769

Please sign in to comment.