1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.hadoop.hbase.hbql.mapping;
22
23 import org.apache.expreval.expr.TypeSupport;
24 import org.apache.hadoop.hbase.hbql.client.ColumnVersionMap;
25 import org.apache.hadoop.hbase.hbql.client.HBqlException;
26
27 import java.lang.reflect.Field;
28 import java.lang.reflect.ParameterizedType;
29 import java.lang.reflect.Type;
30 import java.util.Map;
31
32 public class VersionAnnotationAttrib extends FieldAttrib {
33
34 public VersionAnnotationAttrib(final String familyName,
35 final String columnName,
36 final Field field,
37 final FieldType fieldType,
38 final String getter,
39 final String setter) throws HBqlException {
40 super(familyName, columnName, field, fieldType, getter, setter);
41
42 final ColumnVersionMap versionAnno = field.getAnnotation(ColumnVersionMap.class);
43
44 final String annoname = "@ColumnVersionMap annotation";
45
46
47 if (!TypeSupport.isParentClass(Map.class, field.getType()))
48 throw new HBqlException(getObjectQualifiedName(field) + "has a " + annoname + " so it "
49 + "must implement the Map interface");
50
51
52 final ParameterizedType ptype = (ParameterizedType)field.getGenericType();
53 final Type[] typeargs = ptype.getActualTypeArguments();
54 final Type mapValueType = typeargs[1];
55
56
57
58 this.defineAccessors();
59 }
60
61 public boolean isACurrentValue() {
62 return false;
63 }
64
65 public boolean isAVersionValue() {
66 return true;
67 }
68 }