Calls compose function of respective data type of object.

@param dataTypeClazz
the data type clazz
@param dataValue
the data value
@param mapGenericClassses
the map generic classses
@param isCql3Enabled
the is cql3 enabled
@return the byte[]
547844
public static byte[] compose(Class<?> dataTypeClazz, Object dataValue, Class<?> mapGenericClassses,
            boolean isCql3Enabled)
    {
        if (isCql3Enabled || (!isCql3Enabled && dataValue != null))
        {
            switch (getCassandraDataTypeClass(dataTypeClazz))
            {
            case LIST:
                return ListTypeBuilder.compose(dataValue, dataTypeClazz, mapGenericClassses);
            case SET:
                return SetTypeBuilder.compose(dataValue, dataTypeClazz, mapGenericClassses);
            }
        }
        return null;
    }
1292763
@SuppressWarnings("unchecked")
	public <T> T convert(Type type, Object value, T defaultValue, boolean isCustomFirst) throws ConvertException {
		if (TypeUtil.isUnknow(type) && null == defaultValue) {
			// 对于用户不指定目标类型的情况，返回原值
			return (T) value;
		}
		if (ObjectUtil.isNull(value)) {
			return defaultValue;
		}
		if (TypeUtil.isUnknow(type)) {
			type = defaultValue.getClass();
		}
		
		// 标准转换器
		final Converter<T> converter = getConverter(type, isCustomFirst);
		if (null != converter) {
			return converter.convert(value, defaultValue);
		}

		Class<T> rowType = (Class<T>) TypeUtil.getClass(type);
		if (null == rowType) {
			if (null != defaultValue) {
				rowType = (Class<T>) defaultValue.getClass();
			} else {
				// 无法识别的泛型类型，按照Object处理
				return (T) value;
			}
		}
		
		// 特殊类型转换，包括Collection、Map、强转、Array等
		final T result = convertSpecial(type, rowType, value, defaultValue);
		if (null != result) {
			return result;
		}
		
		// 尝试转Bean
		if (BeanUtil.isBean(rowType)) {
			return new BeanConverter<T>(type).convert(value, defaultValue);
		}
		
		// 无法转换
		throw new ConvertException("No Converter for type [{}]", rowType.getName());
	}
689181
public static MappingColumn[] getIdMappingColumns(final Class<?> entityType) {
		return Arrays.stream(MappingUtils.getMappingColumns(entityType)).filter(c -> c.isId())
				.toArray(MappingColumn[]::new);
	}
763604
private static void resetMapperForThrift(boolean isCql3Enabled)
    {
        if (isCql3Enabled)
        {
            validationClassMapper.put(Byte.class, BytesType.class);
            validationClassMapper.put(byte.class, BytesType.class);
            validationClassMapper.put(Short.class, IntegerType.class);
            validationClassMapper.put(short.class, IntegerType.class);
            validationClassMapper.put(java.sql.Time.class, DateType.class);
            validationClassMapper.put(java.sql.Date.class, DateType.class);
            validationClassMapper.put(java.util.Date.class, DateType.class);
            validationClassMapper.put(java.sql.Timestamp.class, DateType.class);
        }
    }
584247
public static String toStringType(int type, String defaultValue) {
	switch (type) {
	case Types.ARRAY:
	    return "CF_SQL_ARRAY";
	case Types.BIGINT:
	    return "CF_SQL_BIGINT";
	case Types.BINARY:
	    return "CF_SQL_BINARY";
	case Types.BIT:
	    return "CF_SQL_BIT";
	case Types.BOOLEAN:
	    return "CF_SQL_BOOLEAN";
	case Types.BLOB:
	    return "CF_SQL_BLOB";
	case Types.CHAR:
	    return "CF_SQL_CHAR";
	case Types.CLOB:
	    return "CF_SQL_CLOB";
	case Types.DATALINK:
	    return "CF_SQL_DATALINK";
	case Types.DATE:
	    return "CF_SQL_DATE";
	case Types.DISTINCT:
	    return "CF_SQL_DISTINCT";
	case Types.NUMERIC:
	    return "CF_SQL_NUMERIC";
	case Types.DECIMAL:
	    return "CF_SQL_DECIMAL";
	case Types.DOUBLE:
	    return "CF_SQL_DOUBLE";
	case Types.REAL:
	    return "CF_SQL_REAL";
	case Types.FLOAT:
	    return "CF_SQL_FLOAT";
	case Types.TINYINT:
	    return "CF_SQL_TINYINT";
	case Types.SMALLINT:
	    return "CF_SQL_SMALLINT";
	case Types.STRUCT:
	    return "CF_SQL_STRUCT";
	case Types.INTEGER:
	    return "CF_SQL_INTEGER";
	case Types.VARCHAR:
	    return "CF_SQL_VARCHAR";
	case Types.NVARCHAR:
	    return "CF_SQL_NVARCHAR";
	case CFTypes.VARCHAR2:
	    return "CF_SQL_VARCHAR2";
	case Types.LONGVARBINARY:
	    return "CF_SQL_LONGVARBINARY";
	case Types.VARBINARY:
	    return "CF_SQL_VARBINARY";
	case Types.LONGVARCHAR:
	    return "CF_SQL_LONGVARCHAR";
	case Types.TIME:
	    return "CF_SQL_TIME";
	case Types.TIMESTAMP:
	    return "CF_SQL_TIMESTAMP";
	case Types.REF:
	    return "CF_SQL_REF";
	case CFTypes.CURSOR:
	    return "CF_SQL_REFCURSOR";
	case Types.OTHER:
	    return "CF_SQL_OTHER";
	case Types.NULL:
	    return "CF_SQL_NULL";

	default:
	    return null;
	}
    }
