Class GravatarQrCodeRequest
java.lang.Object
com.github.natche.gravatarjavaclient.avatar.GravatarQrCodeRequest
A request for a user's profile QR code from Gravatar.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether the provided object equals this request.static GravatarQrCodeRequestConstructs and returns a new GravatarQrCodeRequest.static GravatarQrCodeRequestConstructs and returns a new GravatarQrCodeRequest.Reads and returns aBufferedImageusing the URL constructed from the current state of this request.getHash()Returns the hash for this request.Returns the image type this request will use.Returns the URL for requesting the QR code based on the current state of this request.intgetSize()Returns the size of the image this request should return.Returns the QR code version this request will use.inthashCode()Returns a hashcode of this request.booleanSaves the QR code obtained from this to the provided file as a PNG.Sets the image type this request will use.setSize(int imageLength) Sets the length of the image this request should return.setVersion(GravatarQrImageVersion version) Sets the QR code version this request will use.toString()Returns a string representation of this request.
-
Method Details
-
fromEmail
Constructs and returns a new GravatarQrCodeRequest.- Parameters:
email- the email for this Gravatar QR code request- Throws:
NullPointerException- if the email is nullIllegalArgumentException- if the email is empty or not a valid email address
-
fromHash
Constructs and returns a new GravatarQrCodeRequest.- Parameters:
hash- the hash for this Gravatar QR code request- Throws:
NullPointerException- if the hash is nullIllegalArgumentException- if the hash is empty
-
getHash
Returns the hash for this request.- Returns:
- the hash for this request
-
setSize
Sets the length of the image this request should return.- Parameters:
imageLength- the length of the image this request should return- Returns:
- this builder
- Throws:
IllegalArgumentException- if the provided image length is not in the rangeIMAGE_LENGTH_RANGE
-
getSize
public int getSize()Returns the size of the image this request should return.- Returns:
- the size of the image this request should return
-
setImageType
Sets the image type this request will use. SeeGravatarQrImageType.- Parameters:
type- the image type- Returns:
- this builder
- Throws:
NullPointerException- if the provided type is null
-
getImageType
Returns the image type this request will use.- Returns:
- the image type this request will use
-
setVersion
Sets the QR code version this request will use.- Parameters:
version- the QR code version this request will use- Returns:
- this builder
- Throws:
NullPointerException- if the provided version is null
-
getVersion
Returns the QR code version this request will use.- Returns:
- the QR code version this request will use
-
getRequestUrl
Returns the URL for requesting the QR code based on the current state of this request.- Returns:
- the URL for requesting the QR code based on the current state of this request
-
getBufferedImage
Reads and returns aBufferedImageusing the URL constructed from the current state of this request.- Returns:
- a
BufferedImagerepresenting a QR code - Throws:
GravatarJavaClientException- if an exception occurs reading from the URL
-
saveTo
Saves the QR code obtained from this to the provided file as a PNG. Note: the API returns a PNG which is why encoding options are not allowed by this method.- Parameters:
saveTo- the file to save the QR code to as a PNG- Returns:
- whether the save operation was successful
- Throws:
NullPointerException- if the provided file is nullIllegalArgumentException- if the provided file references a directory or exists
-
hashCode
public int hashCode()Returns a hashcode of this request. -
toString
Returns a string representation of this request. -
equals
Returns whether the provided object equals this request.
-