ServiceDeclaration.java

  1. package net.morimekta.providence.reflect.model;

  2. import net.morimekta.providence.reflect.parser.ThriftToken;

  3. import javax.annotation.Nonnull;
  4. import javax.annotation.Nullable;
  5. import java.util.List;

  6. /**
  7.  * <pre>{@code
  8.  * service ::= 'service' {name} ('extends' {extending})? '{' {function}* '}' {annotations}?
  9.  * }</pre>
  10.  */
  11. public class ServiceDeclaration extends Declaration {
  12.     private final ThriftToken             serviceToken;
  13.     private final ThriftToken             extending;
  14.     private final List<MethodDeclaration> methods;

  15.     public ServiceDeclaration(@Nullable String documentation,
  16.                               @Nonnull ThriftToken serviceToken,
  17.                               @Nonnull ThriftToken name,
  18.                               @Nullable ThriftToken extending,
  19.                               @Nonnull List<MethodDeclaration> methods,
  20.                               @Nullable List<AnnotationDeclaration> annotations) {
  21.         super(documentation, name, annotations);
  22.         this.serviceToken = serviceToken;
  23.         this.extending = extending;
  24.         this.methods = methods;
  25.     }

  26.     @Nonnull
  27.     public ThriftToken getServiceToken() {
  28.         return serviceToken;
  29.     }

  30.     @Nullable
  31.     public String getExtending() {
  32.         if (extending != null) {
  33.             return extending.toString();
  34.         }
  35.         return null;
  36.     }

  37.     @Nullable
  38.     public ThriftToken getExtendingToken() {
  39.         return extending;
  40.     }

  41.     @Nonnull
  42.     public List<MethodDeclaration> getMethods() {
  43.         return methods;
  44.     }
  45. }