• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Column类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.gfx.android.orma.annotation.Column的典型用法代码示例。如果您正苦于以下问题:Java Column类的具体用法?Java Column怎么用?Java Column使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Column类属于com.github.gfx.android.orma.annotation包,在下文中一共展示了Column类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildOrderByHelpers

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
void buildOrderByHelpers(List<MethodSpec> methodSpecs, ColumnDefinition column) {
    if (column.hasHelper(Column.Helpers.ORDER_IN_ASC)) {
        methodSpecs.add(MethodSpec.methodBuilder("orderBy" + Strings.toUpperFirst(column.name) + "Asc")
                .addModifiers(Modifier.PUBLIC)
                .returns(getTargetClassName())
                .addStatement("return orderBy(schema.$L.orderInAscending())", column.name)
                .build());
    }
    if (column.hasHelper(Column.Helpers.ORDER_IN_DESC)) {
        methodSpecs.add(MethodSpec.methodBuilder("orderBy" + Strings.toUpperFirst(column.name) + "Desc")
                .addModifiers(Modifier.PUBLIC)
                .returns(getTargetClassName())
                .addStatement("return orderBy(schema.$L.orderInDescending())", column.name)
                .build()
        );
    }
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:18,代码来源:ConditionQueryHelpers.java


示例2: foreignKeyAction

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
void foreignKeyAction(StringBuilder sb, String clause, Column.ForeignKeyAction action) {
    switch (action) {
        case NO_ACTION:
            // this is the SQLite default (see https://www.sqlite.org/foreignkeys.html)
            break;
        case RESTRICT:
            sb.append(clause);
            sb.append("RESTRICT");
            break;
        case SET_NULL:
            sb.append(clause);
            sb.append("SET NULL");
            break;
        case SET_DEFAULT:
            sb.append(clause);
            sb.append("SET DEFAULT");
            break;
        case CASCADE:
            sb.append(clause);
            sb.append("CASCADE");
            break;
        default:
            throw new AssertionError("not reached");
    }
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:26,代码来源:SqlGenerator.java


示例3: ColumnDefinition

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
private ColumnDefinition(SchemaDefinition schema) {
    this.schema = schema;
    context = schema.context;
    element = null;
    name = kDefaultPrimaryKeyName;
    columnName = kDefaultPrimaryKeyName;
    type = TypeName.LONG;
    nullable = false;
    explicitNonNull = false;
    primaryKey = true;
    primaryKeyOnConflict = OnConflict.NONE;
    autoincrement = false;
    autoId = true;
    indexed = false;
    unique = false;
    uniqueOnConflict = OnConflict.NONE;
    defaultExpr = "";
    collate = Column.Collate.BINARY;
    onDeleteAction = Column.ForeignKeyAction.NO_ACTION;
    onUpdateAction = Column.ForeignKeyAction.NO_ACTION;
    helperFlags = normalizeHelperFlags(primaryKey, indexed, autoincrement, autoId, Column.Helpers.AUTO);
    typeAdapter = schema.context.getTypeAdapter(type);
    storageType = null;
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:25,代码来源:ColumnDefinition.java


示例4: columnName

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
static String columnName(Column column, Element element) {
    if (column != null && !column.value().equals("")) {
        return column.value();
    } else {
        for (AnnotationMirror annotation : element.getAnnotationMirrors()) {
            Name annotationName = annotation.getAnnotationType().asElement().getSimpleName();
            if (annotationName.contentEquals("SerializedName") // GSON
                    || annotationName.contentEquals("JsonProperty") // Jackson
                    ) {
                for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotation
                        .getElementValues().entrySet()) {
                    if (entry.getKey().getSimpleName().contentEquals("value")) {
                        return entry.getValue().getValue().toString();
                    }
                }
            }
        }
    }
    return element.getSimpleName().toString();
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:21,代码来源:ColumnDefinition.java


示例5: normalizeHelperFlags

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
@Column.Helpers
static long normalizeHelperFlags(boolean primaryKey, boolean indexed, boolean autoincrement, boolean autoId, long flags) {
    if (flags == Column.Helpers.AUTO) {
        if (primaryKey) {
            return (autoincrement || !autoId)
                    ? Column.Helpers.CONDITIONS | Column.Helpers.ORDERS
                    : Column.Helpers.CONDITIONS;
        } else if (indexed) {
            return Column.Helpers.CONDITIONS | Column.Helpers.ORDERS | Column.Helpers.AGGREGATORS;
        } else {
            return Column.Helpers.AGGREGATORS;
        }
    } else {
        return flags;
    }
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:17,代码来源:ColumnDefinition.java


示例6: buildConditionHelpersForCompositeIndex

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
void buildConditionHelpersForCompositeIndex(List<MethodSpec> methodSpecs, IndexDefinition index) {
    // create only "==" helper
    if (!index.hasHelper(Column.Helpers.CONDITION_EQ)) {
        return;
    }

    CharSequence baseName = buildBaseNameForCompositeIndex(index);

    CodeBlock.Builder conditions = CodeBlock.builder();
    List<ParameterSpec> paramSpecs = new ArrayList<>();

    for (int i = 0; i < index.columns.size(); i++) {
        ColumnDefinition column = index.columns.get(i);

        ParameterSpec paramSpec = buildParameterSpec(column);
        CodeBlock serializedFieldExpr = serializedFieldExpr(column, paramSpec);
        if (i != 0) {
            conditions.add(".");
        }
        conditions.add("where(schema.$L, $S, $L)",
                column.columnName, "=", serializedFieldExpr);
        paramSpecs.add(paramSpec);
    }

    MethodSpec.Builder methodSpec = MethodSpec.methodBuilder(baseName + "Eq")
            .addModifiers(Modifier.PUBLIC)
            .addParameters(paramSpecs)
            .addStatement("return $L", conditions.build())
            .returns(targetClassName);
    methodSpecs.add(methodSpec.build());
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:32,代码来源:ConditionQueryHelpers.java


示例7: extractIndexes

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
Stream<IndexDefinition> extractIndexes() {
    return columns.stream()
            .filter(column -> column.indexed && !column.primaryKey)
            .map(column -> new IndexDefinition(
                    context.sqlg.buildIndexName(tableName, column.columnName),
                    false,
                    Column.Helpers.AUTO,
                    column
            ));
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:11,代码来源:SchemaDefinition.java


示例8: buildAggregationHelpers

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
void buildAggregationHelpers(List<MethodSpec> methodSpecs, ColumnDefinition column) {
    if (column.hasHelper(Column.Helpers.MIN) && Types.isNumeric(column.type)) {
        methodSpecs.add(MethodSpec.methodBuilder("minBy" + Strings.toUpperFirst(column.name))
                .addAnnotation(Annotations.nullable())
                .addModifiers(Modifier.PUBLIC)
                .returns(column.getBoxType())
                .addCode(buildAggregatorBody(column, "MIN",
                        () -> CodeBlock.of("schema.$L.getFromCursor(conn, cursor, 0)", column.name)))
                .build()
        );
    }
    if (column.hasHelper(Column.Helpers.MAX) && Types.isNumeric(column.type)) {
        methodSpecs.add(MethodSpec.methodBuilder("maxBy" + Strings.toUpperFirst(column.name))
                .addAnnotation(Annotations.nullable())
                .addModifiers(Modifier.PUBLIC)
                .returns(column.getBoxType())
                .addCode(buildAggregatorBody(column, "MAX",
                        () -> CodeBlock.of("schema.$L.getFromCursor(conn, cursor, 0)", column.name)))
                .build()
        );
    }
    if (column.hasHelper(Column.Helpers.SUM) && Types.isNumeric(column.type)) {
        boolean isInteger = Types.looksLikeIntegerType(column.type);
        methodSpecs.add(MethodSpec.methodBuilder("sumBy" + Strings.toUpperFirst(column.name))
                .addAnnotation(Annotations.nullable())
                .addModifiers(Modifier.PUBLIC)
                .returns(isInteger ? TypeName.LONG.box() : TypeName.DOUBLE.box())
                .addCode(buildAggregatorBody(column, "SUM",
                        () -> isInteger ? CodeBlock.of("cursor.getLong(0)") : CodeBlock.of("cursor.getDouble(0)")))
                .build()
        );
    }
    if (column.hasHelper(Column.Helpers.AVG) && Types.isNumeric(column.type)) {
        methodSpecs.add(MethodSpec.methodBuilder("avgBy" + Strings.toUpperFirst(column.name))
                .addAnnotation(Annotations.nullable())
                .addModifiers(Modifier.PUBLIC)
                .returns(TypeName.DOUBLE.box())
                .addCode(buildAggregatorBody(column, "AVG", () -> CodeBlock.of("cursor.getDouble(0)")))
                .build()
        );
    }
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:43,代码来源:ConditionQueryHelpers.java


示例9: buildUpsert

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
private CodeBlock buildUpsert(String modelExpr) {
    CodeBlock.Builder code = CodeBlock.builder();

    Optional<ColumnDefinition> optionalPrimaryKey = schema.getPrimaryKey();

    if (!optionalPrimaryKey.isPresent()) {
        return code.addStatement("throw new $T($S)",
                UnsupportedOperationException.class,
                "upsert is not supported because of missing @PrimaryKey"
        ).build();
    }

    ColumnDefinition primaryKey = optionalPrimaryKey.get();

    if (!primaryKey.hasHelper(Column.Helpers.CONDITION_EQ)) {
        return code.addStatement("throw new $T($S)",
                UnsupportedOperationException.class,
                "upsert is not supported because of missing @PrimaryKey's CONDITION_EQ helper"
        ).build();
    }

    // build contentValues

    code.addStatement("$T contentValues = new $T()", Types.ContentValues, Types.ContentValues);

    for (ColumnDefinition column : schema.getColumnsWithoutAutoId()) {
        CodeBlock expr = upsertColumnAndGet(modelExpr, column);
        code.addStatement("contentValues.put($S, $L)", column.getEscapedColumnName(), expr);
    }

    // only "auto = true" supports conditional UPDATE
    if (primaryKey.autoId) {
        code.beginControlFlow("if ($L != 0)", primaryKey.buildGetColumnExpr(modelExpr));
    }

    code.addStatement("int updatedRows = updater().$LEq($L).putAll(contentValues).execute()",
            primaryKey.name, primaryKey.buildGetColumnExpr(modelExpr));
    code.beginControlFlow("if (updatedRows != 0)");
    code.addStatement("return selector().$LEq($L).value()",
            primaryKey.name, primaryKey.buildGetColumnExpr(modelExpr));
    code.endControlFlow();

    if (primaryKey.autoId) {
        code.endControlFlow();
    }

    code.addStatement("long rowId = conn.insert(schema, contentValues, $T.NONE)", OnConflict.class);
    code.addStatement("return conn.findByRowId(schema, rowId)");

    return code.build();
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:52,代码来源:RelationWriter.java


示例10: appendColumnDef

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
public void appendColumnDef(StringBuilder sb, ProcessingContext context, ColumnDefinition column) {
    appendIdentifier(sb, column.columnName);
    sb.append(' ');

    sb.append(column.getStorageType());
    sb.append(' ');

    List<String> constraints = new ArrayList<>();

    if (column.primaryKey) {
        constraints.add("PRIMARY KEY");
        if (column.primaryKeyOnConflict != OnConflict.NONE) {
            constraints.add("ON CONFLICT");
            constraints.add(onConflictClause(column.primaryKeyOnConflict));
        }
        if (column.autoincrement) {
            constraints.add("AUTOINCREMENT");
        }
    } else {
        if (column.unique) {
            constraints.add("UNIQUE");
            if (column.uniqueOnConflict != OnConflict.NONE) {
                constraints.add("ON CONFLICT");
                constraints.add(onConflictClause(column.uniqueOnConflict));
            }
        }
        if (!column.nullable) {
            constraints.add("NOT NULL");
        }
    }

    if (!Strings.isEmpty(column.defaultExpr)) {
        constraints.add("DEFAULT " + column.defaultExpr);
    }

    if (column.collate != Column.Collate.BINARY) {
        constraints.add("COLLATE " + column.collate.name());
    }

    if (column.isAssociation()) {
        constraints.add(foreignKeyConstraints(context, column));
    }

    sb.append(constraints.stream().collect(Collectors.joining(" ")));
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:46,代码来源:SqlGenerator.java


示例11: hasConditionHelpers

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
public boolean hasConditionHelpers() {
    return (helperFlags & Column.Helpers.CONDITIONS) != 0;
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:4,代码来源:ColumnDefinition.java


示例12: hasOrderHelpers

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
public boolean hasOrderHelpers() {
    return (helperFlags & Column.Helpers.ORDERS) != 0;
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:4,代码来源:ColumnDefinition.java


示例13: hasAggregationHelpers

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
public boolean hasAggregationHelpers() {
    return (helperFlags & Column.Helpers.AGGREGATORS) != 0;
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:4,代码来源:ColumnDefinition.java


示例14: hasHelper

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
public boolean hasHelper(@Column.Helpers long f) {
    assert f != Column.Helpers.NONE && f != Column.Helpers.AUTO;
    return (helperFlags & f) == f;
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:5,代码来源:ColumnDefinition.java


示例15: IndexDefinition

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
public IndexDefinition(String name, boolean unique, @Column.Helpers long helperFlags, List<ColumnDefinition> columns) {
    this.name = name;
    this.unique = unique;
    this.helperFlags = helperFlags == Column.Helpers.AUTO ? Column.Helpers.ALL : helperFlags;
    this.columns = columns;
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:7,代码来源:IndexDefinition.java


示例16: collectColumns

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
List<ColumnDefinition> collectColumns(@NonNull TypeElement typeElement) {
    List<ColumnDefinition> columns = new ArrayList<>();
    TypeMirror superclass = typeElement.getSuperclass();
    if (!superclass.toString().equals(Object.class.getCanonicalName())) {
        // superclass might represent  com.example.C<java.lang.String>
        TypeElement superclassElement = context.getTypeElement(superclass);
        columns.addAll(collectColumns(superclassElement));
    }

    Map<String, List<ExecutableElement>> getters = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    Map<String, List<ExecutableElement>> setters = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

    List<VariableElement> columnElements = new ArrayList<>();

    typeElement.getEnclosedElements()
            .forEach(element -> {
                if (element instanceof VariableElement) {
                    if (element.getAnnotation(PrimaryKey.class) != null) {
                        columnElements.add((VariableElement) element);
                    } else if (element.getAnnotation(Column.class) != null) {
                        columnElements.add((VariableElement) element);
                    }
                    return;
                }

                if (!(element instanceof ExecutableElement)) {
                    return;
                }
                if (isConstructor(element)) {
                    return;
                }

                ExecutableElement methodElement = (ExecutableElement) element;

                Getter getter = methodElement.getAnnotation(Getter.class);
                Setter setter = methodElement.getAnnotation(Setter.class);

                extractNameFromGetter(getters, getter, methodElement);
                extractNameFromSetter(setters, setter, methodElement);
            });

    columns.addAll(columnElements.stream()
            .map((element) -> {
                ColumnDefinition column = new ColumnDefinition(this, element);
                column.initGetterAndSetter(
                        getBestMatched(getters, column.columnName, column.name),
                        getBestMatched(setters, column.columnName, column.name));
                return column;
            })
            .collect(Collectors.toList()));
    return columns;
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:53,代码来源:SchemaDefinition.java


示例17: hasPrimaryIdEqHelper

import com.github.gfx.android.orma.annotation.Column; //导入依赖的package包/类
public boolean hasPrimaryIdEqHelper() {
    return primaryKey != null && primaryKey.hasHelper(Column.Helpers.CONDITION_EQ);
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:4,代码来源:SchemaDefinition.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OFPacketQueue类代码示例发布时间:2022-05-22
下一篇:
Java FurnaceBurnEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap