Class ProfilePictureInfo


  • public class ProfilePictureInfo
    extends java.lang.Object
    Class holding profile picture information.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Comparator<ProfilePictureInfo> LARGEST_FIRST
      Sort instance to get the largest images first.
    • Constructor Summary

      Constructors 
      Constructor Description
      ProfilePictureInfo​(java.lang.String url, java.lang.String mediaType)
      Constructor for image when size is unknown.
      ProfilePictureInfo​(java.lang.String url, java.lang.String mediaType, int width, int height)
      Constructor.
      ProfilePictureInfo​(java.net.URL url, java.lang.String mediaType, int width, int height)
      Constructor.
    • Field Detail

      • LARGEST_FIRST

        public static java.util.Comparator<ProfilePictureInfo> LARGEST_FIRST
        Sort instance to get the largest images first. Images without size are always last.
    • Constructor Detail

      • ProfilePictureInfo

        public ProfilePictureInfo​(java.lang.String url,
                                  java.lang.String mediaType)
                           throws java.net.MalformedURLException
        Constructor for image when size is unknown.
        Parameters:
        url - The URL to the profile picture.
        mediaType - The media type, e.g. 'image/jpeg'.
        Throws:
        java.lang.NullPointerException - If url or mediaType is null.
        java.net.MalformedURLException - If the url is malformed.
      • ProfilePictureInfo

        public ProfilePictureInfo​(java.lang.String url,
                                  java.lang.String mediaType,
                                  int width,
                                  int height)
                           throws java.net.MalformedURLException
        Constructor.
        Parameters:
        url - The URL to the profile picture.
        mediaType - The media type, e.g. 'image/jpeg'.
        width - The width of the image, zero/negative if unknown.
        height - The height of the image, zero/negative if unknown.
        Throws:
        java.lang.NullPointerException - If url or mediaType is null.
        java.net.MalformedURLException - If the url is malformed.
      • ProfilePictureInfo

        public ProfilePictureInfo​(java.net.URL url,
                                  java.lang.String mediaType,
                                  int width,
                                  int height)
        Constructor.
        Parameters:
        url - The URL to the profile picture.
        mediaType - The media type, e.g. 'image/jpeg'.
        width - The width of the image, zero/negative if unknown.
        height - The height of the image, zero/negative if unknown.
        Throws:
        java.lang.NullPointerException - If url or mediaType is null.
    • Method Detail

      • sortLargestFirst

        public static ProfilePictureInfo[] sortLargestFirst​(ProfilePictureInfo[] images)
        Sorts the array of ProfilePictureInfo's so that the largest ones comes first. Images without size are always last.
        Parameters:
        images - The array of ProfilePictureInfo's, if null, sorting will not be done and a NullPointerException is NOT thrown.
        Returns:
        The SAME INSTANCE as the input, sorting is done in-place, null if images is null.
      • getURL

        public java.net.URL getURL()
        Gets the URL to the profile picture.
        Returns:
        The URL, never null, e.g. "https://..cdn.com/dms/image/..?e=..".
      • getMediaType

        public java.lang.String getMediaType()
        Gets the media type, e.g. 'image/jpeg'.
        Returns:
        The media type, never null.
      • getWidth

        public int getWidth()
        Gets the width of the profile picture.

        If either width or height is unknown, -1 is returned.

        Returns:
        The width, or -1 if unknown (never zero).
      • getHeight

        public int getHeight()
        Gets the height of the profile picture.

        If either width or height is unknown, -1 is returned.

        Returns:
        The height, or -1 if unknown (never zero).
      • hashCode

        public int hashCode()
        Gets the hash code of this instance.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        The hash code.
      • equals

        public boolean equals​(java.lang.Object obj)
        Checks if two objects are equal.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - The other object to compare with.
        Returns:
        The equality flag.
      • toString

        public java.lang.String toString()
        Gets a String.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The string as "[[width x height,]mediaType,url]".