1206106
public static CassandraType getCassandraDataTypeClass(Class clazz)
    {
        if(clazz.isEnum()){
            return CassandraType.STRING;
        }
        return typeToClazz.get(clazz);
    }
885834
@SuppressWarnings("rawtypes")
	public static Class<?> getMapKeyType(Class<? extends Map> mapClass) {
		return ResolvableType.forClass(mapClass).asMap().resolveGeneric(0);
	}
1032118
function parseTypeString(type){
  if (type.indexOf('CompositeType') > -1){
    return getCompositeTypes(type);
  } else if(type.indexOf('ReversedType') > -1){
    return getType(getInnerType(type));
  }
  else if(type.indexOf('org.apache.cassandra.db.marshal.SetType') > -1){
    return getSetType(type);
  }
  else if(type.indexOf('org.apache.cassandra.db.marshal.ListType') > -1){
    return getListType(type);
  }
  else if(type.indexOf('org.apache.cassandra.db.marshal.MapType') > -1){
    return getMapType(type);
  }
  else if(type === null || type === undefined) {
    return 'BytesType';
  } else {
    return getType(type);
  }
}
1185933
protected Map<String, Object> resolveGenericTypes(DeclaredType type, TypeElement typeElement, Map<String, Object> boundTypes) {
        List<? extends TypeMirror> typeArguments = type.getTypeArguments();
        Map<String, Object> resolvedParameters = new LinkedHashMap<>();
        List<? extends TypeParameterElement> typeParameters = typeElement.getTypeParameters();
        if (typeArguments.size() == typeParameters.size()) {
            Iterator<? extends TypeMirror> i = typeArguments.iterator();
            for (TypeParameterElement typeParameter : typeParameters) {
                String parameterName = typeParameter.toString();
                TypeMirror mirror = i.next();

                TypeKind kind = mirror.getKind();
                switch (kind) {
                    case TYPEVAR:
                        TypeVariable tv = (TypeVariable) mirror;
                        if (boundTypes.containsKey(tv.toString())) {
                            resolvedParameters.put(parameterName, boundTypes.get(tv.toString()));
                        } else {
                            TypeMirror upperBound = tv.getUpperBound();
                            TypeMirror lowerBound = tv.getLowerBound();
                            if (upperBound.getKind() != TypeKind.NULL) {
                                resolvedParameters.put(parameterName, resolveTypeReference(upperBound, Collections.emptyMap()));
                            } else if (lowerBound.getKind() != TypeKind.NULL) {
                                resolvedParameters.put(parameterName, resolveTypeReference(lowerBound, Collections.emptyMap()));
                            }
                        }
                        continue;
                    case ARRAY:
                    case BOOLEAN:
                    case BYTE:
                    case CHAR:
                    case DOUBLE:
                    case FLOAT:
                    case INT:
                    case LONG:
                    case SHORT:
                        resolveGenericTypeParameterForPrimitiveOrArray(resolvedParameters, parameterName, mirror, boundTypes);
                        continue;
                    case DECLARED:
                        resolveGenericTypeParameter(resolvedParameters, parameterName, mirror, boundTypes);
                        continue;
                    case WILDCARD:
                        WildcardType wcType = (WildcardType) mirror;
                        TypeMirror extendsBound = wcType.getExtendsBound();
                        TypeMirror superBound = wcType.getSuperBound();
                        if (extendsBound != null) {
                            resolveGenericTypeParameter(resolvedParameters, parameterName, extendsBound, boundTypes);
                        } else if (superBound != null) {
                            resolveGenericTypeParameter(resolvedParameters, parameterName, superBound, boundTypes);
                        } else {
                            resolvedParameters.put(parameterName, Object.class);
                        }
                    default:
                        // no-op
                }
            }
        }
        return resolvedParameters;
    }
698817
public List executeSelectQuery(Class clazz, List<String> relationalField, CassandraDataHandler dataHandler,
        boolean isNative, String cqlQuery) {
        if (log.isDebugEnabled()) {
            log.debug("Executing cql query {}.", cqlQuery);
        }

        List entities = new ArrayList<Object>();

        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, clazz);

        MetamodelImpl metaModel =
            (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(entityMetadata.getPersistenceUnit());

        EntityType entityType = metaModel.entity(entityMetadata.getEntityClazz());

        List<AbstractManagedType> subManagedType = ((AbstractManagedType) entityType).getSubManagedType();

        if (subManagedType.isEmpty()) {
            entities.addAll(cqlClient.executeQuery(clazz, relationalField, dataHandler, true, isNative, cqlQuery));
        } else {
            for (AbstractManagedType subEntity : subManagedType) {
                EntityMetadata subEntityMetadata =
                    KunderaMetadataManager.getEntityMetadata(kunderaMetadata, subEntity.getJavaType());

                entities.addAll(cqlClient.executeQuery(subEntityMetadata.getEntityClazz(), relationalField, dataHandler,
                    true, isNative, cqlQuery));
            }
        }
        return entities;
    }
1271513
private <X> AbstractManagedType<X> buildManagedType(Class<X> clazz, boolean isIdClass)
    {
        AbstractManagedType<X> managedType = null;
        if (clazz.isAnnotationPresent(Embeddable.class))
        {

            validate(clazz, true);
            if (!embeddables.containsKey(clazz))
            {
                managedType = new DefaultEmbeddableType<X>(clazz, PersistenceType.EMBEDDABLE, getType(
                        clazz.getSuperclass(), isIdClass));
                onDeclaredFields(clazz, managedType);
                embeddables.put(clazz, managedType);
            }
            else
            {
                managedType = (AbstractManagedType<X>) embeddables.get(clazz);
            }

        }
        else if (clazz.isAnnotationPresent(MappedSuperclass.class))
        {

            validate(clazz, false);
            // if (!mappedSuperClassTypes.containsKey(clazz))
            // {
            managedType = new DefaultMappedSuperClass<X>(clazz, PersistenceType.MAPPED_SUPERCLASS,
                    (AbstractIdentifiableType) getType(clazz.getSuperclass(), isIdClass));
            onDeclaredFields(clazz, managedType);
            mappedSuperClassTypes.put(clazz, (MappedSuperclassType<?>) managedType);
            // }
            // else
            // {
            // managedType = (AbstractManagedType<X>)
            // mappedSuperClassTypes.get(clazz);
            // }
        }
        else if (clazz.isAnnotationPresent(Entity.class) || isIdClass)
        {
            if (!managedTypes.containsKey(clazz))
            {
                managedType = new DefaultEntityType<X>(clazz, PersistenceType.ENTITY,
                        (AbstractIdentifiableType) getType(clazz.getSuperclass(), isIdClass));
                // in case of @IdClass, it is a temporary managed type.
                if (!isIdClass)
                {
                    managedTypes.put(clazz, (EntityType<?>) managedType);
                }
            }
            else
            {
                managedType = (AbstractManagedType<X>) managedTypes.get(clazz);
            }
        }

        return managedType;
    }
72112
private ByteBuffer columnValueAsBytes(ByteBuffer columnName, String columnFamilyName, String columnValue)
    {
        CfDef columnFamilyDef = getCfDef(columnFamilyName);
        AbstractType<?> defaultValidator = getFormatType(columnFamilyDef.default_validation_class);

        for (ColumnDef columnDefinition : columnFamilyDef.getColumn_metadata())
        {
            byte[] currentColumnName = columnDefinition.getName();

            if (ByteBufferUtil.compare(currentColumnName, columnName) == 0)
            {
                try
                {
                    String validationClass = columnDefinition.getValidation_class();
                    return getBytesAccordingToType(columnValue, getFormatType(validationClass));
                }
                catch (Exception e)
                {
                    throw new RuntimeException(e);
                }
            }
        }

        return defaultValidator.fromString(columnValue);
    }
