Annotation Interface Composable


@Target(TYPE) @Retention(SOURCE) public @interface Composable
Generate an abstract class for compositions.

The resulting class is abstract. Its constructor takes an instance of the same type and each method is final and delegates to the same method of the delegate.

Example

 @Composable
  public interface FooBar<T>
  {
      void foo(T foo);

      T bar(String bazz) throws IOException;
  }
 

will generate this code


 public abstract class FooBarComposition<T> implements FooBar<T> {
     private final FooBar<T> mDelegate;

     public FooBarComposition(FooBar<T> delegate) {
         mDelegate = delegate;
     }

     public final void foo(T foo) {
         mDelegate.foo(foo);
     }

     public final T bar(String bazz) throws IOException {
         return mDelegate.bar(bazz);
     }
 }
 
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The name of the generated class.
    The package name of the generated class.
  • Element Details

    • packageName

      String packageName
      The package name of the generated class.

      Defaults to the package name of the annotated interface.

      Default:
      ""
    • className

      String className
      The name of the generated class.

      Defaults to the name of the annotated interface plus the word "Composition".

      Default:
      ""