Skip to content

Commit

Permalink
Update to vertx builder changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Nov 20, 2023
1 parent 146689d commit 8f4cf05
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,34 @@ public class ClusterDescriptionConverter {
public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, ClusterDescription obj) {
for (java.util.Map.Entry<String, Object> member : json) {
switch (member.getKey()) {
case "authorizedOperations":
case "nodes":
if (member.getValue() instanceof JsonArray) {
java.util.LinkedHashSet<org.apache.kafka.common.acl.AclOperation> list = new java.util.LinkedHashSet<>();
java.util.ArrayList<io.vertx.kafka.client.common.Node> list = new java.util.ArrayList<>();
((Iterable<Object>)member.getValue()).forEach( item -> {
if (item instanceof String)
list.add(org.apache.kafka.common.acl.AclOperation.valueOf((String)item));
if (item instanceof JsonObject)
list.add(new io.vertx.kafka.client.common.Node((io.vertx.core.json.JsonObject)item));
});
obj.setAuthorizedOperations(list);
}
break;
case "clusterId":
if (member.getValue() instanceof String) {
obj.setClusterId((String)member.getValue());
obj.setNodes(list);
}
break;
case "controller":
if (member.getValue() instanceof JsonObject) {
obj.setController(new io.vertx.kafka.client.common.Node((io.vertx.core.json.JsonObject)member.getValue()));
}
break;
case "nodes":
case "clusterId":
if (member.getValue() instanceof String) {
obj.setClusterId((String)member.getValue());
}
break;
case "authorizedOperations":
if (member.getValue() instanceof JsonArray) {
java.util.ArrayList<io.vertx.kafka.client.common.Node> list = new java.util.ArrayList<>();
java.util.LinkedHashSet<org.apache.kafka.common.acl.AclOperation> list = new java.util.LinkedHashSet<>();
((Iterable<Object>)member.getValue()).forEach( item -> {
if (item instanceof JsonObject)
list.add(new io.vertx.kafka.client.common.Node((io.vertx.core.json.JsonObject)item));
if (item instanceof String)
list.add(org.apache.kafka.common.acl.AclOperation.valueOf((String)item));
});
obj.setNodes(list);
obj.setAuthorizedOperations(list);
}
break;
}
Expand All @@ -59,21 +59,21 @@ public static void toJson(ClusterDescription obj, JsonObject json) {
}

public static void toJson(ClusterDescription obj, java.util.Map<String, Object> json) {
if (obj.getAuthorizedOperations() != null) {
if (obj.getNodes() != null) {
JsonArray array = new JsonArray();
obj.getAuthorizedOperations().forEach(item -> array.add(item.name()));
json.put("authorizedOperations", array);
}
if (obj.getClusterId() != null) {
json.put("clusterId", obj.getClusterId());
obj.getNodes().forEach(item -> array.add(item.toJson()));
json.put("nodes", array);
}
if (obj.getController() != null) {
json.put("controller", obj.getController().toJson());
}
if (obj.getNodes() != null) {
if (obj.getClusterId() != null) {
json.put("clusterId", obj.getClusterId());
}
if (obj.getAuthorizedOperations() != null) {
JsonArray array = new JsonArray();
obj.getNodes().forEach(item -> array.add(item.toJson()));
json.put("nodes", array);
obj.getAuthorizedOperations().forEach(item -> array.add(item.name()));
json.put("authorizedOperations", array);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ public class ConfigEntryConverter {
public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, ConfigEntry obj) {
for (java.util.Map.Entry<String, Object> member : json) {
switch (member.getKey()) {
case "default":
if (member.getValue() instanceof Boolean) {
obj.setDefault((Boolean)member.getValue());
}
break;
case "name":
if (member.getValue() instanceof String) {
obj.setName((String)member.getValue());
}
break;
case "default":
if (member.getValue() instanceof Boolean) {
obj.setDefault((Boolean)member.getValue());
}
break;
case "readOnly":
if (member.getValue() instanceof Boolean) {
obj.setReadOnly((Boolean)member.getValue());
Expand Down Expand Up @@ -69,10 +69,10 @@ public static void toJson(ConfigEntry obj, JsonObject json) {
}

public static void toJson(ConfigEntry obj, java.util.Map<String, Object> json) {
json.put("default", obj.isDefault());
if (obj.getName() != null) {
json.put("name", obj.getName());
}
json.put("default", obj.isDefault());
json.put("readOnly", obj.isReadOnly());
json.put("sensitive", obj.isSensitive());
if (obj.getSource() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json,
obj.setName((String)member.getValue());
}
break;
case "source":
case "value":
if (member.getValue() instanceof String) {
obj.setSource(org.apache.kafka.clients.admin.ConfigEntry.ConfigSource.valueOf((String)member.getValue()));
obj.setValue((String)member.getValue());
}
break;
case "value":
case "source":
if (member.getValue() instanceof String) {
obj.setValue((String)member.getValue());
obj.setSource(org.apache.kafka.clients.admin.ConfigEntry.ConfigSource.valueOf((String)member.getValue()));
}
break;
}
Expand All @@ -47,11 +47,11 @@ public static void toJson(ConfigSynonym obj, java.util.Map<String, Object> json)
if (obj.getName() != null) {
json.put("name", obj.getName());
}
if (obj.getSource() != null) {
json.put("source", obj.getSource().name());
}
if (obj.getValue() != null) {
json.put("value", obj.getValue());
}
if (obj.getSource() != null) {
json.put("source", obj.getSource().name());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,21 @@ public class ConsumerGroupDescriptionConverter {
public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, ConsumerGroupDescription obj) {
for (java.util.Map.Entry<String, Object> member : json) {
switch (member.getKey()) {
case "authorizedOperations":
if (member.getValue() instanceof JsonArray) {
java.util.LinkedHashSet<org.apache.kafka.common.acl.AclOperation> list = new java.util.LinkedHashSet<>();
((Iterable<Object>)member.getValue()).forEach( item -> {
if (item instanceof String)
list.add(org.apache.kafka.common.acl.AclOperation.valueOf((String)item));
});
obj.setAuthorizedOperations(list);
case "groupId":
if (member.getValue() instanceof String) {
obj.setGroupId((String)member.getValue());
}
break;
case "simpleConsumerGroup":
if (member.getValue() instanceof Boolean) {
obj.setSimpleConsumerGroup((Boolean)member.getValue());
}
break;
case "coordinator":
if (member.getValue() instanceof JsonObject) {
obj.setCoordinator(new io.vertx.kafka.client.common.Node((io.vertx.core.json.JsonObject)member.getValue()));
}
break;
case "groupId":
if (member.getValue() instanceof String) {
obj.setGroupId((String)member.getValue());
}
break;
case "members":
if (member.getValue() instanceof JsonArray) {
java.util.ArrayList<io.vertx.kafka.admin.MemberDescription> list = new java.util.ArrayList<>();
Expand All @@ -55,16 +50,21 @@ public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json,
obj.setPartitionAssignor((String)member.getValue());
}
break;
case "simpleConsumerGroup":
if (member.getValue() instanceof Boolean) {
obj.setSimpleConsumerGroup((Boolean)member.getValue());
}
break;
case "state":
if (member.getValue() instanceof String) {
obj.setState(org.apache.kafka.common.ConsumerGroupState.valueOf((String)member.getValue()));
}
break;
case "authorizedOperations":
if (member.getValue() instanceof JsonArray) {
java.util.LinkedHashSet<org.apache.kafka.common.acl.AclOperation> list = new java.util.LinkedHashSet<>();
((Iterable<Object>)member.getValue()).forEach( item -> {
if (item instanceof String)
list.add(org.apache.kafka.common.acl.AclOperation.valueOf((String)item));
});
obj.setAuthorizedOperations(list);
}
break;
}
}
}
Expand All @@ -74,17 +74,13 @@ public static void toJson(ConsumerGroupDescription obj, JsonObject json) {
}

public static void toJson(ConsumerGroupDescription obj, java.util.Map<String, Object> json) {
if (obj.getAuthorizedOperations() != null) {
JsonArray array = new JsonArray();
obj.getAuthorizedOperations().forEach(item -> array.add(item.name()));
json.put("authorizedOperations", array);
if (obj.getGroupId() != null) {
json.put("groupId", obj.getGroupId());
}
json.put("simpleConsumerGroup", obj.isSimpleConsumerGroup());
if (obj.getCoordinator() != null) {
json.put("coordinator", obj.getCoordinator().toJson());
}
if (obj.getGroupId() != null) {
json.put("groupId", obj.getGroupId());
}
if (obj.getMembers() != null) {
JsonArray array = new JsonArray();
obj.getMembers().forEach(item -> array.add(item.toJson()));
Expand All @@ -93,9 +89,13 @@ public static void toJson(ConsumerGroupDescription obj, java.util.Map<String, Ob
if (obj.getPartitionAssignor() != null) {
json.put("partitionAssignor", obj.getPartitionAssignor());
}
json.put("simpleConsumerGroup", obj.isSimpleConsumerGroup());
if (obj.getState() != null) {
json.put("state", obj.getState().name());
}
if (obj.getAuthorizedOperations() != null) {
JsonArray array = new JsonArray();
obj.getAuthorizedOperations().forEach(item -> array.add(item.name()));
json.put("authorizedOperations", array);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ public class ListOffsetsResultInfoConverter {
public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, ListOffsetsResultInfo obj) {
for (java.util.Map.Entry<String, Object> member : json) {
switch (member.getKey()) {
case "leaderEpoch":
if (member.getValue() instanceof Number) {
obj.setLeaderEpoch(((Number)member.getValue()).intValue());
}
break;
case "offset":
if (member.getValue() instanceof Number) {
obj.setOffset(((Number)member.getValue()).longValue());
Expand All @@ -35,6 +30,11 @@ public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json,
obj.setTimestamp(((Number)member.getValue()).longValue());
}
break;
case "leaderEpoch":
if (member.getValue() instanceof Number) {
obj.setLeaderEpoch(((Number)member.getValue()).intValue());
}
break;
}
}
}
Expand All @@ -44,10 +44,10 @@ public static void toJson(ListOffsetsResultInfo obj, JsonObject json) {
}

public static void toJson(ListOffsetsResultInfo obj, java.util.Map<String, Object> json) {
json.put("offset", obj.getOffset());
json.put("timestamp", obj.getTimestamp());
if (obj.getLeaderEpoch() != null) {
json.put("leaderEpoch", obj.getLeaderEpoch());
}
json.put("offset", obj.getOffset());
json.put("timestamp", obj.getTimestamp());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ public class MemberDescriptionConverter {
public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, MemberDescription obj) {
for (java.util.Map.Entry<String, Object> member : json) {
switch (member.getKey()) {
case "assignment":
if (member.getValue() instanceof JsonObject) {
obj.setAssignment(new io.vertx.kafka.admin.MemberAssignment((io.vertx.core.json.JsonObject)member.getValue()));
case "consumerId":
if (member.getValue() instanceof String) {
obj.setConsumerId((String)member.getValue());
}
break;
case "clientId":
if (member.getValue() instanceof String) {
obj.setClientId((String)member.getValue());
}
break;
case "consumerId":
if (member.getValue() instanceof String) {
obj.setConsumerId((String)member.getValue());
case "assignment":
if (member.getValue() instanceof JsonObject) {
obj.setAssignment(new io.vertx.kafka.admin.MemberAssignment((io.vertx.core.json.JsonObject)member.getValue()));
}
break;
case "host":
Expand All @@ -49,14 +49,14 @@ public static void toJson(MemberDescription obj, JsonObject json) {
}

public static void toJson(MemberDescription obj, java.util.Map<String, Object> json) {
if (obj.getAssignment() != null) {
json.put("assignment", obj.getAssignment().toJson());
if (obj.getConsumerId() != null) {
json.put("consumerId", obj.getConsumerId());
}
if (obj.getClientId() != null) {
json.put("clientId", obj.getClientId());
}
if (obj.getConsumerId() != null) {
json.put("consumerId", obj.getConsumerId());
if (obj.getAssignment() != null) {
json.put("assignment", obj.getAssignment().toJson());
}
if (obj.getHost() != null) {
json.put("host", obj.getHost());
Expand Down
30 changes: 15 additions & 15 deletions src/main/generated/io/vertx/kafka/admin/NewTopicConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ public class NewTopicConverter {
public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, NewTopic obj) {
for (java.util.Map.Entry<String, Object> member : json) {
switch (member.getKey()) {
case "config":
if (member.getValue() instanceof JsonObject) {
java.util.Map<String, java.lang.String> map = new java.util.LinkedHashMap<>();
((Iterable<java.util.Map.Entry<String, Object>>)member.getValue()).forEach(entry -> {
if (entry.getValue() instanceof String)
map.put(entry.getKey(), (String)entry.getValue());
});
obj.setConfig(map);
}
break;
case "name":
if (member.getValue() instanceof String) {
obj.setName((String)member.getValue());
Expand All @@ -45,6 +35,16 @@ public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json,
obj.setReplicationFactor(((Number)member.getValue()).shortValue());
}
break;
case "config":
if (member.getValue() instanceof JsonObject) {
java.util.Map<String, java.lang.String> map = new java.util.LinkedHashMap<>();
((Iterable<java.util.Map.Entry<String, Object>>)member.getValue()).forEach(entry -> {
if (entry.getValue() instanceof String)
map.put(entry.getKey(), (String)entry.getValue());
});
obj.setConfig(map);
}
break;
}
}
}
Expand All @@ -54,15 +54,15 @@ public static void toJson(NewTopic obj, JsonObject json) {
}

public static void toJson(NewTopic obj, java.util.Map<String, Object> json) {
if (obj.getConfig() != null) {
JsonObject map = new JsonObject();
obj.getConfig().forEach((key, value) -> map.put(key, value));
json.put("config", map);
}
if (obj.getName() != null) {
json.put("name", obj.getName());
}
json.put("numPartitions", obj.getNumPartitions());
json.put("replicationFactor", obj.getReplicationFactor());
if (obj.getConfig() != null) {
JsonObject map = new JsonObject();
obj.getConfig().forEach((key, value) -> map.put(key, value));
json.put("config", map);
}
}
}
Loading

0 comments on commit 8f4cf05

Please sign in to comment.