/** * Returns a {@link TypeCodec codec} that accepts the given {@link DataType CQL type} and the * given value. * * <p>This method takes an arbitrary Java object and tries to locate a suitable codec for it. * Codecs must perform a {@link TypeCodec#accepts(Object) runtime inspection} of the object to * determine if they can accept it or not, which, depending on the implementations, can be * expensive; besides, the resulting codec cannot be cached. Therefore there might be a * performance penalty when using this method. * * <p>Codecs returned by this method are <em>NOT</em> cached (see the {@link CodecRegistry * top-level documentation} of this class for more explanations about caching). * * @param cqlType The {@link DataType CQL type} the codec should accept; can be {@code null}. * @param value The value the codec should accept; must not be {@code null}. * @return A suitable codec. * @throws CodecNotFoundException if a suitable codec cannot be found. */ public <T> TypeCodec<T> codecFor(DataType cqlType, T value) { return findCodec(cqlType, value); }
/** * Returns a {@link TypeCodec codec} that accepts the given value. * * <p>This method takes an arbitrary Java object and tries to locate a suitable codec for it. * Codecs must perform a {@link TypeCodec#accepts(Object) runtime inspection} of the object to * determine if they can accept it or not, which, depending on the implementations, can be * expensive; besides, the resulting codec cannot be cached. Therefore there might be a * performance penalty when using this method. * * <p>Furthermore, this method returns the first matching codec, regardless of its accepted CQL * type. It should be reserved for situations where the target CQL type is not available or * unknown. In the Java driver, this happens mainly when serializing a value in a {@link * SimpleStatement#SimpleStatement(String, Object...) SimpleStatement} or in the {@link * com.datastax.driver.core.querybuilder.QueryBuilder}, where no CQL type information is * available. * * <p>Codecs returned by this method are <em>NOT</em> cached (see the {@link CodecRegistry * top-level documentation} of this class for more explanations about caching). * * @param value The value the codec should accept; must not be {@code null}. * @return A suitable codec. * @throws CodecNotFoundException if a suitable codec cannot be found. */ public <T> TypeCodec<T> codecFor(T value) { return findCodec(null, value); }
elementType = TypeToken.of(typeArguments[0]); TypeCodec<?> eltCodec = findCodec(cqlType.getTypeArguments().get(0), elementType); return (TypeCodec<T>) TypeCodec.list(eltCodec); elementType = TypeToken.of(typeArguments[0]); TypeCodec<?> eltCodec = findCodec(cqlType.getTypeArguments().get(0), elementType); return (TypeCodec<T>) TypeCodec.set(eltCodec); valueType = TypeToken.of(typeArguments[1]); TypeCodec<?> keyCodec = findCodec(cqlType.getTypeArguments().get(0), keyType); TypeCodec<?> valueCodec = findCodec(cqlType.getTypeArguments().get(1), valueType); return (TypeCodec<T>) TypeCodec.map(keyCodec, valueCodec);
? DataType.blob() : cqlType.getTypeArguments().get(0); return TypeCodec.list(findCodec(elementType, (TypeToken) null)); } else { DataType elementType = ? null : cqlType.getTypeArguments().get(0); return (TypeCodec<T>) TypeCodec.list(findCodec(elementType, list.iterator().next())); ? DataType.blob() : cqlType.getTypeArguments().get(0); return TypeCodec.set(findCodec(elementType, (TypeToken) null)); } else { DataType elementType = ? null : cqlType.getTypeArguments().get(0); return (TypeCodec<T>) TypeCodec.set(findCodec(elementType, set.iterator().next())); : cqlType.getTypeArguments().get(1); return TypeCodec.map( findCodec(keyType, (TypeToken) null), findCodec(valueType, (TypeToken) null)); } else { DataType keyType = return (TypeCodec<T>) TypeCodec.map( findCodec(keyType, entry.getKey()), findCodec(valueType, entry.getValue()));
/** * Returns a {@link TypeCodec codec} that accepts the given {@link DataType CQL type} * and the given value. * <p/> * This method takes an arbitrary Java object and tries to locate a suitable codec for it. * Codecs must perform a {@link TypeCodec#accepts(Object) runtime inspection} of the object to determine * if they can accept it or not, which, depending on the implementations, can be expensive; besides, the * resulting codec cannot be cached. * Therefore there might be a performance penalty when using this method. * <p/> * Codecs returned by this method are <em>NOT</em> cached (see the {@link CodecRegistry top-level documentation} * of this class for more explanations about caching). * * @param cqlType The {@link DataType CQL type} the codec should accept; can be {@code null}. * @param value The value the codec should accept; must not be {@code null}. * @return A suitable codec. * @throws CodecNotFoundException if a suitable codec cannot be found. */ public <T> TypeCodec<T> codecFor(DataType cqlType, T value) { return findCodec(cqlType, value); }
/** * Returns a {@link TypeCodec codec} that accepts the given value. * <p/> * This method takes an arbitrary Java object and tries to locate a suitable codec for it. * Codecs must perform a {@link TypeCodec#accepts(Object) runtime inspection} of the object to determine * if they can accept it or not, which, depending on the implementations, can be expensive; besides, the * resulting codec cannot be cached. * Therefore there might be a performance penalty when using this method. * <p/> * Furthermore, this method returns the first matching codec, regardless of its accepted CQL type. * It should be reserved for situations where the target CQL type is not available or unknown. * In the Java driver, this happens mainly when serializing a value in a * {@link SimpleStatement#SimpleStatement(String, Object...) SimpleStatement} or in the * {@link com.datastax.driver.core.querybuilder.QueryBuilder}, where no CQL type information is available. * <p/> * Codecs returned by this method are <em>NOT</em> cached (see the {@link CodecRegistry top-level documentation} * of this class for more explanations about caching). * * @param value The value the codec should accept; must not be {@code null}. * @return A suitable codec. * @throws CodecNotFoundException if a suitable codec cannot be found. */ public <T> TypeCodec<T> codecFor(T value) { return findCodec(null, value); }
/** * Returns a {@link TypeCodec codec} that accepts the given {@link DataType CQL type} * and the given value. * <p/> * This method takes an arbitrary Java object and tries to locate a suitable codec for it. * Codecs must perform a {@link TypeCodec#accepts(Object) runtime inspection} of the object to determine * if they can accept it or not, which, depending on the implementations, can be expensive; besides, the * resulting codec cannot be cached. * Therefore there might be a performance penalty when using this method. * <p/> * Codecs returned by this method are <em>NOT</em> cached (see the {@link CodecRegistry top-level documentation} * of this class for more explanations about caching). * * @param cqlType The {@link DataType CQL type} the codec should accept; can be {@code null}. * @param value The value the codec should accept; must not be {@code null}. * @return A suitable codec. * @throws CodecNotFoundException if a suitable codec cannot be found. */ public <T> TypeCodec<T> codecFor(DataType cqlType, T value) { return findCodec(cqlType, value); }
/** * Returns a {@link TypeCodec codec} that accepts the given {@link DataType CQL type} * and the given value. * <p/> * This method takes an arbitrary Java object and tries to locate a suitable codec for it. * Codecs must perform a {@link TypeCodec#accepts(Object) runtime inspection} of the object to determine * if they can accept it or not, which, depending on the implementations, can be expensive; besides, the * resulting codec cannot be cached. * Therefore there might be a performance penalty when using this method. * <p/> * Codecs returned by this method are <em>NOT</em> cached (see the {@link CodecRegistry top-level documentation} * of this class for more explanations about caching). * * @param cqlType The {@link DataType CQL type} the codec should accept; can be {@code null}. * @param value The value the codec should accept; must not be {@code null}. * @return A suitable codec. * @throws CodecNotFoundException if a suitable codec cannot be found. */ public <T> TypeCodec<T> codecFor(DataType cqlType, T value) { return findCodec(cqlType, value); }
/** * Returns a {@link TypeCodec codec} that accepts the given value. * <p/> * This method takes an arbitrary Java object and tries to locate a suitable codec for it. * Codecs must perform a {@link TypeCodec#accepts(Object) runtime inspection} of the object to determine * if they can accept it or not, which, depending on the implementations, can be expensive; besides, the * resulting codec cannot be cached. * Therefore there might be a performance penalty when using this method. * <p/> * Furthermore, this method returns the first matching codec, regardless of its accepted CQL type. * It should be reserved for situations where the target CQL type is not available or unknown. * In the Java driver, this happens mainly when serializing a value in a * {@link SimpleStatement#SimpleStatement(String, Object...) SimpleStatement} or in the * {@link com.datastax.driver.core.querybuilder.QueryBuilder}, where no CQL type information is available. * <p/> * Codecs returned by this method are <em>NOT</em> cached (see the {@link CodecRegistry top-level documentation} * of this class for more explanations about caching). * * @param value The value the codec should accept; must not be {@code null}. * @return A suitable codec. * @throws CodecNotFoundException if a suitable codec cannot be found. */ public <T> TypeCodec<T> codecFor(T value) { return findCodec(null, value); }
/** * Returns a {@link TypeCodec codec} that accepts the given value. * <p/> * This method takes an arbitrary Java object and tries to locate a suitable codec for it. * Codecs must perform a {@link TypeCodec#accepts(Object) runtime inspection} of the object to determine * if they can accept it or not, which, depending on the implementations, can be expensive; besides, the * resulting codec cannot be cached. * Therefore there might be a performance penalty when using this method. * <p/> * Furthermore, this method returns the first matching codec, regardless of its accepted CQL type. * It should be reserved for situations where the target CQL type is not available or unknown. * In the Java driver, this happens mainly when serializing a value in a * {@link SimpleStatement#SimpleStatement(String, Object...) SimpleStatement} or in the * {@link com.datastax.driver.core.querybuilder.QueryBuilder}, where no CQL type information is available. * <p/> * Codecs returned by this method are <em>NOT</em> cached (see the {@link CodecRegistry top-level documentation} * of this class for more explanations about caching). * * @param value The value the codec should accept; must not be {@code null}. * @return A suitable codec. * @throws CodecNotFoundException if a suitable codec cannot be found. */ public <T> TypeCodec<T> codecFor(T value) { return findCodec(null, value); }
elementType = TypeToken.of(typeArguments[0]); TypeCodec<?> eltCodec = findCodec(cqlType.getTypeArguments().get(0), elementType); return (TypeCodec<T>) TypeCodec.list(eltCodec); elementType = TypeToken.of(typeArguments[0]); TypeCodec<?> eltCodec = findCodec(cqlType.getTypeArguments().get(0), elementType); return (TypeCodec<T>) TypeCodec.set(eltCodec); valueType = TypeToken.of(typeArguments[1]); TypeCodec<?> keyCodec = findCodec(cqlType.getTypeArguments().get(0), keyType); TypeCodec<?> valueCodec = findCodec(cqlType.getTypeArguments().get(1), valueType); return (TypeCodec<T>) TypeCodec.map(keyCodec, valueCodec);
? DataType.blob() : cqlType.getTypeArguments().get(0); return TypeCodec.list(findCodec(elementType, (TypeToken) null)); } else { DataType elementType = (cqlType == null || cqlType.getTypeArguments().isEmpty()) ? null : cqlType.getTypeArguments().get(0); return (TypeCodec<T>) TypeCodec.list(findCodec(elementType, list.iterator().next())); ? DataType.blob() : cqlType.getTypeArguments().get(0); return TypeCodec.set(findCodec(elementType, (TypeToken) null)); } else { DataType elementType = (cqlType == null || cqlType.getTypeArguments().isEmpty()) ? null : cqlType.getTypeArguments().get(0); return (TypeCodec<T>) TypeCodec.set(findCodec(elementType, set.iterator().next())); cqlType.getTypeArguments().get(1); return TypeCodec.map( findCodec(keyType, (TypeToken) null), findCodec(valueType, (TypeToken) null)); } else { DataType keyType = (cqlType == null || cqlType.getTypeArguments().size() < 1) Map.Entry entry = (Map.Entry) map.entrySet().iterator().next(); return (TypeCodec<T>) TypeCodec.map( findCodec(keyType, entry.getKey()), findCodec(valueType, entry.getValue()));
? DataType.blob() : cqlType.getTypeArguments().get(0); return TypeCodec.list(findCodec(elementType, (TypeToken) null)); } else { DataType elementType = (cqlType == null || cqlType.getTypeArguments().isEmpty()) ? null : cqlType.getTypeArguments().get(0); return (TypeCodec<T>) TypeCodec.list(findCodec(elementType, list.iterator().next())); ? DataType.blob() : cqlType.getTypeArguments().get(0); return TypeCodec.set(findCodec(elementType, (TypeToken) null)); } else { DataType elementType = (cqlType == null || cqlType.getTypeArguments().isEmpty()) ? null : cqlType.getTypeArguments().get(0); return (TypeCodec<T>) TypeCodec.set(findCodec(elementType, set.iterator().next())); cqlType.getTypeArguments().get(1); return TypeCodec.map( findCodec(keyType, (TypeToken) null), findCodec(valueType, (TypeToken) null)); } else { DataType keyType = (cqlType == null || cqlType.getTypeArguments().size() < 1) Map.Entry entry = (Map.Entry) map.entrySet().iterator().next(); return (TypeCodec<T>) TypeCodec.map( findCodec(keyType, entry.getKey()), findCodec(valueType, entry.getValue()));
? DataType.blob() : cqlType.getTypeArguments().get(0); return TypeCodec.list(findCodec(elementType, (TypeToken) null)); } else { DataType elementType = (cqlType == null || cqlType.getTypeArguments().isEmpty()) ? null : cqlType.getTypeArguments().get(0); return (TypeCodec<T>) TypeCodec.list(findCodec(elementType, list.iterator().next())); ? DataType.blob() : cqlType.getTypeArguments().get(0); return TypeCodec.set(findCodec(elementType, (TypeToken) null)); } else { DataType elementType = (cqlType == null || cqlType.getTypeArguments().isEmpty()) ? null : cqlType.getTypeArguments().get(0); return (TypeCodec<T>) TypeCodec.set(findCodec(elementType, set.iterator().next())); cqlType.getTypeArguments().get(1); return TypeCodec.map( findCodec(keyType, (TypeToken) null), findCodec(valueType, (TypeToken) null)); } else { DataType keyType = (cqlType == null || cqlType.getTypeArguments().size() < 1) Map.Entry entry = (Map.Entry) map.entrySet().iterator().next(); return (TypeCodec<T>) TypeCodec.map( findCodec(keyType, entry.getKey()), findCodec(valueType, entry.getValue()));
elementType = TypeToken.of(typeArguments[0]); TypeCodec<?> eltCodec = findCodec(cqlType.getTypeArguments().get(0), elementType); return (TypeCodec<T>) TypeCodec.list(eltCodec); elementType = TypeToken.of(typeArguments[0]); TypeCodec<?> eltCodec = findCodec(cqlType.getTypeArguments().get(0), elementType); return (TypeCodec<T>) TypeCodec.set(eltCodec); valueType = TypeToken.of(typeArguments[1]); TypeCodec<?> keyCodec = findCodec(cqlType.getTypeArguments().get(0), keyType); TypeCodec<?> valueCodec = findCodec(cqlType.getTypeArguments().get(1), valueType); return (TypeCodec<T>) TypeCodec.map(keyCodec, valueCodec);
elementType = TypeToken.of(typeArguments[0]); TypeCodec<?> eltCodec = findCodec(cqlType.getTypeArguments().get(0), elementType); return (TypeCodec<T>) TypeCodec.list(eltCodec); elementType = TypeToken.of(typeArguments[0]); TypeCodec<?> eltCodec = findCodec(cqlType.getTypeArguments().get(0), elementType); return (TypeCodec<T>) TypeCodec.set(eltCodec); valueType = TypeToken.of(typeArguments[1]); TypeCodec<?> keyCodec = findCodec(cqlType.getTypeArguments().get(0), keyType); TypeCodec<?> valueCodec = findCodec(cqlType.getTypeArguments().get(1), valueType); return (TypeCodec<T>) TypeCodec.map(keyCodec, valueCodec);