All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.raysha.lib.telegram.bot.api.model.ChatId Maven / Gradle / Ivy

Go to download

This is an java library for the Telegram-Bot-API. The Bot-API is an HTTP-based interface created for developers keen on building bots for Telegram.

There is a newer version: 2.1
Show newest version
package de.raysha.lib.telegram.bot.api.model;

/**
 * This object represents a chat. A chatId contains a String or an Integer as Identifier.
 */
public class ChatId {
    private String sId;
    private Integer iId;

    public ChatId(Object id) {
        checkId(id);

        if(id instanceof String){
            this.sId = (String)id;
        }else if(id instanceof Integer){
            this.iId = (Integer)id;
        }else{
            throw new IllegalArgumentException("The id must be either a String or a Intger!");
        }
    }

    public ChatId(String id) {
        checkId(id);

        this.sId = id;
        this.iId = null;
    }

    public ChatId(Integer id) {
        checkId(id);

        this.iId = id;
        this.sId = null;
    }

    private void checkId(Object id) {
        if(id == null) throw new IllegalArgumentException("The id must not be null!");
    }

    public Object getId(){
        if(sId != null) return sId;
        return iId;
    }

    public String getsId() {
        return sId;
    }

    public Integer getiId() {
        return iId;
    }

    @Override
    public String toString() {
        return "" + getId();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy