Class Icon

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Icon.IconType
      Supported image types for the Discord API.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Icon from​(byte[] data)
      Creates an Icon with the specified image data.
      static Icon from​(byte[] data, Icon.IconType type)
      Creates an Icon with the specified image data.
      static Icon from​(java.io.File file)
      Creates an Icon with the specified File.
      static Icon from​(java.io.File file, Icon.IconType type)
      Creates an Icon with the specified File.
      static Icon from​(java.io.InputStream stream)
      Creates an Icon with the specified InputStream.
      static Icon from​(java.io.InputStream stream, Icon.IconType type)
      Creates an Icon with the specified InputStream.
      java.lang.String getEncoding()
      The base64 encoded data for this Icon
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getEncoding

        @Nonnull
        public java.lang.String getEncoding()
        The base64 encoded data for this Icon
        Returns:
        String representation of the encoded data for this icon
      • from

        @Nonnull
        public static Icon from​(@Nonnull
                                java.io.File file)
                         throws java.io.IOException
        Creates an Icon with the specified File.
        We here read the specified File and forward the retrieved byte data to from(byte[], IconType).
        Parameters:
        file - An existing, not-null file.
        Returns:
        An Icon instance representing the specified File
        Throws:
        java.lang.IllegalArgumentException - if the provided file is null, does not exist, or has an unsupported extension
        java.io.IOException - if there is a problem while reading the file.
      • from

        @Nonnull
        public static Icon from​(@Nonnull
                                java.io.InputStream stream)
                         throws java.io.IOException
        Creates an Icon with the specified InputStream.
        We here read the specified InputStream and forward the retrieved byte data to from(byte[], IconType). This will use Icon.IconType.JPEG but discord is capable for interpreting other types correctly either way.
        Parameters:
        stream - A not-null InputStream.
        Returns:
        An Icon instance representing the specified InputStream
        Throws:
        java.lang.IllegalArgumentException - if the provided stream is null
        java.io.IOException - If the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.
      • from

        @Nonnull
        public static Icon from​(@Nonnull
                                byte[] data)
        Creates an Icon with the specified image data. This will use Icon.IconType.JPEG but discord is capable for interpreting other types correctly either way.
        Parameters:
        data - not-null image data bytes.
        Returns:
        An Icon instance representing the specified image data
        Throws:
        java.lang.IllegalArgumentException - if the provided data is null
      • from

        @Nonnull
        public static Icon from​(@Nonnull
                                java.io.File file,
                                @Nonnull
                                Icon.IconType type)
                         throws java.io.IOException
        Creates an Icon with the specified File.
        We here read the specified File and forward the retrieved byte data to from(byte[], IconType).
        Parameters:
        file - An existing, not-null file.
        type - The type of image
        Returns:
        An Icon instance representing the specified File
        Throws:
        java.lang.IllegalArgumentException - if the provided file is either null or does not exist
        java.io.IOException - if there is a problem while reading the file.
      • from

        @Nonnull
        public static Icon from​(@Nonnull
                                java.io.InputStream stream,
                                @Nonnull
                                Icon.IconType type)
                         throws java.io.IOException
        Creates an Icon with the specified InputStream.
        We here read the specified InputStream and forward the retrieved byte data to from(byte[], IconType).
        Parameters:
        stream - A not-null InputStream.
        type - The type of image
        Returns:
        An Icon instance representing the specified InputStream
        Throws:
        java.lang.IllegalArgumentException - if the provided stream is null
        java.io.IOException - If the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.
      • from

        @Nonnull
        public static Icon from​(@Nonnull
                                byte[] data,
                                @Nonnull
                                Icon.IconType type)
        Creates an Icon with the specified image data.
        Parameters:
        data - not-null image data bytes.
        type - The type of image
        Returns:
        An Icon instance representing the specified image data
        Throws:
        java.lang.IllegalArgumentException - if the provided data is null