Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface TestInterface extends Callable<Void>{
- void doSomething(Future<Object> future, String id);
- }
- class A{
- private Future<Object> future;
- private CustomInteraface a;
- public A(Future<Object> future, CustomInteraface a){
- //do init
- }
- //getters and setters
- }
- Class B implements TestInterface{
- private HashMap<String, A> map = new HashMap();
- private static B monitor = new B();
- public Void call(){
- HashMap.Entry<String, A> pair = (HashMap.Entry<String, A>) it.next();
- A a = (A) pair.getValue();
- Future<Object> future = a.getFuture();
- // Do something
- }
- public void doSomething(Future<Object> future, String id){
- if(map.contains(id)){
- //Do something
- }
- else{
- A a = new A(future, null);
- map.put();
- }
- }
- }
- interface TestInterface extends Callable<Void>{
- <T> void doSomething(Future<T> future, String id);
- }
- class A<T>{
- private Future<T> future;
- private CustomInteraface a;
- public A(Future<T> future, CustomInteraface a){
- //do init
- }
- //getters and setters
- }
- Class B implements TestInterface{
- private HashMap<String, A> map = new HashMap();
- private static B monitor = new B();
- public Void call(){
- HashMap.Entry<String, A> pair = (HashMap.Entry<String, A>) it.next();
- A a = (A) pair.getValue();
- //Code will definitely fail here as I'm trying to cast a future object of generic type to Object class
- Future<Object> future = a.getFuture();
- // Do something
- }
- public void doSomething(Future<T> future, String id){
- if(map.contains(id)){
- //Do something
- }
- else{
- A<T> a = new A<T>(future, null);
- map.put();
- }
- }
- }
Add Comment
Please, Sign In to add comment