package org.realityforge.arez.processor;

import javax.annotation.Nonnull;
import javax.lang.model.element.Element;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import org.realityforge.arez.annotations.Container;

final class ContainerDescriptorParser
{
  private ContainerDescriptorParser()
  {
  }

  static ContainerDescriptor parse( @Nonnull final Element element,
                                    @Nonnull final Elements elementUtils,
                                    @Nonnull final Types typeUtils )
    throws ArezProcessorException
  {
    final PackageElement packageElement = elementUtils.getPackageOf( element );
    final TypeElement typeElement = (TypeElement) element;
    if ( !element.getKind().isClass() )
    {
      throw new ArezProcessorException( "@" + Container.class.getSimpleName() + " target must be a class", element );
    }
    else if ( element.getModifiers().contains( Modifier.ABSTRACT ) )
    {
      throw new ArezProcessorException( "@" + Container.class.getSimpleName() + " target must not be abstract",
                                        element );
    }
    else if ( element.getModifiers().contains( Modifier.FINAL ) )
    {
      throw new ArezProcessorException( "@" + Container.class.getSimpleName() + " target must not be final", element );
    }
    final Container container = typeElement.getAnnotation( Container.class );
    final String name =
      container.name().equals( "<default>" ) ? typeElement.getSimpleName().toString() : container.name();

    return new ContainerDescriptor( name, container.singleton(), packageElement, typeElement );
  }
}

@@ -927,36 +927,32 @@
 sorException( %22@
-%22 + 
 Container.class.
@@ -948,34 +948,8 @@
 iner
-.class.getSimpleName() + %22
  tar
@@ -1096,36 +1096,32 @@
 sorException( %22@
-%22 + 
 Container.class.
@@ -1117,34 +1117,8 @@
 iner
-.class.getSimpleName() + %22
  tar
@@ -1147,48 +1147,8 @@
 ct%22,
-%0A                                       
  ele
@@ -1279,12 +1279,8 @@
 ( %22@
-%22 + 
 Cont
@@ -1288,34 +1288,8 @@
 iner
-.class.getSimpleName() + %22
  tar

Simplify exception messages