13093
public Datatype.Builder mergeFrom(Datatype value) {
    Datatype_Builder defaults = new Datatype.Builder();
    if (defaults._unsetProperties.contains(Property.TYPE)
        || !Objects.equals(value.getType(), defaults.getType())) {
      setType(value.getType());
    }
    if (defaults._unsetProperties.contains(Property.INTERFACE_TYPE)
        || value.isInterfaceType() != defaults.isInterfaceType()) {
      setInterfaceType(value.isInterfaceType());
    }
    if (defaults._unsetProperties.contains(Property.BUILDER)
        || !Objects.equals(value.getBuilder(), defaults.getBuilder())) {
      setBuilder(value.getBuilder());
    }
    if (defaults._unsetProperties.contains(Property.EXTENSIBLE)
        || value.isExtensible() != defaults.isExtensible()) {
      setExtensible(value.isExtensible());
    }
    value.getBuilderFactory().ifPresent(this::setBuilderFactory);
    if (defaults._unsetProperties.contains(Property.GENERATED_BUILDER)
        || !Objects.equals(value.getGeneratedBuilder(), defaults.getGeneratedBuilder())) {
      setGeneratedBuilder(value.getGeneratedBuilder());
    }
    if (defaults._unsetProperties.contains(Property.VALUE_TYPE)
        || !Objects.equals(value.getValueType(), defaults.getValueType())) {
      setValueType(value.getValueType());
    }
    if (defaults._unsetProperties.contains(Property.PARTIAL_TYPE)
        || !Objects.equals(value.getPartialType(), defaults.getPartialType())) {
      setPartialType(value.getPartialType());
    }
    value.getRebuildableType().ifPresent(this::setRebuildableType);
    if (defaults._unsetProperties.contains(Property.PROPERTY_ENUM)
        || !Objects.equals(value.getPropertyEnum(), defaults.getPropertyEnum())) {
      setPropertyEnum(value.getPropertyEnum());
    }
    putAllStandardMethodUnderrides(value.getStandardMethodUnderrides());
    if (defaults._unsetProperties.contains(Property.BUILDER_SERIALIZABLE)
        || value.isBuilderSerializable() != defaults.isBuilderSerializable()) {
      setBuilderSerializable(value.isBuilderSerializable());
    }
    if (defaults._unsetProperties.contains(Property.HAS_TO_BUILDER_METHOD)
        || value.getHasToBuilderMethod() != defaults.getHasToBuilderMethod()) {
      setHasToBuilderMethod(value.getHasToBuilderMethod());
    }
    if (value instanceof Value && generatedBuilderAnnotations == ImmutableList.<Excerpt>of()) {
      generatedBuilderAnnotations = ImmutableList.copyOf(value.getGeneratedBuilderAnnotations());
    } else {
      addAllGeneratedBuilderAnnotations(value.getGeneratedBuilderAnnotations());
    }
    if (value instanceof Value && valueTypeAnnotations == ImmutableList.<Excerpt>of()) {
      valueTypeAnnotations = ImmutableList.copyOf(value.getValueTypeAnnotations());
    } else {
      addAllValueTypeAnnotations(value.getValueTypeAnnotations());
    }
    if (defaults._unsetProperties.contains(Property.VALUE_TYPE_VISIBILITY)
        || !Objects.equals(value.getValueTypeVisibility(), defaults.getValueTypeVisibility())) {
      setValueTypeVisibility(value.getValueTypeVisibility());
    }
    if (value instanceof Value && nestedClasses == ImmutableList.<Excerpt>of()) {
      nestedClasses = ImmutableList.copyOf(value.getNestedClasses());
    } else {
      addAllNestedClasses(value.getNestedClasses());
    }
    return (Datatype.Builder) this;
  }
1237831
@SuppressWarnings("unchecked")
	public static <D, J> D toData(Class<? extends PreferenceTypeAdapter<J, D>> clazz, J javaValue) {
		PreferenceTypeAdapter<J, D> adapter = cache.get(clazz);

		if (adapter == null) {
			try {
				lock.lock();
				adapter = clazz.newInstance();
				cache.put(clazz, adapter);
			} catch (Throwable e) {
				throw (new KriptonRuntimeException(e));
			} finally {
				lock.unlock();
			}
		}

		return adapter.toData(javaValue);
	}
