KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > jpa > conf > AnnotationPrototypes


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20
21 package org.apache.cayenne.jpa.conf;
22
23 import javax.persistence.Column;
24 import javax.persistence.JoinColumn;
25 import javax.persistence.Table;
26
27 import org.apache.cayenne.jpa.JpaProviderException;
28
29 /**
30  * A utility class that provides access to default JPA annotation instances.
31  *
32  * @author Andrus Adamchik
33  */

34 @Table
35 abstract class AnnotationPrototypes {
36
37     static final Column column;
38     static final JoinColumn joinColumn;
39     static final Table table;
40
41     static {
42
43         table = AnnotationPrototypes.class.getAnnotation(Table.class);
44
45         try {
46             column = AnnotationPrototypes.class
47                     .getDeclaredField("annotatedColumn")
48                     .getAnnotation(Column.class);
49
50             joinColumn = AnnotationPrototypes.class.getDeclaredField(
51                     "annotatedJoinColumn").getAnnotation(JoinColumn.class);
52         }
53         catch (NoSuchFieldException JavaDoc e) {
54             throw new JpaProviderException("No annotated field found", e);
55         }
56     }
57
58     @Column
59     Object JavaDoc annotatedColumn;
60
61     @JoinColumn
62     Object JavaDoc annotatedJoinColumn;
63
64     public static Column getColumn() {
65         return column;
66     }
67
68     public static JoinColumn getJoinColumn() {
69         return joinColumn;
70     }
71
72     public static Table getTable() {
73         return table;
74     }
75 }
76
Popular Tags