Package eirb.pub.app.server.utils
Record Class ServerUser
java.lang.Object
java.lang.Record
eirb.pub.app.server.utils.ServerUser
-
Constructor Summary
ConstructorsConstructorDescriptionServerUser(UUID uuid, String email, String name, PublicKey publicKey) Creates an instance of aServerUserrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic ServerUserbyEmail(String email, ServerAuthentication sa) Retrieve a user based on its emailstatic ServerUserbyID(UUID uuid, ServerAuthentication sa) Retrieve a user based on its idemail()Returns the value of theemailrecord component.booleanIndicates whether some other object is "equal to" this one.static ServerUserfromJSON(org.json.JSONObject response) Parse a JSON response to get a ServerUserfinal inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.Returns the value of thepublicKeyrecord component.final StringtoString()Returns a string representation of this record class.uuid()Returns the value of theuuidrecord component.
-
Constructor Details
-
ServerUser
Creates an instance of aServerUserrecord class.- Parameters:
uuid- the value for theuuidrecord componentemail- the value for theemailrecord componentname- the value for thenamerecord componentpublicKey- the value for thepublicKeyrecord component
-
-
Method Details
-
byID
public static ServerUser byID(UUID uuid, ServerAuthentication sa) throws ServerException, IOException, TimeoutException Retrieve a user based on its id- Parameters:
uuid- uuid of the desired usersa- ServerAuthentication to fetch information- Returns:
- the serverUser linked to this id
- Throws:
AuthenticationException- if the authentication failedTimeoutException- if the request took too much time to completeIOException- the connection failed during the processServerException
-
byEmail
public static ServerUser byEmail(String email, ServerAuthentication sa) throws ServerException, IOException, TimeoutException Retrieve a user based on its email- Parameters:
email- email of the desired usersa- ServerAuthentication to fetch information- Returns:
- the serverUser linked to this email
- Throws:
AuthenticationException- if the authentication failedTimeoutException- if the request took too much time to completeIOException- the connection failed during the processServerException
-
fromJSON
Parse a JSON response to get a ServerUser- Parameters:
response- response of the server- Returns:
- ServerUser represented by the jsonObject
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
uuid
Returns the value of theuuidrecord component.- Returns:
- the value of the
uuidrecord component
-
email
Returns the value of theemailrecord component.- Returns:
- the value of the
emailrecord component
-
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
publicKey
Returns the value of thepublicKeyrecord component.- Returns:
- the value of the
publicKeyrecord component
-