本文整理汇总了Java中com.datastax.driver.mapping.annotations.Column类的典型用法代码示例。如果您正苦于以下问题:Java Column类的具体用法?Java Column怎么用?Java Column使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Column类属于com.datastax.driver.mapping.annotations包,在下文中一共展示了Column类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColumnName
import com.datastax.driver.mapping.annotations.Column; //导入依赖的package包/类
private static <F extends AnnotatedElement & Member> String getColumnName(F element) {
if (element.isAnnotationPresent(Column.class)) {
String name = element.getAnnotation(Column.class).name();
if (!name.isEmpty()) return name;
}
if (element instanceof Method) {
if (element.getName().startsWith("get")) {
return element.getName().substring(3);
}
if (element.getName().startsWith("is")) {
return element.getName().substring(2);
}
}
if (element instanceof Field) {
return element.getName();
}
return null;
}
示例2: getNameOfField
import com.datastax.driver.mapping.annotations.Column; //导入依赖的package包/类
private static String getNameOfField(Field f) {
Column nameAnnotation = f.getAnnotation(Column.class);
String fieldName = null;
if (nameAnnotation != null) {
fieldName = nameAnnotation.name();
} else {
fieldName = f.getName();
}
return fieldName;
}
示例3: getColumnAnnotation
import com.datastax.driver.mapping.annotations.Column; //导入依赖的package包/类
/**
* Get the Column annotation for a table field.
* @param field the field name to put the annotation on
* @return the annotation
*/
public static AnnotationSpec getColumnAnnotation(String field) {
AnnotationSpec.Builder builder = AnnotationSpec.builder(Column.class);
if(MetaData.isSnakeCase(field)) {
builder.addMember("value", "name = $S", field);
}
return builder.build();
}
示例4: createStructure
import com.datastax.driver.mapping.annotations.Column; //导入依赖的package包/类
private String createStructure(StructureType structureType, Class<?> c) throws Exception {
String schemaName = extractSchemaName(c);
if (schemaName == null) {
throw new Exception("No table name defined for type / table: " + c.getName());
}
Field[] fields = c.getFields();
String structureName = structureType.name();
StringBuilder stringBuilder = new StringBuilder("CREATE " + structureName + " ");
stringBuilder.append(schemaName);
stringBuilder.append(" (\n");
int i = 0;
for (Field f : fields) {
// Prepare the field name
Column nameAnnotation = f.getAnnotation(Column.class);
String fieldName = getNameOfField(f);
// Append field name
stringBuilder.append("\t").append(fieldName);
// Append Field Type
String fieldType = mapJavaToCassandraType(fieldName, f.getType());
stringBuilder.append(" ").append(fieldType);
// Append comma for next line if not last field
if (i != fields.length - 1 || structureType.equals(StructureType.TABLE)) {
stringBuilder.append(",\n");
}
i++;
}
// Append Primary Key description
if (structureType.equals(StructureType.TABLE)) {
stringBuilder.append("\t").append(generatePrimaryKey(c));
}
// Close create statement
stringBuilder.append("\n);");
return stringBuilder.toString();
}
示例5: getDay
import com.datastax.driver.mapping.annotations.Column; //导入依赖的package包/类
@Column public Date getDay() {
return day;
}
示例6: getParent
import com.datastax.driver.mapping.annotations.Column; //导入依赖的package包/类
@Column public String getParent() {
return parent;
}
示例7: getChild
import com.datastax.driver.mapping.annotations.Column; //导入依赖的package包/类
@Column public String getChild() {
return child;
}
示例8: getCalls
import com.datastax.driver.mapping.annotations.Column; //导入依赖的package包/类
@Column public long getCalls() {
return calls;
}
示例9: getErrors
import com.datastax.driver.mapping.annotations.Column; //导入依赖的package包/类
@Column public long getErrors() {
return errors;
}