001: package com.bm.ejb3metadata.annotations.metadata;
002:
003: import com.bm.ejb3metadata.annotations.JField;
004:
005: /**
006: * This class represents the annotation metadata of a field.
007: *
008: * @author Daniel Wiese
009: */
010: public class FieldAnnotationMetadata extends CommonAnnotationMetadata {
011:
012: /**
013: * Method on which we got metadata.
014: */
015: private JField jField = null;
016:
017: /**
018: * Parent metadata.
019: */
020: private ClassAnnotationMetadata classAnnotationMetadata = null;
021:
022: /**
023: * This field is a field from a super class ?<br>
024: */
025: private boolean inherited = false;
026:
027: /**
028: * Constructor.
029: *
030: * @param jField
031: * the field on which we will set/add metadata
032: * @param classAnnotationMetadata
033: * the parent metadata.
034: */
035: public FieldAnnotationMetadata(final JField jField,
036: final ClassAnnotationMetadata classAnnotationMetadata) {
037: this .jField = jField;
038: this .classAnnotationMetadata = classAnnotationMetadata;
039: }
040:
041: /**
042: * @return name of the field
043: */
044: public String getFieldName() {
045: return this .jField.getName();
046: }
047:
048: /**
049: * @return JMethod object
050: */
051: public JField getJField() {
052: return this .jField;
053: }
054:
055: /**
056: * @return string representation
057: */
058: @Override
059: public String toString() {
060: StringBuilder sb = new StringBuilder();
061: String titleIndent = " ";
062: String indent = " ";
063: // classname
064: sb.append(titleIndent);
065: sb.append(this .getClass().getName().substring(
066: this .getClass().getPackage().getName().length() + 1));
067: sb.append("[\n");
068:
069: // Add super class toString()
070: sb.append(super .toString());
071:
072: // Field
073: sb.append(indent);
074: sb.append("jField=");
075: sb.append(jField);
076: sb.append("\n");
077:
078: // inherited
079: if (inherited) {
080: sb.append(indent);
081: sb.append("inherited=");
082: sb.append(inherited);
083: sb.append("\n");
084: }
085:
086: sb.append(titleIndent);
087: sb.append("]\n");
088: return sb.toString();
089: }
090:
091: /**
092: * @return true if this method is inherited from a super class
093: */
094: public boolean isInherited() {
095: return inherited;
096: }
097:
098: /**
099: * Sets the inheritance of this method.
100: *
101: * @param inherited
102: * true if method is from a super class
103: */
104: public void setInherited(final boolean inherited) {
105: this .inherited = inherited;
106: }
107:
108: /**
109: * @return parent metadata (class)
110: */
111: public ClassAnnotationMetadata getClassAnnotationMetadata() {
112: return classAnnotationMetadata;
113: }
114:
115: }
|