本文整理匯總了Java中com.datastax.driver.core.DataType.isFrozen方法的典型用法代碼示例。如果您正苦於以下問題:Java DataType.isFrozen方法的具體用法?Java DataType.isFrozen怎麽用?Java DataType.isFrozen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.datastax.driver.core.DataType
的用法示例。
在下文中一共展示了DataType.isFrozen方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getClassWithTypes
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
/**
* Handle getting the class names for parameterized types.
*
* @param type the cassandra data type to extract from
* @return the parameterized type result
*/
public static TypeResult getClassWithTypes(DataType type) {
ClassName outer = getRawType(type);
List<TypeName> generics = new ArrayList<>();
boolean hasFrozenType = false;
for(DataType genericType : type.getTypeArguments()) {
if(Udt.instance.isUdt(genericType)) {
generics.add(MetaData.getClassNameForUdt((UserType) genericType));
if(genericType.isFrozen()) {
hasFrozenType = true;
}
} else {
generics.add(getRawType(genericType).box());
}
}
return new TypeResult(ParameterizedTypeName.get(outer, generics.toArray(new TypeName[generics.size()])), hasFrozenType);
}
示例2: getFieldSpec
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
/**
* Get a FieldSpec for an entity field.
*
* @param field the field name
* @param type the field type
* @param isUdtClass is this a UDT entity?
* @param extraAnnotations additional annotations to put on the field
* @return the FieldSpec representing the cassandra field
*/
public static FieldSpec getFieldSpec(String field, DataType type, boolean isUdtClass,
List<AnnotationSpec> extraAnnotations) {
String fieldName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, field);
FieldSpec.Builder spec;
boolean hasFrozen = type.isFrozen();
if (type.getTypeArguments().size() == 0) {
if(Udt.instance.isUdt(type)) {
spec = FieldSpec.builder(MetaData.getClassNameForUdt((UserType)type), fieldName, Modifier.PUBLIC);
} else {
spec = FieldSpec.builder(getRawType(type), fieldName, Modifier.PUBLIC);
}
} else {
TypeResult result = getClassWithTypes(type);
hasFrozen |= result.hasFrozenType;
spec = FieldSpec.builder(result.type, fieldName, Modifier.PUBLIC);
}
if(hasFrozen) { spec.addAnnotation(getFrozenValueAnnotation()); }
if (isUdtClass) { spec.addAnnotation(getFieldAnnotation(field)); }
else { spec.addAnnotation(getColumnAnnotation(field)); }
spec.addAnnotation(MetaData.getJsonAnnotation(field));
for(AnnotationSpec annotationSpec : extraAnnotations) {
spec.addAnnotation(annotationSpec);
}
return spec.build();
}
示例3: getCql3Type
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
private static CQL3Type.Raw getCql3Type(DataType dt) throws Exception {
CQL3Type.Raw type;
switch (dt.getName()) {
case LIST:
type = CQL3Type.Raw.list(getCql3Type(dt.getTypeArguments().get(0)));
break;
case MAP:
type = CQL3Type.Raw.map(getCql3Type(dt.getTypeArguments().get(0)),
getCql3Type(dt.getTypeArguments().get(1)));
break;
case SET:
type = CQL3Type.Raw.set(getCql3Type(dt.getTypeArguments().get(0)));
break;
case TUPLE:
ArrayList<CQL3Type.Raw> tupleTypes = new ArrayList<CQL3Type.Raw>();
for (DataType arg : ((TupleType) dt).getComponentTypes()) {
tupleTypes.add(getCql3Type(arg));
}
type = CQL3Type.Raw.tuple(tupleTypes);
break;
case UDT: // Requires this UDT to already be loaded
UserType udt = (UserType) dt;
type = CQL3Type.Raw.userType(new UTName(new ColumnIdentifier(udt.getKeyspace(), true),
new ColumnIdentifier(udt.getTypeName(), true)));
break;
default:
type = CQL3Type.Raw.from(
Enum.<CQL3Type.Native> valueOf(CQL3Type.Native.class, dt.getName().toString().toUpperCase()));
break;
}
if (dt.isFrozen()) {
type = CQL3Type.Raw.frozen(type);
}
return type;
}
示例4: buildNonPKColumnsExpression
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
private void buildNonPKColumnsExpression(final StringBuilder queryExpression,
UpsertExecutionContext.ListPlacementStyle listPlacementStyle,
UpsertExecutionContext.CollectionMutationStyle collectionMutationStyle)
{
int count = 0;
for (String colNameEntry : columnDefinitions.keySet()) {
if (pkColumnNames.contains(colNameEntry)) {
continue;
}
if (count > 0) {
queryExpression.append(",");
}
count += 1;
if (counterColumns.contains(colNameEntry)) {
queryExpression.append(" " + colNameEntry + " = " + colNameEntry + " + :" + colNameEntry);
continue;
}
DataType dataType = columnDefinitions.get(colNameEntry);
if ((!dataType.isCollection()) && (!counterColumns.contains(colNameEntry))) {
queryExpression.append(" " + colNameEntry + " = :" + colNameEntry);
continue;
}
if ((dataType.isCollection()) && (!dataType.isFrozen())) {
if (collectionMutationStyle == UpsertExecutionContext.CollectionMutationStyle.REMOVE_FROM_EXISTING_COLLECTION) {
queryExpression.append(" " + colNameEntry + " = " + colNameEntry + " - :" + colNameEntry);
}
if (collectionMutationStyle == UpsertExecutionContext.CollectionMutationStyle.ADD_TO_EXISTING_COLLECTION) {
if ((setColumns.contains(colNameEntry)) || (mapColumns.contains(colNameEntry))) {
queryExpression.append(" " + colNameEntry + " = " + colNameEntry + " + :" + colNameEntry);
}
if ((listColumns.contains(colNameEntry)) &&
(listPlacementStyle == UpsertExecutionContext.ListPlacementStyle.APPEND_TO_EXISTING_LIST)) {
queryExpression.append(" " + colNameEntry + " = " + colNameEntry + " + :" + colNameEntry);
}
if ((listColumns.contains(colNameEntry)) &&
(listPlacementStyle == UpsertExecutionContext.ListPlacementStyle.PREPEND_TO_EXISTING_LIST)) {
queryExpression.append(" " + colNameEntry + " = :" + colNameEntry + " + " + colNameEntry);
}
}
} else {
if ((dataType.isCollection()) && (dataType.isFrozen())) {
queryExpression.append(" " + colNameEntry + " = :" + colNameEntry);
}
}
}
}