package net.zerobuilder.compiler;

import com.squareup.javapoet.AnnotationSpec;

import javax.annotation.Generated;
import javax.lang.model.util.Elements;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public final class Messages {

  public static final class ErrorMessages {

    private static final String POJO_HINT
        = " If this is not a POJO, try putting the @Goal annotation on a constructor instead.";

    public static final String PRIVATE_METHOD =
        "The goal method may not be private.";

    public static final String ABSTRACT_CONSTRUCTOR =
        "An abstract class may not have constructor goals." +
            " Try putting the @Goal annotation on a static \"factory\" method instead.";

    public static final String PRIVATE_TYPE =
        "The @Builders annotated class may not be private.";

    public static final String NESTING_KIND =
        "The @Builders annotation can only be used on top level and non-private static inner classes.";

    public static final String STEP_OUT_OF_BOUNDS =
        "Step position must be less than the number of arguments.";

    public static final String STEP_DUPLICATE =
        "Step position is specified twice.";

    public static final String DUPLICATE_GOAL_NAME =
        "There is another goal with this name. " +
            "Goal name conflicts can be resolved with the @Goal(name = ...) attribute.";

    public static final String BEAN_NO_DEFAULT_CONSTRUCTOR =
        "A non-private default constructor must exist." + POJO_HINT;

    public static final String BEAN_PRIVATE_CLASS =
        "This class may not be private." + POJO_HINT;

    public static final String BEAN_ABSTRACT_CLASS =
        "This class may not be abstract." + POJO_HINT;

    public static final String BEAN_COULD_NOT_FIND_SETTER =
        "Could not find a setter." + POJO_HINT;

    public static final String MISSING_PROJECTION =
        "Problem while generating an updater: Missing projection.";

    public static final String BEAN_IGNORE_AND_STEP =
        "@BeanIgnore and @Step don't make sense together." + POJO_HINT;

    public static final String STEP_ON_SETTER =
        "The @Step annotation goes on getters, not setters.";

    public static final String IGNORE_ON_SETTER =
        "The @BeanIgnore annotation goes on getters, not setters.";

    public static final String BEAN_SUBGOALS =
        "Bean goals may not have subgoals." + POJO_HINT;

    public static final String TYPE_PARAMS_BEAN =
        "Type parameters are not allowed in bean goals.";

    private ErrorMessages() {
      throw new UnsupportedOperationException("no instances");
    }
  }

  public static final class JavadocMessages {

    public static final String GENERATED_COMMENTS = "https://github.com/h908714124/zerobuilder";

    public static List<AnnotationSpec> generatedAnnotations(Elements elements) {
      if (elements.getTypeElement("javax.annotation.Generated") != null) {
        return Arrays.asList(AnnotationSpec.builder(Generated.class)
            .addMember("value", "$S", ZeroProcessor.class.getName())
            .addMember("comments", "$S", GENERATED_COMMENTS)
            .build());
      }
      return Collections.emptyList();

    }

    private JavadocMessages() {
      throw new UnsupportedOperationException("no instances");
    }
  }

  private Messages() {
    throw new UnsupportedOperationException("no instances");
  }
}

@@ -165,21 +165,26 @@
 va.util.
-Array
+Collection
 s;%0Aimpor
@@ -195,36 +195,30 @@
 va.util.
-Collections;
+List;%0A
 %0Aimport 
 java.uti
@@ -201,32 +201,39 @@
 l.List;%0A%0Aimport 
+static 
 java.util.List;%0A
@@ -222,24 +222,45 @@
 c java.util.
+Collections.singleton
 List;%0A%0Apubli
@@ -334,147 +334,8 @@
  %7B%0A%0A
-    private static final String POJO_HINT%0A        = %22 If this is not a POJO, try putting the @Goal annotation on a constructor instead.%22;%0A%0A
     
@@ -564,39 +564,13 @@
 Try 
-putting the @Goal annotation on
+using
  a s
@@ -579,19 +579,15 @@
 tic 
-%5C%22
 factory
-%5C%22
  met
@@ -665,28 +665,8 @@
 The 
-@Builders annotated 
 clas
@@ -753,48 +753,21 @@
 The 
-@Builders annotation can only be used on
+class must be
  top
@@ -773,19 +773,18 @@
 p level 
-and
+or
  non-pri
@@ -804,16 +804,8 @@
 nner
- classes
 .%22;%0A
@@ -1141,48 +1141,17 @@
    %22
-Goal name conflicts can be resolved with
+Try using
  the
@@ -1160,30 +1160,23 @@
 Goal
-(n
+N
 ame 
-= ...) attribute
+annotation
 .%22;%0A
@@ -1292,28 +1292,16 @@
  exist.%22
- + POJO_HINT
 ;%0A%0A    p
@@ -1387,28 +1387,16 @@
 rivate.%22
- + POJO_HINT
 ;%0A%0A    p
@@ -1484,28 +1484,16 @@
 stract.%22
- + POJO_HINT
 ;%0A%0A    p
@@ -1571,17 +1571,19 @@
 ot find 
-a
+the
  setter.
@@ -1579,36 +1579,24 @@
 the setter.%22
- + POJO_HINT
 ;%0A%0A    publi
@@ -1819,28 +1819,16 @@
 gether.%22
- + POJO_HINT
 ;%0A%0A    p
@@ -1884,16 +1884,20 @@
   %22The @
+Bean
 Step ann
@@ -2150,20 +2150,8 @@
 ls.%22
- + POJO_HINT
 ;%0A%0A 
@@ -2507,31 +2507,24 @@
 lder%22;%0A%0A    
-public 
 static List%3C
@@ -2675,17 +2675,17 @@
 urn 
-Arrays.as
+singleton
 List

change messages