当前位置: 首页>>代码示例>>Java>>正文


Java Column类代码示例

本文整理汇总了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; 
}
 
开发者ID:papyrusglobal,项目名称:state-channels,代码行数:19,代码来源:CassandraUtil.java

示例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;
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-server,代码行数:13,代码来源:CassandraSchemaGenerator.java

示例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();
}
 
开发者ID:jtruelove,项目名称:exovert,代码行数:13,代码来源:EntityGeneratorHelper.java

示例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();
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-server,代码行数:47,代码来源:CassandraSchemaGenerator.java

示例5: getDay

import com.datastax.driver.mapping.annotations.Column; //导入依赖的package包/类
@Column public Date getDay() {
  return day;
}
 
开发者ID:openzipkin,项目名称:zipkin-dependencies,代码行数:4,代码来源:CassandraDependenciesJob.java

示例6: getParent

import com.datastax.driver.mapping.annotations.Column; //导入依赖的package包/类
@Column public String getParent() {
  return parent;
}
 
开发者ID:openzipkin,项目名称:zipkin-dependencies,代码行数:4,代码来源:CassandraDependenciesJob.java

示例7: getChild

import com.datastax.driver.mapping.annotations.Column; //导入依赖的package包/类
@Column public String getChild() {
  return child;
}
 
开发者ID:openzipkin,项目名称:zipkin-dependencies,代码行数:4,代码来源:CassandraDependenciesJob.java

示例8: getCalls

import com.datastax.driver.mapping.annotations.Column; //导入依赖的package包/类
@Column public long getCalls() {
  return calls;
}
 
开发者ID:openzipkin,项目名称:zipkin-dependencies,代码行数:4,代码来源:CassandraDependenciesJob.java

示例9: getErrors

import com.datastax.driver.mapping.annotations.Column; //导入依赖的package包/类
@Column public long getErrors() {
  return errors;
}
 
开发者ID:openzipkin,项目名称:zipkin-dependencies,代码行数:4,代码来源:CassandraDependenciesJob.java


注:本文中的com.datastax.driver.mapping.annotations.Column类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。