package org.realityforge.arez.processor;

import java.lang.annotation.Annotation;
import javax.annotation.Nonnull;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.type.TypeKind;

final class MethodChecks
{
  private MethodChecks()
  {
  }

  public static void mustNotBeStatic( @Nonnull final Class<? extends Annotation> type,
                                      @Nonnull final ExecutableElement method )
    throws ArezProcessorException
  {
    if ( method.getModifiers().contains( Modifier.STATIC ) )
    {
      throw new ArezProcessorException( "@" + type.getSimpleName() + " target must not be static", method );
    }
  }

  public static void mustNotBeAbstract( @Nonnull final Class<? extends Annotation> type,
                                        @Nonnull final ExecutableElement method )
    throws ArezProcessorException
  {
    if ( method.getModifiers().contains( Modifier.ABSTRACT ) )
    {
      throw new ArezProcessorException( "@" + type.getSimpleName() + " target must not be abstract", method );
    }
  }

  public static void mustNotBePrivate( @Nonnull final Class<? extends Annotation> type,
                                       @Nonnull final ExecutableElement method )
    throws ArezProcessorException
  {
    if ( method.getModifiers().contains( Modifier.PRIVATE ) )
    {
      throw new ArezProcessorException( "@" + type.getSimpleName() + " target must not be private", method );
    }
  }

  public static void mustNotBeFinal( @Nonnull final Class<? extends Annotation> type,
                                     @Nonnull final ExecutableElement method )
    throws ArezProcessorException
  {
    if ( method.getModifiers().contains( Modifier.FINAL ) )
    {
      throw new ArezProcessorException( "@" + type.getSimpleName() + " target must not be final", method );
    }
  }

  public static void mustBeFinal( @Nonnull final Class<? extends Annotation> type,
                                     @Nonnull final ExecutableElement method )
    throws ArezProcessorException
  {
    if ( !method.getModifiers().contains( Modifier.FINAL ) )
    {
      throw new ArezProcessorException( "@" + type.getSimpleName() + " target must be final", method );
    }
  }

  public static void mustNotHaveAnyParameters( @Nonnull final Class<? extends Annotation> type,
                                               @Nonnull final ExecutableElement method )
    throws ArezProcessorException
  {
    if ( !method.getParameters().isEmpty() )
    {
      throw new ArezProcessorException( "@" + type.getSimpleName() + " target must not have any parameters", method );
    }
  }

  public static void mustNotReturnAnyValue( @Nonnull final Class<? extends Annotation> type,
                                            @Nonnull final ExecutableElement method )
    throws ArezProcessorException
  {
    if ( TypeKind.VOID != method.getReturnType().getKind() )
    {
      throw new ArezProcessorException( "@" + type.getSimpleName() + " target must not return a value", method );
    }
  }

  public static void mustReturnAValue( @Nonnull final Class<? extends Annotation> type,
                                       @Nonnull final ExecutableElement method )
    throws ArezProcessorException
  {
    if ( TypeKind.VOID == method.getReturnType().getKind() )
    {
      throw new ArezProcessorException( "@" + type.getSimpleName() + " target must return a value", method );
    }
  }

  public static void mustNotThrowAnyExceptions( @Nonnull final Class<? extends Annotation> type,
                                                @Nonnull final ExecutableElement method )
    throws ArezProcessorException
  {
    if ( !method.getThrownTypes().isEmpty() )
    {
      throw new ArezProcessorException( "@" + type.getSimpleName() + " target must not throw any exceptions", method );
    }
  }
}

@@ -296,39 +296,32 @@
 ks()%0A  %7B%0A  %7D%0A%0A  
-public 
 static void must
@@ -374,39 +374,32 @@
 notation%3E type,%0A
-       
                 
@@ -674,39 +674,32 @@
 );%0A    %7D%0A  %7D%0A%0A  
-public 
 static void must
@@ -754,39 +754,32 @@
 notation%3E type,%0A
-       
                 
@@ -1060,39 +1060,32 @@
 );%0A    %7D%0A  %7D%0A%0A  
-public 
 static void must
@@ -1139,39 +1139,32 @@
 notation%3E type,%0A
-       
                 
@@ -1442,39 +1442,32 @@
 );%0A    %7D%0A  %7D%0A%0A  
-public 
 static void must
@@ -1530,45 +1530,8 @@
 ype,
-%0A                                    
  @No
@@ -1786,39 +1786,32 @@
 );%0A    %7D%0A  %7D%0A%0A  
-public 
 static void must
@@ -1871,45 +1871,8 @@
 ype,
-%0A                                    
  @No
@@ -2124,39 +2124,32 @@
 );%0A    %7D%0A  %7D%0A%0A  
-public 
 static void must
@@ -2211,39 +2211,32 @@
 notation%3E type,%0A
-       
                 
@@ -2514,39 +2514,32 @@
 );%0A    %7D%0A  %7D%0A%0A  
-public 
 static void must
@@ -2598,39 +2598,32 @@
 notation%3E type,%0A
-       
                 
@@ -2909,39 +2909,32 @@
 );%0A    %7D%0A  %7D%0A%0A  
-public 
 static void must
@@ -2988,39 +2988,32 @@
 notation%3E type,%0A
-       
                 
@@ -3302,15 +3302,8 @@
 %0A%0A  
-public 
 stat
@@ -3378,39 +3378,32 @@
 notation%3E type,%0A
-       
                 

Remove public qualifiers