org.jclouds.rest.functions
Interface ImplicitOptionalConverter

All Superinterfaces:
com.google.common.base.Function<InvocationSuccess,com.google.common.base.Optional<Object>>
All Known Implementing Classes:
AlwaysPresentImplicitOptionalConverter, PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersion

@Beta
public interface ImplicitOptionalConverter
extends com.google.common.base.Function<InvocationSuccess,com.google.common.base.Optional<Object>>

When a client marked @Delegate is optional, the implementation of this is responsible for creating the optional object. For example.

 interface MyCloud {
    @Delegate
    Optional<KeyPairClient> getKeyPairExtensionForRegion(String region);
 }
 
The input object of type InvocationSuccess will include the following.
  1. the class declaring the method that returns optional: InvocationSuccess#getClazz; in the example above, MyCloud
  2. the method returning the optional: InvocationSuccess#getMethod; in the example above, getKeyPairExtensionForRegion
  3. the args passed to that method at runtime: InvocationSuccess#getArgs; for example North
  4. the rest client to be enclosed in the optional, should you choose to return it: InvocationSuccess#getReturnVal; in the example above, an implementation of KeyPairClient
Using this context, your implementation of ImplicitOptionalConverter can perform whatever you need, when deciding if the the returnVal is present and available. Here are some ideas: The default implementation returns present if no SinceApiVersion annotation is assigned, or the value is less than or equal to the current ApiVersion. To override this, add the following in your subclass override of RestClientModule.configure() method:
 bind(ImplicitOptionalConverter.class).to(MyCustomOptionalConverter.class);
 

Author:
Adrian Cole

Method Summary
 
Methods inherited from interface com.google.common.base.Function
apply, equals
 



Copyright © 2009-2013 jclouds. All Rights Reserved.