davsclaus commented on code in PR #28309:
URL: https://github.com/apache/camel/pull/28309#discussion_r4352309587
##########
components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/RedisEndpoint.java:
##########
@@ -31,6 +34,87 @@
*/
@UriEndpoint(firstVersion = "2.11.0", scheme = "spring-redis", title = "Spring
Redis", syntax = "spring-redist:host:port",
category = { Category.CACHE }, headersClass =
RedisConstants.class)
+@BodyTypes(consumerOut = @BodyType(value = Carrier.UNKNOWN,
+ description = "The message as the
serializer reads it: with the default JDK serializer the"
+ + " Java object the publisher
serialized, such as the String a PUBLISH of this"
+ + " component sent, with the
channel in the CamelRedis.Channel header. A"
+ + " message that is not Java
serialized, such as one from redis-cli, is"
+ + " dropped with a WARN: set
a StringRedisSerializer as the serializer to"
+ + " receive text"),
+ producerIn = @BodyType(value = Carrier.ANY,
+ description = "The body is not used: the
key, the value and the other arguments of the"
+ + " command come from headers,
such as CamelRedis.Key and CamelRedis.Value, or"
+ + " CamelRedis.Channel and
CamelRedis.Message for PUBLISH. Set CamelRedis.Value"
+ + " from the body to store the
body: with the default serializer it must be"
+ + " Serializable, so a stream
fails"),
+ producerOut = @BodyType(value = Carrier.UNCHANGED, dependsOn =
"command",
+ byOption = {
+ @BodyType.When(option = "command",
value = "SET", carriers = Carrier.UNCHANGED),
+ @BodyType.When(option = "command",
value = "SETEX", carriers = Carrier.UNCHANGED),
+ @BodyType.When(option = "command",
value = "MSET", carriers = Carrier.UNCHANGED),
+ @BodyType.When(option = "command",
value = "HSET", carriers = Carrier.UNCHANGED),
+ @BodyType.When(option = "command",
value = "HMSET", carriers = Carrier.UNCHANGED),
+ @BodyType.When(option = "command",
value = "HDEL", carriers = Carrier.UNCHANGED),
+ @BodyType.When(option = "command",
value = "DEL", carriers = Carrier.UNCHANGED),
+ @BodyType.When(option = "command",
value = "PUBLISH", carriers = Carrier.UNCHANGED),
+ @BodyType.When(option = "command",
value = "LSET", carriers = Carrier.UNCHANGED),
+ @BodyType.When(option = "command",
value = "LTRIM", carriers = Carrier.UNCHANGED),
+ @BodyType.When(option = "command",
value = "RENAME", carriers = Carrier.UNCHANGED),
+ @BodyType.When(option = "command",
value = "EXISTS", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Boolean"),
+ @BodyType.When(option = "command",
value = "EXPIRE", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Boolean"),
+ @BodyType.When(option = "command",
value = "SETNX", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Boolean"),
+ @BodyType.When(option = "command",
value = "HEXISTS", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Boolean"),
+ @BodyType.When(option = "command",
value = "SISMEMBER", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Boolean"),
+ @BodyType.When(option = "command",
value = "INCR", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Long"),
+ @BodyType.When(option = "command",
value = "INCRBY", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Long"),
+ @BodyType.When(option = "command",
value = "DECR", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Long"),
+ @BodyType.When(option = "command",
value = "DECRBY", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Long"),
+ @BodyType.When(option = "command",
value = "LPUSH", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Long"),
+ @BodyType.When(option = "command",
value = "RPUSH", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Long"),
+ @BodyType.When(option = "command",
value = "LLEN", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Long"),
+ @BodyType.When(option = "command",
value = "SADD", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Long"),
+ @BodyType.When(option = "command",
value = "SREM", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Long"),
+ @BodyType.When(option = "command",
value = "SCARD", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Long"),
+ @BodyType.When(option = "command",
value = "HLEN", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Long"),
+ @BodyType.When(option = "command",
value = "TTL", carriers = Carrier.VALUE,
+ javaType =
"java.lang.Long"),
+ @BodyType.When(option = "command",
value = "PING", carriers = Carrier.TEXT,
+ javaType =
"java.lang.String"),
+ @BodyType.When(option = "command",
value = "ECHO", carriers = Carrier.TEXT,
+ javaType =
"java.lang.String"),
+ @BodyType.When(option = "command",
value = "HGETALL", carriers = Carrier.MAP),
+ @BodyType.When(option = "command",
value = "KEYS", carriers = Carrier.LIST),
+ @BodyType.When(option = "command",
value = "HKEYS", carriers = Carrier.LIST),
+ @BodyType.When(option = "command",
value = "HVALS", carriers = Carrier.LIST),
+ @BodyType.When(option = "command",
value = "SMEMBERS", carriers = Carrier.LIST),
+ @BodyType.When(option = "command",
value = "ZRANGE", carriers = Carrier.LIST),
+ @BodyType.When(option = "command",
value = "ZREVRANGE", carriers = Carrier.LIST),
+ @BodyType.When(option = "command",
value = "LRANGE", carriers = Carrier.LIST),
+ @BodyType.When(option = "command",
value = "MGET", carriers = Carrier.LIST),
+ @BodyType.When(option = "command",
value = "HMGET", carriers = Carrier.LIST) },
Review Comment:
These commands do not fall back to `unchanged`. The side has `dependsOn =
"command"`, so a command without an option body is not known:
`CatalogBodyTypes.answer` gives no answer, and the group test checks that for
GET.
There is no carrier to name for them either. GET and the other commands that
read one value give the stored object as it is, which with the default JDK
serializer is whatever the `CamelRedis.Value` header held. So f8509b32a56d
names them in the description instead: "the stored object, which can be
anything, for GET, HGET, LINDEX, LPOP, RPOP, SPOP and the other commands that
read or pop one value: these are not known".
_Claude Code on behalf of davsclaus_
##########
components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseEndpoint.java:
##########
@@ -63,6 +66,26 @@
*/
@UriEndpoint(firstVersion = "2.19.0", scheme = "couchbase", title =
"Couchbase", syntax = "couchbase:protocol://hostname:port",
category = { Category.DATABASE }, headersClass =
CouchbaseConstants.class)
+@BodyTypes(consumerOut = @BodyType(value = Carrier.POJO, javaType =
"com.couchbase.client.java.kv.GetResult",
+ byOption = {
+ @BodyType.When(option =
"fullDocument", value = "false", carriers = Carrier.TEXT,
+ javaType =
"java.lang.String"),
+ @BodyType.When(option = "useView",
value = "true", carriers = Carrier.POJO,
+ javaType =
"com.couchbase.client.java.kv.GetResult") },
+ description = "One message per document the
query finds, read by its id (the"
+ + " CamelCouchbaseId header)
as the GetResult of the Couchbase SDK:"
+ + " contentAsObject() gives
the JSON document. With fullDocument=false the row"
+ + " of the SQL++ query as
JSON text, or with useView=true the value the view"
+ + " emits"),
+ producerIn = @BodyType(value = { Carrier.TEXT, Carrier.MAP,
Carrier.LIST, Carrier.POJO }, dependsOn = "operation",
+ description = "The document that CCB_PUT,
the default, stores as JSON: a Map, a List or a"
+ + " POJO becomes JSON, and
text is stored as a JSON string, so unmarshal JSON"
+ + " text first. Bytes, a
stream or no body fail. CCB_GET and CCB_DEL do not use"
+ + " the body: the id is the
CamelCouchbaseId header"),
+ producerOut = @BodyType(value = Carrier.VALUE, javaType =
"java.lang.Boolean", dependsOn = "operation",
Review Comment:
Added in f8509b32a56d: CCB_GET gives the `GetResult` of the SDK and CCB_DEL
the `MutationResult` as text. The group test now reads a field after each: it
is reported after CCB_DEL (text) and not after CCB_GET.
One correction to the premise: the other operations did not fall back to the
Boolean. The side has `dependsOn = "operation"`, so for a value without an
option body the validator gives no answer (`CatalogBodyTypes.answer`), and
`camel_catalog_doc` says "Not known when operation is set". The `operation`
option is still a free String. CAMEL-26020 proposes its values as an enum, and
then the build checks these values too.
_Claude Code on behalf of davsclaus_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]