1 19 20 21 package org.apache.cayenne.jpa.map; 22 23 import javax.persistence.Column; 24 25 public class JpaColumn { 26 27 protected String name; 28 protected boolean unique; 29 protected boolean nullable; 30 protected boolean insertable; 31 protected boolean updatable; 32 protected String columnDefinition; 33 protected String table; 34 protected int length; 35 protected int precision; 36 protected int scale; 37 38 public JpaColumn() { 39 40 } 41 42 public JpaColumn(Column annotation) { 43 if (!"".equals(annotation.name())) { 44 name = annotation.name(); 45 } 46 47 unique = annotation.unique(); 48 nullable = annotation.nullable(); 49 insertable = annotation.insertable(); 50 updatable = annotation.updatable(); 51 52 if (!"".equals(annotation.columnDefinition())) { 53 columnDefinition = annotation.columnDefinition(); 54 } 55 56 if (!"".equals(annotation.table())) { 57 table = annotation.table(); 58 } 59 60 length = annotation.length(); 61 precision = annotation.precision(); 62 scale = annotation.scale(); 63 } 64 65 public String getColumnDefinition() { 66 return columnDefinition; 67 } 68 69 public void setColumnDefinition(String columnDefinition) { 70 this.columnDefinition = columnDefinition; 71 } 72 73 public boolean isInsertable() { 74 return insertable; 75 } 76 77 public void setInsertable(boolean insertable) { 78 this.insertable = insertable; 79 } 80 81 public int getLength() { 82 return length; 83 } 84 85 public void setLength(int length) { 86 this.length = length; 87 } 88 89 public String getName() { 90 return name; 91 } 92 93 public void setName(String name) { 94 this.name = name; 95 } 96 97 public boolean isNullable() { 98 return nullable; 99 } 100 101 public void setNullable(boolean nullable) { 102 this.nullable = nullable; 103 } 104 105 public int getPrecision() { 106 return precision; 107 } 108 109 public void setPrecision(int precision) { 110 this.precision = precision; 111 } 112 113 public int getScale() { 114 return scale; 115 } 116 117 public void setScale(int scale) { 118 this.scale = scale; 119 } 120 121 public String getTable() { 122 return table; 123 } 124 125 public void setTable(String table) { 126 this.table = table; 127 } 128 129 public boolean isUnique() { 130 return unique; 131 } 132 133 public void setUnique(boolean unique) { 134 this.unique = unique; 135 } 136 137 public boolean isUpdatable() { 138 return updatable; 139 } 140 141 public void setUpdatable(boolean updateable) { 142 this.updatable = updateable; 143 } 144 145 @Override 146 public String toString() { 147 String className = getClass().getName(); 148 return className.substring(className.lastIndexOf('.') + 1) + ":" + name; 149 } 150 } 151 | Popular Tags |