1 package com.bm.introspectors;
2
3 import java.lang.annotation.Annotation;
4
5 import javax.persistence.Embeddable;
6
7 import org.slf4j.Logger;
8
9
10
11
12
13
14
15
16
17
18
19 public class EmbeddedClassIntrospector<T> extends AbstractPersistentClassIntrospector<T>
20 implements Introspector<T> {
21
22 private static final org.slf4j.Logger log = org.slf4j.LoggerFactory
23 .getLogger(EmbeddedClassIntrospector.class);
24
25
26 private final Class<T> embeddedClassName;
27
28
29 private final Property attibuteName;
30
31
32
33
34
35
36
37 @SuppressWarnings("unchecked")
38 public EmbeddedClassIntrospector(Property toInspect) {
39 this.embeddedClassName = toInspect.getType();
40 this.attibuteName = toInspect;
41
42 Annotation[] classAnnotations = this.embeddedClassName.getAnnotations();
43 boolean isEbeddeable = false;
44
45
46 for (Annotation a : classAnnotations) {
47 if (a instanceof Embeddable) {
48
49 isEbeddeable = true;
50 }
51 }
52
53
54 if (!isEbeddeable) {
55 log.error("The class " + this.embeddedClassName.getSimpleName()
56 + " is not a ebededable class");
57 throw new RuntimeException("The class "
58 + this.embeddedClassName.getSimpleName()
59 + " is not a ebededable class");
60 }
61
62
63 this.processAccessTypeField(this.embeddedClassName);
64 }
65
66
67
68
69
70
71 public Class getEmbeddedClassName() {
72 return embeddedClassName;
73 }
74
75
76
77
78
79
80 public Property getAttibuteName() {
81 return attibuteName;
82 }
83
84
85
86
87
88 protected Logger getLogger() {
89 return log;
90 }
91 }