00001 /* 00002 * AnnotatedElement.hpp 00003 * 00004 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. 00005 * 00006 * Oracle is a registered trademarks of Oracle Corporation and/or its 00007 * affiliates. 00008 * 00009 * This software is the confidential and proprietary information of Oracle 00010 * Corporation. You shall not disclose such confidential and proprietary 00011 * information and shall use it only in accordance with the terms of the 00012 * license agreement you entered into with Oracle. 00013 * 00014 * This notice may not be removed or altered. 00015 */ 00016 #ifndef COH_ANNOTATED_ELEMENT_HPP 00017 #define COH_ANNOTATED_ELEMENT_HPP 00018 00019 #include "coherence/lang/compatibility.hpp" 00020 00021 #include "coherence/lang/abstract_spec.hpp" 00022 #include "coherence/lang/Annotation.hpp" 00023 #include "coherence/lang/FinalHandle.hpp" 00024 #include "coherence/lang/ObjectArray.hpp" 00025 00026 00027 00028 COH_OPEN_NAMESPACE2(coherence,lang) 00029 00030 // ----- forward declarations ----------------------------------------------- 00031 00032 class Class; 00033 00034 /** 00035 * AnnotatedElement represents an annotated element. 00036 * 00037 * @author mf 2011.03.01 00038 * 00039 * @since Coherence 3.7.1 00040 */ 00041 class COH_EXPORT AnnotatedElement 00042 : public abstract_spec<AnnotatedElement> 00043 { 00044 // ----- constructors --------------------------------------------------- 00045 00046 protected: 00047 /** 00048 * Construct an AnnotatedElement. 00049 */ 00050 AnnotatedElement(); 00051 00052 00053 // ----- AnnotatedElement interface ------------------------------------- 00054 00055 public: 00056 /** 00057 * Returns this element's annotation for the specified type if such an 00058 * annotation is present, else NULL. 00059 * 00060 * @param vClassAnnotation the annotation type 00061 * 00062 * @return the Annotation or NULL if not present 00063 */ 00064 virtual Annotation::View getAnnotation(TypedHandle<const Class> vClassAnnotation) const; 00065 00066 /** 00067 * Returns all annotations present on this element. 00068 * 00069 * @return all annotations present on this element 00070 */ 00071 virtual ObjectArray::View getAnnotations() const; 00072 00073 /** 00074 * Returns all annotations directly present on this element. 00075 * 00076 * @return all annotations present on this element 00077 */ 00078 virtual ObjectArray::View getDeclaredAnnotations() const; 00079 00080 /** 00081 * Return true the specified annotation is present on this element. 00082 * 00083 * @return true the specified annotation is present on this element. 00084 */ 00085 virtual bool isAnnotationPresent(TypedHandle<const Class> vClassAnnotation) const; 00086 00087 /** 00088 * Add the specified Annotation to this element. 00089 * 00090 * @param vAnnotation the annotation 00091 */ 00092 virtual AnnotatedElement::Handle addAnnotation(Annotation::View vAnnotation); 00093 00094 /** 00095 * Return the parent of this AnnotationElement or NULL if there is none. 00096 * 00097 * The default implementation always returns NULL. 00098 * 00099 * @return the parent of this AnnotationElement or NULL if there is none 00100 */ 00101 virtual AnnotatedElement::View getSuperelement() const; 00102 00103 00104 // ----- data members --------------------------------------------------- 00105 00106 protected: 00107 /** 00108 * The map of resolved annotations, key'd by annotation type Class 00109 */ 00110 mutable FinalHandle<Object> f_hMapAnnotations; 00111 00112 /** 00113 * The list of declared annotations. 00114 */ 00115 FinalHandle<Object> f_hListAnnotationsDeclared; 00116 }; 00117 00118 COH_CLOSE_NAMESPACE2 00119 00120 #endif // COH_ANNOTATED_ELEMENT_HPP