-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
594 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
216 changes: 216 additions & 0 deletions
216
src/main/java/com/easemob/im/api/model/EMBatchCustomGroupMemberAttribute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
/* | ||
* EMService | ||
* Easemob Rest API | ||
* | ||
* The version of the OpenAPI document: 1.0.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
|
||
package com.easemob.im.api.model; | ||
|
||
import com.easemob.im.JSON; | ||
import com.google.gson.*; | ||
import com.google.gson.annotations.SerializedName; | ||
import com.google.gson.reflect.TypeToken; | ||
import com.google.gson.stream.JsonReader; | ||
import com.google.gson.stream.JsonWriter; | ||
|
||
import java.io.IOException; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
/** | ||
* EMBatchCustomGroupMemberAttribute | ||
*/ | ||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-11-20T11:16:55.650302+08:00[Asia/Shanghai]") | ||
public class EMBatchCustomGroupMemberAttribute { | ||
public static final String SERIALIZED_NAME_USERNAME = "username"; | ||
@SerializedName(SERIALIZED_NAME_USERNAME) | ||
private String username; | ||
|
||
public static final String SERIALIZED_NAME_METADATA = "metadata"; | ||
@SerializedName(SERIALIZED_NAME_METADATA) | ||
private Object metadata; | ||
|
||
public EMBatchCustomGroupMemberAttribute() { | ||
} | ||
|
||
public EMBatchCustomGroupMemberAttribute username(String username) { | ||
|
||
this.username = username; | ||
return this; | ||
} | ||
|
||
/** | ||
* 用户 ID,长度不可超过 64 字节 | ||
* @return username | ||
**/ | ||
@javax.annotation.Nullable | ||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
|
||
public void setUsername(String username) { | ||
this.username = username; | ||
} | ||
|
||
|
||
public EMBatchCustomGroupMemberAttribute metadata(Object metadata) { | ||
|
||
this.metadata = metadata; | ||
return this; | ||
} | ||
|
||
/** | ||
* 要设置的群成员自定义属性,为 key-value 键值对。对于单个键值对: - key 表示属性名称,不能超过 16 字节。 - value 表示属性值,不能超过 512 个字节。若 value 设置为空字符串即删除该自定义属性。 单个群成员的自定义属性总长度不能超过 4 KB | ||
* @return metadata | ||
**/ | ||
@javax.annotation.Nullable | ||
public Object getMetadata() { | ||
return metadata; | ||
} | ||
|
||
|
||
public void setMetadata(Object metadata) { | ||
this.metadata = metadata; | ||
} | ||
|
||
|
||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
EMBatchCustomGroupMemberAttribute batchCustomGroupMemberAttribute = (EMBatchCustomGroupMemberAttribute) o; | ||
return Objects.equals(this.username, batchCustomGroupMemberAttribute.username) && | ||
Objects.equals(this.metadata, batchCustomGroupMemberAttribute.metadata); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(username, metadata); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("class EMBatchCustomGroupMemberAttribute {\n"); | ||
sb.append(" username: ").append(toIndentedString(username)).append("\n"); | ||
sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); | ||
sb.append("}"); | ||
return sb.toString(); | ||
} | ||
|
||
/** | ||
* Convert the given object to string with each line indented by 4 spaces | ||
* (except the first line). | ||
*/ | ||
private String toIndentedString(Object o) { | ||
if (o == null) { | ||
return "null"; | ||
} | ||
return o.toString().replace("\n", "\n "); | ||
} | ||
|
||
|
||
public static HashSet<String> openapiFields; | ||
public static HashSet<String> openapiRequiredFields; | ||
|
||
static { | ||
// a set of all properties/fields (JSON key names) | ||
openapiFields = new HashSet<String>(); | ||
openapiFields.add("username"); | ||
openapiFields.add("metadata"); | ||
|
||
// a set of required properties/fields (JSON key names) | ||
openapiRequiredFields = new HashSet<String>(); | ||
} | ||
|
||
/** | ||
* Validates the JSON Element and throws an exception if issues found | ||
* | ||
* @param jsonElement JSON Element | ||
* @throws IOException if the JSON Element is invalid with respect to EMBatchCustomGroupMemberAttribute | ||
*/ | ||
public static void validateJsonElement(JsonElement jsonElement) throws IOException { | ||
if (jsonElement == null) { | ||
if (!EMBatchCustomGroupMemberAttribute.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null | ||
throw new IllegalArgumentException(String.format("The required field(s) %s in EMBatchCustomGroupMemberAttribute is not found in the empty JSON string", EMBatchCustomGroupMemberAttribute.openapiRequiredFields.toString())); | ||
} | ||
} | ||
|
||
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet(); | ||
// check to see if the JSON string contains additional fields | ||
for (Map.Entry<String, JsonElement> entry : entries) { | ||
if (!EMBatchCustomGroupMemberAttribute.openapiFields.contains(entry.getKey())) { | ||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EMBatchCustomGroupMemberAttribute` properties. JSON: %s", entry.getKey(), jsonElement.toString())); | ||
} | ||
} | ||
JsonObject jsonObj = jsonElement.getAsJsonObject(); | ||
if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { | ||
throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); | ||
} | ||
} | ||
|
||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory { | ||
@SuppressWarnings("unchecked") | ||
@Override | ||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { | ||
if (!EMBatchCustomGroupMemberAttribute.class.isAssignableFrom(type.getRawType())) { | ||
return null; // this class only serializes 'EMBatchCustomGroupMemberAttribute' and its subtypes | ||
} | ||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class); | ||
final TypeAdapter<EMBatchCustomGroupMemberAttribute> thisAdapter | ||
= gson.getDelegateAdapter(this, TypeToken.get(EMBatchCustomGroupMemberAttribute.class)); | ||
|
||
return (TypeAdapter<T>) new TypeAdapter<EMBatchCustomGroupMemberAttribute>() { | ||
@Override | ||
public void write(JsonWriter out, EMBatchCustomGroupMemberAttribute value) throws IOException { | ||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); | ||
elementAdapter.write(out, obj); | ||
} | ||
|
||
@Override | ||
public EMBatchCustomGroupMemberAttribute read(JsonReader in) throws IOException { | ||
JsonElement jsonElement = elementAdapter.read(in); | ||
validateJsonElement(jsonElement); | ||
return thisAdapter.fromJsonTree(jsonElement); | ||
} | ||
|
||
}.nullSafe(); | ||
} | ||
} | ||
|
||
/** | ||
* Create an instance of EMBatchCustomGroupMemberAttribute given an JSON string | ||
* | ||
* @param jsonString JSON string | ||
* @return An instance of EMBatchCustomGroupMemberAttribute | ||
* @throws IOException if the JSON string is invalid with respect to EMBatchCustomGroupMemberAttribute | ||
*/ | ||
public static EMBatchCustomGroupMemberAttribute fromJson(String jsonString) throws IOException { | ||
return JSON.getGson().fromJson(jsonString, EMBatchCustomGroupMemberAttribute.class); | ||
} | ||
|
||
/** | ||
* Convert an instance of EMBatchCustomGroupMemberAttribute to an JSON string | ||
* | ||
* @return JSON string | ||
*/ | ||
public String toJson() { | ||
return JSON.getGson().toJson(this); | ||
} | ||
} | ||
|
Oops, something went wrong.