pro.zackpollard.telegrambot.api.internal.chat.message.content.NewChatPhotoContentImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jtelegram-botapi Show documentation
Show all versions of jtelegram-botapi Show documentation
The Java Telegram Bot API is a wrapper for the Telegram HTTP Bot API
package pro.zackpollard.telegrambot.api.internal.chat.message.content;
import org.json.JSONArray;
import org.json.JSONObject;
import pro.zackpollard.telegrambot.api.chat.message.content.NewChatPhotoContent;
import pro.zackpollard.telegrambot.api.chat.message.content.type.PhotoSize;
import pro.zackpollard.telegrambot.api.internal.chat.message.content.type.PhotoSizeImpl;
import java.util.ArrayList;
import java.util.List;
/**
* @author Zack Pollard
*/
public class NewChatPhotoContentImpl implements NewChatPhotoContent {
private final PhotoSize[] content;
private NewChatPhotoContentImpl(JSONArray jsonArray) {
List photoSizeList = new ArrayList<>();
for (int i = 0; i < jsonArray.length(); ++i) {
JSONObject photoObject = jsonArray.getJSONObject(i);
photoSizeList.add(PhotoSizeImpl.createPhotoSize(photoObject));
}
content = photoSizeList.stream()
.toArray(PhotoSize[]::new);
}
public static NewChatPhotoContent createNewChatPhotoContent(JSONArray jsonArray) {
return new NewChatPhotoContentImpl(jsonArray);
}
/**
* Gets the new photo for the chat
*
* @return The new photo.
*/
@Override
public PhotoSize[] getContent() {
return content;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy