// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight;

import com.intellij.psi.PsiAnnotation;
import org.jetbrains.annotations.NotNull;

/**
 * Represents a particular nullability annotation instance
 */
public class NullabilityAnnotationInfo {
  private final @NotNull PsiAnnotation myAnnotation;
  private final @NotNull Nullability myNullability;
  private final boolean myContainer;

  NullabilityAnnotationInfo(@NotNull PsiAnnotation annotation, @NotNull Nullability nullability, boolean container) {
    myAnnotation = annotation;
    myNullability = nullability;
    myContainer = container;
  }

  /**
   * @return annotation object (might be synthetic)
   */
  @NotNull
  public PsiAnnotation getAnnotation() {
    return myAnnotation;
  }

  /**
   * @return nullability this annotation represents
   */
  @NotNull
  public Nullability getNullability() {
    return myNullability;
  }

  /**
   * @return true if this annotation is a container annotation (applied to the whole class/package/etc.)
   */
  public boolean isContainer() {
    return myContainer;
  }

  /**
   * @return true if this annotation is an external annotation
   */
  public boolean isExternal() {
    return AnnotationUtil.isExternalAnnotation(myAnnotation);
  }

  /**
   * @return true if this annotation is an inferred annotation
   */
  public boolean isInferred() {
    return AnnotationUtil.isInferredAnnotation(myAnnotation);
  }
}

@@ -1535,11 +1535,237 @@
 on);%0A  %7D
+%0A%0A  @Override%0A  public String toString() %7B%0A    return %22NullabilityAnnotationInfo%7B%22 +%0A           myNullability + %22(%22 + myAnnotation.getQualifiedName() + %22)%22 +%0A           (myContainer ? %22, container=%22 : %22%22) +%0A           %22%7D%22;%0A  %7D
 %0A%7D%0A

define NullabilityAnnotationInfo.toString