001package sting.processor;
002
003import javax.annotation.Nonnull;
004
005/**
006 * Emits raw Java statements and exposes expressions for interceptor lifecycle metadata.
007 */
008public interface LifecycleCodeEmitter
009{
010  /**
011   * Return a Java expression for the fully qualified intercepted service type name.
012   *
013   * @return a Java expression for the fully qualified intercepted service type name.
014   */
015  @Nonnull
016  String serviceType();
017
018  /**
019   * Return a Java expression for the intercepted method name.
020   *
021   * @return a Java expression for the intercepted method name.
022   */
023  @Nonnull
024  String methodName();
025
026  /**
027   * Return a Java expression for the specified binding annotation member value.
028   *
029   * @param name the binding annotation member name.
030   * @return a Java expression for the specified binding annotation member value.
031   */
032  @Nonnull
033  String bindingValue( @Nonnull String name );
034
035  /**
036   * Return a Java expression for an intercepted method argument.
037   *
038   * @param index the zero-based argument index.
039   * @return a Java expression for an intercepted method argument.
040   */
041  @Nonnull
042  String argument( int index );
043
044  /**
045   * Return a Java expression for the shared {@code Object[]} argument metadata.
046   *
047   * @return a Java expression for the shared {@code Object[]} argument metadata.
048   */
049  @Nonnull
050  String argumentsArray();
051
052  /**
053   * Return a Java expression for the successful result value.
054   *
055   * @return a Java expression for the successful result value.
056   * @throws RuntimeException if called outside after-phase emission.
057   */
058  @Nonnull
059  String result();
060
061  /**
062   * Return a Java expression for the thrown failure.
063   *
064   * @return a Java expression for the thrown failure.
065   * @throws RuntimeException if called outside after-exception-phase emission.
066   */
067  @Nonnull
068  String thrown();
069
070  /**
071   * Emit a complete Java statement including any required semicolon.
072   *
073   * @param javaStatement the Java statement to emit.
074   */
075  void emitStatement( @Nonnull String javaStatement );
076}