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.hadoop.hbase.hbql.client.HBqlException;
24
25 import java.lang.reflect.Field;
26 import java.lang.reflect.Modifier;
27
28 public class CurrentValueAnnotationAttrib extends FieldAttrib {
29
30 final ColumnAttrib columnAttrib;
31
32 public CurrentValueAnnotationAttrib(final Field field, final ColumnAttrib columnAttrib) throws HBqlException {
33
34 super(columnAttrib.getFamilyName(),
35 columnAttrib.getColumnName(),
36 field,
37 columnAttrib.getFieldType(),
38 columnAttrib.getGetter(),
39 columnAttrib.getSetter());
40
41 this.columnAttrib = columnAttrib;
42
43 this.defineAccessors();
44
45 if (isFinal(this.getField()))
46 throw new HBqlException(this + "." + this.getField().getName() + " cannot have a @Column "
47 + "annotation and be marked final");
48
49
50
51 }
52
53 private ColumnAttrib getColumnAttrib() {
54 return columnAttrib;
55 }
56
57 public boolean isAKeyAttrib() {
58 return this.getColumnAttrib().isAKeyAttrib();
59 }
60
61 private static boolean isFinal(final Field field) {
62 return Modifier.isFinal(field.getModifiers());
63 }
64
65 public Object getDefaultValue() throws HBqlException {
66 return this.getColumnAttrib().getDefaultValue();
67 }
68
69 public boolean hasDefaultArg() throws HBqlException {
70 return this.getDefaultValue() != null;
71 }
72 }