Skip to content

Commit

Permalink
Use @JsonGen annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Nov 30, 2023
1 parent a76d604 commit b50cf9e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ public class MongoAuthenticationOptionsConverter {
private static final Base64.Decoder BASE64_DECODER = JsonUtil.BASE64_DECODER;
private static final Base64.Encoder BASE64_ENCODER = JsonUtil.BASE64_ENCODER;

public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, MongoAuthenticationOptions obj) {
static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, MongoAuthenticationOptions obj) {
for (java.util.Map.Entry<String, Object> member : json) {
switch (member.getKey()) {
case "collectionName":
if (member.getValue() instanceof String) {
obj.setCollectionName((String)member.getValue());
}
break;
case "passwordCredentialField":
case "usernameField":
if (member.getValue() instanceof String) {
obj.setPasswordCredentialField((String)member.getValue());
obj.setUsernameField((String)member.getValue());
}
break;
case "passwordField":
Expand All @@ -40,34 +40,34 @@ public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json,
obj.setUsernameCredentialField((String)member.getValue());
}
break;
case "usernameField":
case "passwordCredentialField":
if (member.getValue() instanceof String) {
obj.setUsernameField((String)member.getValue());
obj.setPasswordCredentialField((String)member.getValue());
}
break;
}
}
}

public static void toJson(MongoAuthenticationOptions obj, JsonObject json) {
static void toJson(MongoAuthenticationOptions obj, JsonObject json) {
toJson(obj, json.getMap());
}

public static void toJson(MongoAuthenticationOptions obj, java.util.Map<String, Object> json) {
static void toJson(MongoAuthenticationOptions obj, java.util.Map<String, Object> json) {
if (obj.getCollectionName() != null) {
json.put("collectionName", obj.getCollectionName());
}
if (obj.getPasswordCredentialField() != null) {
json.put("passwordCredentialField", obj.getPasswordCredentialField());
if (obj.getUsernameField() != null) {
json.put("usernameField", obj.getUsernameField());
}
if (obj.getPasswordField() != null) {
json.put("passwordField", obj.getPasswordField());
}
if (obj.getUsernameCredentialField() != null) {
json.put("usernameCredentialField", obj.getUsernameCredentialField());
}
if (obj.getUsernameField() != null) {
json.put("usernameField", obj.getUsernameField());
if (obj.getPasswordCredentialField() != null) {
json.put("passwordCredentialField", obj.getPasswordCredentialField());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,49 @@ public class MongoAuthorizationOptionsConverter {
private static final Base64.Decoder BASE64_DECODER = JsonUtil.BASE64_DECODER;
private static final Base64.Encoder BASE64_ENCODER = JsonUtil.BASE64_ENCODER;

public static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, MongoAuthorizationOptions obj) {
static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, MongoAuthorizationOptions obj) {
for (java.util.Map.Entry<String, Object> member : json) {
switch (member.getKey()) {
case "collectionName":
if (member.getValue() instanceof String) {
obj.setCollectionName((String)member.getValue());
}
break;
case "permissionField":
case "usernameField":
if (member.getValue() instanceof String) {
obj.setPermissionField((String)member.getValue());
obj.setUsernameField((String)member.getValue());
}
break;
case "roleField":
if (member.getValue() instanceof String) {
obj.setRoleField((String)member.getValue());
}
break;
case "usernameField":
case "permissionField":
if (member.getValue() instanceof String) {
obj.setUsernameField((String)member.getValue());
obj.setPermissionField((String)member.getValue());
}
break;
}
}
}

public static void toJson(MongoAuthorizationOptions obj, JsonObject json) {
static void toJson(MongoAuthorizationOptions obj, JsonObject json) {
toJson(obj, json.getMap());
}

public static void toJson(MongoAuthorizationOptions obj, java.util.Map<String, Object> json) {
static void toJson(MongoAuthorizationOptions obj, java.util.Map<String, Object> json) {
if (obj.getCollectionName() != null) {
json.put("collectionName", obj.getCollectionName());
}
if (obj.getPermissionField() != null) {
json.put("permissionField", obj.getPermissionField());
if (obj.getUsernameField() != null) {
json.put("usernameField", obj.getUsernameField());
}
if (obj.getRoleField() != null) {
json.put("roleField", obj.getRoleField());
}
if (obj.getUsernameField() != null) {
json.put("usernameField", obj.getUsernameField());
if (obj.getPermissionField() != null) {
json.put("permissionField", obj.getPermissionField());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.vertx.ext.auth.mongo;

import io.vertx.codegen.annotations.DataObject;
import io.vertx.codegen.json.annotations.JsonGen;
import io.vertx.core.json.JsonObject;

/**
Expand All @@ -24,7 +25,8 @@
* @author francoisprunier
*
*/
@DataObject(generateConverter = true)
@DataObject
@JsonGen(publicConverter = false)
public class MongoAuthenticationOptions {

private String collectionName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.vertx.ext.auth.mongo;

import io.vertx.codegen.annotations.DataObject;
import io.vertx.codegen.json.annotations.JsonGen;
import io.vertx.core.json.JsonObject;

/**
Expand All @@ -24,7 +25,8 @@
* @author francoisprunier
*
*/
@DataObject(generateConverter = true)
@DataObject
@JsonGen(publicConverter = false)
public class MongoAuthorizationOptions {

private String collectionName;
Expand Down

0 comments on commit b50cf9e

Please sign in to comment.