BAEL-6611 add example code for completablefuture vs future vs rxjava comparison
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package com.baeldung.concurrent.futurevscompletablefuturevsrxjava;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class ObjectCallable implements Callable<TestObject> {
|
||||
@Override
|
||||
public TestObject call() throws Exception {
|
||||
return new TestObject();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.baeldung.concurrent.futurevscompletablefuturevsrxjava;
|
||||
|
||||
public class ObjectHydrator {
|
||||
|
||||
public TestObject hydrateTestObject(TestObject testObject){
|
||||
testObject.setDataPointTwo(20);
|
||||
return testObject;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.concurrent.futurevscompletablefuturevsrxjava;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ObjectSupplier implements Supplier<TestObject> {
|
||||
|
||||
@Override
|
||||
public TestObject get() {
|
||||
return new TestObject();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.baeldung.concurrent.futurevscompletablefuturevsrxjava;
|
||||
|
||||
public class TestObject {
|
||||
|
||||
private int dataPointOne;
|
||||
private int dataPointTwo;
|
||||
|
||||
public TestObject() {
|
||||
dataPointOne = 10;
|
||||
}
|
||||
|
||||
public int getDataPointOne() {
|
||||
return dataPointOne;
|
||||
}
|
||||
|
||||
public void setDataPointOne(int dataPointOne) {
|
||||
this.dataPointOne = dataPointOne;
|
||||
}
|
||||
|
||||
public int getDataPointTwo() {
|
||||
return dataPointTwo;
|
||||
}
|
||||
|
||||
public void setDataPointTwo(int dataPointTwo) {
|
||||
this.dataPointTwo = dataPointTwo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TestObject{" + "dataPointOne=" + dataPointOne + ", dataPointTwo=" + dataPointTwo + '}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user