1302739
public static Set<Type> getTypedTypes(Map<Class<?>, Type> typeClosure, Class<?> rawType, Typed typed) {
        Set<Type> types = new HashSet<Type>();
        for (Class<?> specifiedClass : typed.value()) {
            Type tmp = typeClosure.get(specifiedClass);
            if (tmp != null) {
                types.add(tmp);
            } else {
                throw BeanLogger.LOG.typedClassNotInHierarchy(specifiedClass.getName(), rawType, Formats.formatTypes(typeClosure.values()));
            }
        }
        types.add(Object.class);
        return types;
    }
1189144
public static byte[] compose(Class<?> dataTypeClazz, Object dataValue, boolean isCql3Enabled)
    {

        if (isCql3Enabled || (!isCql3Enabled && dataValue != null))
        {

            switch (getCassandraDataTypeClass(dataTypeClazz))
            {
            case INT:
                return IntegerTypeBuilder.compose(dataValue, dataTypeClazz);
            case DATE:
                return DateTypeBuilder.compose(dataValue, dataTypeClazz);
            case FLOAT:
                return FloatTypeBuilder.compose(dataValue, dataTypeClazz);
            case LONG:
                return LongTypeBuilder.compose(dataValue, dataTypeClazz);
            case DOUBLE:
                return DoubleTypeBuilder.compose(dataValue, dataTypeClazz);
            case STRING:
                return StringTypeBuilder.compose(dataValue, dataTypeClazz);
            case ASCII:
                return AsciiTypeBuilder.compose(dataValue, dataTypeClazz);
            case UUID:
                return UUIDTypeBuilder.compose(dataValue, dataTypeClazz);
            case BYTES:
                return BytesTypeBuilder.compose(dataValue, dataTypeClazz);
            case BOOLEAN:
                return BooleanTypeBuilder.compose(dataValue, dataTypeClazz);
            case INT32:
                return IntegerTypeBuilder.compose(dataValue, dataTypeClazz);
            case DECIMAL:
                return DecimalTypeBuilder.compose(dataValue, dataTypeClazz);
            case COUNTER:
                return CounterTypeBuilder.compose(dataValue, dataTypeClazz);
            case ENUM:
                return EnumTypeBuilder.compose(dataValue, dataTypeClazz);
            case CHARACTER:
                return CharacterTypeBuilder.compose(dataValue, dataTypeClazz);
            case SHORT:
                return ShortTypeBuilder.compose(dataValue, dataTypeClazz);
            case BIGINT:
                return BigIntegerTypeBuilder.compose(dataValue, dataTypeClazz);
            case TIMESTAMP:
                return TimeStampTypeBuilder.compose(dataValue, dataTypeClazz);
            case SQL_DATE:
                return SQLDateTypeBuilder.compose(dataValue, dataTypeClazz);
            case SQL_TIME:
                return SQLTimeTypeBuilder.compose(dataValue, dataTypeClazz);
            case SQL_TIMESTAMP:
                return SQLTimeStampTypeBuilder.compose(dataValue, dataTypeClazz);
            case CALENDAR:
                return CalendarTypeBuilder.compose(dataValue, dataTypeClazz);
            }
        }
        return null;
    }
1141248
public static Object getValue4Type(ResultSet rs, String column, Class<?> typeClass) throws SQLException {

        if (Collection.class.isAssignableFrom(typeClass)) {
            return null;
        }

        try {
            rs.findColumn(column);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

        if (typeClass.equals(Integer.class) || typeClass.equals(Integer.TYPE)) {
            return rs.getInt(column);
        }

        if (typeClass.equals(Long.class) || typeClass.equals(Long.TYPE)) {
            return rs.getLong(column);
        }

        if (typeClass.equals(Boolean.class) || typeClass.equals(Boolean.TYPE)) {
            return rs.getBoolean(column);
        }

        if (typeClass.equals(Float.class) || typeClass.equals(Float.TYPE)) {
            return rs.getFloat(column);
        }

        if (typeClass.equals(Double.class) || typeClass.equals(Double.TYPE)) {
            return rs.getDouble(column);
        }

        if (typeClass.equals(Byte.class) || typeClass.equals(Byte.TYPE)) {
            return rs.getByte(column);
        }

        if (typeClass.equals(String.class)) {
            return rs.getString(column);
        }

        if (Date.class.isAssignableFrom(typeClass)) {
            return rs.getTimestamp(column);
        }

        if (java.sql.Date.class.isAssignableFrom(typeClass)) {
            return rs.getDate(column);
        }

        return rs.getObject(column);
    }