Class PropertyElement
- java.lang.Object
-
- com.webcohesion.enunciate.javac.decorations.element.DecoratedElement<ExecutableElement>
-
- com.webcohesion.enunciate.javac.decorations.element.DecoratedExecutableElement
-
- com.webcohesion.enunciate.javac.decorations.element.PropertyElement
-
- All Implemented Interfaces:
AnnotatedConstruct,Element,ExecutableElement,Parameterizable
public class PropertyElement extends DecoratedExecutableElement
A property, representing the getter/setter pair. In all cases, the description of the property matches the description of the getter, but the annotations are the union of the getter and the setter, with the intersection preferring the getter.- Author:
- Ryan Heaton
-
-
Field Summary
-
Fields inherited from class com.webcohesion.enunciate.javac.decorations.element.DecoratedElement
delegate, env
-
-
Constructor Summary
Constructors Constructor Description PropertyElement(DecoratedExecutableElement getter, DecoratedExecutableElement setter, DecoratedProcessingEnvironment env)A property declaration.PropertyElement(DecoratedExecutableElement getter, DecoratedExecutableElement setter, PropertySpec spec, DecoratedProcessingEnvironment env)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R,P>
Raccept(ElementVisitor<R,P> v, P p)TypeMirrorasType()<A extends Annotation>
AgetAnnotation(Class<A> annotationType)Gets the annotation on the getter.List<AnnotationMirror>getAnnotationMirrors()Gets the collection of annotations on the setter and the getter.Map<String,AnnotationMirror>getAnnotations()Gets the annotations on the setter and the getter.DecoratedExecutableElementgetGetter()The getter.StringgetPropertyName()Make sure the property name is calculated correctly.TypeMirrorgetPropertyType()The type of this property.TypeMirrorgetReturnType()DecoratedExecutableElementgetSetter()The setter, or null if this property is a read-only property.NamegetSimpleName()The simple name of the property is the property name.booleanisGetter()booleanisReadOnly()Whether this property is read-only.booleanisSetter()booleanisVarArgs()booleanisWriteOnly()Whether this property is write-only.-
Methods inherited from class com.webcohesion.enunciate.javac.decorations.element.DecoratedExecutableElement
createParamDocComment, getDefaultValue, getParameters, getReceiverType, getThrownTypes, getTypeParameters, isDefault
-
Methods inherited from class com.webcohesion.enunciate.javac.decorations.element.DecoratedElement
equals, getAnnotationsByType, getDelegate, getDocComment, getDocValue, getDocValue, getEnclosedElements, getEnclosingElement, getJavaDoc, getJavaDoc, getJavaDoc, getKind, getModifiers, getSimpleNameString, isAbstract, isFinal, isNative, isPrivate, isProtected, isPublic, isStatic, isStrictfp, isSynchronized, isTransient, isVolatile, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javax.lang.model.AnnotatedConstruct
getAnnotationsByType
-
Methods inherited from interface javax.lang.model.element.Element
equals, getEnclosedElements, getEnclosingElement, getKind, getModifiers, hashCode
-
-
-
-
Constructor Detail
-
PropertyElement
public PropertyElement(DecoratedExecutableElement getter, DecoratedExecutableElement setter, DecoratedProcessingEnvironment env)
A property declaration.- Parameters:
getter- The getter.setter- The setter.- Throws:
IllegalStateException- If the getter and setter don't pair up.
-
PropertyElement
public PropertyElement(DecoratedExecutableElement getter, DecoratedExecutableElement setter, PropertySpec spec, DecoratedProcessingEnvironment env)
-
-
Method Detail
-
asType
public TypeMirror asType()
- Specified by:
asTypein interfaceElement- Overrides:
asTypein classDecoratedElement<ExecutableElement>
-
getPropertyType
public TypeMirror getPropertyType()
The type of this property.- Returns:
- The type of this property.
-
getSimpleName
public Name getSimpleName()
The simple name of the property is the property name.- Specified by:
getSimpleNamein interfaceElement- Specified by:
getSimpleNamein interfaceExecutableElement- Overrides:
getSimpleNamein classDecoratedElement<ExecutableElement>- Returns:
- The simple name of the property is the property name.
-
getPropertyName
public String getPropertyName()
Make sure the property name is calculated correctly.- Overrides:
getPropertyNamein classDecoratedExecutableElement
-
getSetter
public DecoratedExecutableElement getSetter()
The setter, or null if this property is a read-only property.- Returns:
- The setter.
-
getGetter
public DecoratedExecutableElement getGetter()
The getter.- Returns:
- The getter.
-
isReadOnly
public boolean isReadOnly()
Whether this property is read-only.- Returns:
- Whether this property is read-only.
-
isWriteOnly
public boolean isWriteOnly()
Whether this property is write-only.- Returns:
- Whether this property is write-only.
-
getAnnotations
public Map<String,AnnotationMirror> getAnnotations()
Gets the annotations on the setter and the getter. If the annotation is on both the setter and the getter, only the one on the getter will be included.- Overrides:
getAnnotationsin classDecoratedElement<ExecutableElement>- Returns:
- The union of the annotations on the getter and setter.
-
getAnnotationMirrors
public List<AnnotationMirror> getAnnotationMirrors()
Gets the collection of annotations on the setter and the getter. If the annotation is on both the setter and the getter, only the one on the getter will be included.- Specified by:
getAnnotationMirrorsin interfaceAnnotatedConstruct- Specified by:
getAnnotationMirrorsin interfaceElement- Overrides:
getAnnotationMirrorsin classDecoratedElement<ExecutableElement>- Returns:
- The union of the annotations on the getter and setter.
-
getAnnotation
public <A extends Annotation> A getAnnotation(Class<A> annotationType)
Gets the annotation on the getter. If it doesn't exist, returns the one on the setter.- Specified by:
getAnnotationin interfaceAnnotatedConstruct- Specified by:
getAnnotationin interfaceElement- Overrides:
getAnnotationin classDecoratedElement<ExecutableElement>- Parameters:
annotationType- The annotation type.- Returns:
- The annotation.
-
getReturnType
public TypeMirror getReturnType()
- Specified by:
getReturnTypein interfaceExecutableElement- Overrides:
getReturnTypein classDecoratedExecutableElement
-
isGetter
public boolean isGetter()
- Overrides:
isGetterin classDecoratedExecutableElement
-
isSetter
public boolean isSetter()
- Overrides:
isSetterin classDecoratedExecutableElement
-
isVarArgs
public boolean isVarArgs()
- Specified by:
isVarArgsin interfaceExecutableElement- Overrides:
isVarArgsin classDecoratedExecutableElement
-
accept
public <R,P> R accept(ElementVisitor<R,P> v, P p)
- Specified by:
acceptin interfaceElement- Overrides:
acceptin classDecoratedExecutableElement
-
-