Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
Copyright 2020 Twitter, Inc.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
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.twitter.clientlib.model;
import java.util.Objects;
import java.util.Arrays;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.twitter.clientlib.model.CreateTweetRequestGeo;
import com.twitter.clientlib.model.CreateTweetRequestMedia;
import com.twitter.clientlib.model.CreateTweetRequestPoll;
import com.twitter.clientlib.model.CreateTweetRequestReply;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.twitter.clientlib.JSON;
/**
* CreateTweetRequest
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class CreateTweetRequest {
public static final String SERIALIZED_NAME_TEXT = "text";
@SerializedName(SERIALIZED_NAME_TEXT)
private String text;
public static final String SERIALIZED_NAME_DIRECT_MESSAGE_DEEP_LINK = "direct_message_deep_link";
@SerializedName(SERIALIZED_NAME_DIRECT_MESSAGE_DEEP_LINK)
private String directMessageDeepLink;
public static final String SERIALIZED_NAME_QUOTE_TWEET_ID = "quote_tweet_id";
@SerializedName(SERIALIZED_NAME_QUOTE_TWEET_ID)
private String quoteTweetId;
public static final String SERIALIZED_NAME_FOR_SUPER_FOLLOWERS_ONLY = "for_super_followers_only";
@SerializedName(SERIALIZED_NAME_FOR_SUPER_FOLLOWERS_ONLY)
private Boolean forSuperFollowersOnly;
public static final String SERIALIZED_NAME_REPLY = "reply";
@SerializedName(SERIALIZED_NAME_REPLY)
private CreateTweetRequestReply reply;
public static final String SERIALIZED_NAME_MEDIA = "media";
@SerializedName(SERIALIZED_NAME_MEDIA)
private CreateTweetRequestMedia media;
public static final String SERIALIZED_NAME_POLL = "poll";
@SerializedName(SERIALIZED_NAME_POLL)
private CreateTweetRequestPoll poll;
/**
* Settings to indicate who can reply to the Tweet.
*/
@JsonAdapter(ReplySettingsEnum.Adapter.class)
public enum ReplySettingsEnum {
FOLLOWING("following"),
MENTIONEDUSERS("mentionedUsers");
private String value;
ReplySettingsEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static ReplySettingsEnum fromValue(String value) {
for (ReplySettingsEnum b : ReplySettingsEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final ReplySettingsEnum enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public ReplySettingsEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return ReplySettingsEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_REPLY_SETTINGS = "reply_settings";
@SerializedName(SERIALIZED_NAME_REPLY_SETTINGS)
private ReplySettingsEnum replySettings;
public static final String SERIALIZED_NAME_GEO = "geo";
@SerializedName(SERIALIZED_NAME_GEO)
private CreateTweetRequestGeo geo;
public CreateTweetRequest() {
}
public CreateTweetRequest text(String text) {
this.text = text;
return this;
}
/**
* The content of the Tweet.
* @return text
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "Learn how to use the user Tweet timeline and user mention timeline endpoints in the Twitter API v2 to explore Tweet\\u2026 https://t.co/56a0vZUx7i", value = "The content of the Tweet.")
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public CreateTweetRequest directMessageDeepLink(String directMessageDeepLink) {
this.directMessageDeepLink = directMessageDeepLink;
return this;
}
/**
* Link to take the conversation from the public timeline to a private Direct Message.
* @return directMessageDeepLink
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Link to take the conversation from the public timeline to a private Direct Message.")
public String getDirectMessageDeepLink() {
return directMessageDeepLink;
}
public void setDirectMessageDeepLink(String directMessageDeepLink) {
this.directMessageDeepLink = directMessageDeepLink;
}
public CreateTweetRequest quoteTweetId(String quoteTweetId) {
this.quoteTweetId = quoteTweetId;
return this;
}
/**
* Unique identifier of this Tweet. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.
* @return quoteTweetId
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "1346889436626259968", value = "Unique identifier of this Tweet. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.")
public String getQuoteTweetId() {
return quoteTweetId;
}
public void setQuoteTweetId(String quoteTweetId) {
this.quoteTweetId = quoteTweetId;
}
public CreateTweetRequest forSuperFollowersOnly(Boolean forSuperFollowersOnly) {
this.forSuperFollowersOnly = forSuperFollowersOnly;
return this;
}
/**
* Exclusive Tweet for super followers.
* @return forSuperFollowersOnly
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Exclusive Tweet for super followers.")
public Boolean getForSuperFollowersOnly() {
return forSuperFollowersOnly;
}
public void setForSuperFollowersOnly(Boolean forSuperFollowersOnly) {
this.forSuperFollowersOnly = forSuperFollowersOnly;
}
public CreateTweetRequest reply(CreateTweetRequestReply reply) {
this.reply = reply;
return this;
}
/**
* Get reply
* @return reply
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
public CreateTweetRequestReply getReply() {
return reply;
}
public void setReply(CreateTweetRequestReply reply) {
this.reply = reply;
}
public CreateTweetRequest media(CreateTweetRequestMedia media) {
this.media = media;
return this;
}
/**
* Get media
* @return media
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
public CreateTweetRequestMedia getMedia() {
return media;
}
public void setMedia(CreateTweetRequestMedia media) {
this.media = media;
}
public CreateTweetRequest poll(CreateTweetRequestPoll poll) {
this.poll = poll;
return this;
}
/**
* Get poll
* @return poll
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
public CreateTweetRequestPoll getPoll() {
return poll;
}
public void setPoll(CreateTweetRequestPoll poll) {
this.poll = poll;
}
public CreateTweetRequest replySettings(ReplySettingsEnum replySettings) {
this.replySettings = replySettings;
return this;
}
/**
* Settings to indicate who can reply to the Tweet.
* @return replySettings
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Settings to indicate who can reply to the Tweet.")
public ReplySettingsEnum getReplySettings() {
return replySettings;
}
public void setReplySettings(ReplySettingsEnum replySettings) {
this.replySettings = replySettings;
}
public CreateTweetRequest geo(CreateTweetRequestGeo geo) {
this.geo = geo;
return this;
}
/**
* Get geo
* @return geo
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
public CreateTweetRequestGeo getGeo() {
return geo;
}
public void setGeo(CreateTweetRequestGeo geo) {
this.geo = geo;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CreateTweetRequest createTweetRequest = (CreateTweetRequest) o;
return Objects.equals(this.text, createTweetRequest.text) &&
Objects.equals(this.directMessageDeepLink, createTweetRequest.directMessageDeepLink) &&
Objects.equals(this.quoteTweetId, createTweetRequest.quoteTweetId) &&
Objects.equals(this.forSuperFollowersOnly, createTweetRequest.forSuperFollowersOnly) &&
Objects.equals(this.reply, createTweetRequest.reply) &&
Objects.equals(this.media, createTweetRequest.media) &&
Objects.equals(this.poll, createTweetRequest.poll) &&
Objects.equals(this.replySettings, createTweetRequest.replySettings) &&
Objects.equals(this.geo, createTweetRequest.geo);
}
@Override
public int hashCode() {
return Objects.hash(text, directMessageDeepLink, quoteTweetId, forSuperFollowersOnly, reply, media, poll, replySettings, geo);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CreateTweetRequest {\n");
sb.append(" text: ").append(toIndentedString(text)).append("\n");
sb.append(" directMessageDeepLink: ").append(toIndentedString(directMessageDeepLink)).append("\n");
sb.append(" quoteTweetId: ").append(toIndentedString(quoteTweetId)).append("\n");
sb.append(" forSuperFollowersOnly: ").append(toIndentedString(forSuperFollowersOnly)).append("\n");
sb.append(" reply: ").append(toIndentedString(reply)).append("\n");
sb.append(" media: ").append(toIndentedString(media)).append("\n");
sb.append(" poll: ").append(toIndentedString(poll)).append("\n");
sb.append(" replySettings: ").append(toIndentedString(replySettings)).append("\n");
sb.append(" geo: ").append(toIndentedString(geo)).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 openapiFields;
public static HashSet openapiRequiredFields;
static {
// a set of all properties/fields (JSON key names)
openapiFields = new HashSet();
openapiFields.add("text");
openapiFields.add("direct_message_deep_link");
openapiFields.add("quote_tweet_id");
openapiFields.add("for_super_followers_only");
openapiFields.add("reply");
openapiFields.add("media");
openapiFields.add("poll");
openapiFields.add("reply_settings");
openapiFields.add("geo");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
}
/**
* Validates the JSON Object and throws an exception if issues found
*
* @param jsonObj JSON Object
* @throws IOException if the JSON Object is invalid with respect to CreateTweetRequest
*/
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
if (jsonObj == null) {
if (CreateTweetRequest.openapiRequiredFields.isEmpty()) {
return;
} else { // has reuqired fields
throw new IllegalArgumentException(String.format("The required field(s) %s in CreateTweetRequest is not found in the empty JSON string", CreateTweetRequest.openapiRequiredFields.toString()));
}
}
Set> entries = jsonObj.entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!CreateTweetRequest.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateTweetRequest` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
}
}
// validate the optional field `reply`
if (jsonObj.getAsJsonObject("reply") != null) {
CreateTweetRequestReply.validateJsonObject(jsonObj.getAsJsonObject("reply"));
}
// validate the optional field `media`
if (jsonObj.getAsJsonObject("media") != null) {
CreateTweetRequestMedia.validateJsonObject(jsonObj.getAsJsonObject("media"));
}
// validate the optional field `poll`
if (jsonObj.getAsJsonObject("poll") != null) {
CreateTweetRequestPoll.validateJsonObject(jsonObj.getAsJsonObject("poll"));
}
// validate the optional field `geo`
if (jsonObj.getAsJsonObject("geo") != null) {
CreateTweetRequestGeo.validateJsonObject(jsonObj.getAsJsonObject("geo"));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!CreateTweetRequest.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'CreateTweetRequest' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(CreateTweetRequest.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, CreateTweetRequest value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public CreateTweetRequest read(JsonReader in) throws IOException {
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
validateJsonObject(jsonObj);
return thisAdapter.fromJsonTree(jsonObj);
}
}.nullSafe();
}
}
/**
* Create an instance of CreateTweetRequest given an JSON string
*
* @param jsonString JSON string
* @return An instance of CreateTweetRequest
* @throws IOException if the JSON string is invalid with respect to CreateTweetRequest
*/
public static CreateTweetRequest fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, CreateTweetRequest.class);
}
/**
* Convert an instance of CreateTweetRequest to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}