Class OkNamedMirror

  • All Implemented Interfaces:
    java.lang.annotation.Annotation

    public class OkNamedMirror
    extends java.lang.Object
    implements OkJsonMirrors.OkNamed
    OkNamedMirror used to parse data of AnnotationMirror for original annotation com.squareup.moshi.Json during annotation processing. Interface is being described using OkJsonMirrors.OkNamed annotation, which should be structurally compatible to the annotation being modelled.
    See Also:
    find(Iterable), from(AnnotationMirror)
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private OkNamedMirror​(javax.lang.model.element.AnnotationMirror annotationMirror)  
      private OkNamedMirror​(javax.lang.model.element.TypeElement defaultAnnotationElement)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Class<? extends java.lang.annotation.Annotation> annotationType()  
      boolean equals​(java.lang.Object other)  
      static com.google.common.base.Optional<OkNamedMirror> find​(java.lang.Iterable<? extends javax.lang.model.element.AnnotationMirror> mirrors)
      Finds first annotation of this type in an iterable of annotation mirrors.
      static com.google.common.base.Optional<OkNamedMirror> find​(javax.lang.model.element.Element element)
      Finds first annotation of this type on the element.
      static com.google.common.base.Optional<OkNamedMirror> from​(javax.lang.model.element.AnnotationMirror mirror)
      Tries to convert annotation mirror to this annotation type.
      static OkNamedMirror from​(javax.lang.model.element.TypeElement element)
      Creates mirror with default values using annotation element (i.e.
      static com.google.common.collect.ImmutableList<OkNamedMirror> fromAll​(java.lang.Iterable<? extends javax.lang.model.element.AnnotationMirror> mirrors)
      Converts iterable of annotation mirrors where all annotation are of this type.
      javax.lang.model.element.AnnotationMirror getAnnotationMirror()  
      int hashCode()  
      static boolean isPresent​(javax.lang.model.element.Element annotatedElement)  
      static java.lang.String mirrorQualifiedName()  
      java.lang.String name()  
      static java.lang.String qualifiedName()  
      static java.lang.String simpleName()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • MIRROR_QUALIFIED_NAME

        public static final java.lang.String MIRROR_QUALIFIED_NAME
        See Also:
        Constant Field Values
      • annotationMirror

        private final javax.lang.model.element.AnnotationMirror annotationMirror
      • name

        private final java.lang.String name
    • Constructor Detail

      • OkNamedMirror

        private OkNamedMirror​(javax.lang.model.element.TypeElement defaultAnnotationElement)
      • OkNamedMirror

        private OkNamedMirror​(javax.lang.model.element.AnnotationMirror annotationMirror)
    • Method Detail

      • mirrorQualifiedName

        public static java.lang.String mirrorQualifiedName()
      • qualifiedName

        public static java.lang.String qualifiedName()
      • simpleName

        public static java.lang.String simpleName()
      • isPresent

        public static boolean isPresent​(javax.lang.model.element.Element annotatedElement)
      • find

        public static com.google.common.base.Optional<OkNamedMirror> find​(javax.lang.model.element.Element element)
        Finds first annotation of this type on the element.
        Parameters:
        element - annotated element
        Returns:
        optional OkNamedMirror, present if this annotation found
      • find

        public static com.google.common.base.Optional<OkNamedMirror> find​(java.lang.Iterable<? extends javax.lang.model.element.AnnotationMirror> mirrors)
        Finds first annotation of this type in an iterable of annotation mirrors.
        Parameters:
        mirrors - annotation mirrors
        Returns:
        optional OkNamedMirror, present if this annotation found
      • fromAll

        public static com.google.common.collect.ImmutableList<OkNamedMirror> fromAll​(java.lang.Iterable<? extends javax.lang.model.element.AnnotationMirror> mirrors)
        Converts iterable of annotation mirrors where all annotation are of this type. Otherwise it fails
        Parameters:
        mirrors - of this annotation type.
        Returns:
        list of converted OkNamedMirrors
      • from

        public static OkNamedMirror from​(javax.lang.model.element.TypeElement element)
        Creates mirror with default values using annotation element (i.e. declaration, not usage).
        Parameters:
        element - annotation type element
        Returns:
        OkNamedMirror
      • from

        public static com.google.common.base.Optional<OkNamedMirror> from​(javax.lang.model.element.AnnotationMirror mirror)
        Tries to convert annotation mirror to this annotation type.
        Parameters:
        mirror - annotation mirror
        Returns:
        optional OkNamedMirror, present if mirror matched this annotation type
      • name

        public java.lang.String name()
        Returns:
        value of attribute name
      • getAnnotationMirror

        public javax.lang.model.element.AnnotationMirror getAnnotationMirror()
        Returns:
        underlying annotation mirror
      • annotationType

        public java.lang.Class<? extends java.lang.annotation.Annotation> annotationType()
        Specified by:
        annotationType in interface java.lang.annotation.Annotation
        Returns:
        OkNamed.class
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.lang.annotation.Annotation
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Specified by:
        equals in interface java.lang.annotation.Annotation
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Specified by:
        toString in interface java.lang.annotation.Annotation
        Overrides:
        toString in class java.lang.Object