Class Client
java.lang.Object
page.codeberg.friedolyn.configuration.client.Client
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe kind of client to use for the HTTP requests. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate @NonNull BooleanThe Do Not Track header indicates whether the user would prefer privacy rather than personalised content.private @NonNull BooleanThe Global Privacy Control header indicates whether the user consents to a website or service selling or sharing their personal information with third parties.private @NonNull Client.ClientKindThe kind of client to use for the HTTP requests.private @NonNull StringThe user agent to use for the HTTP client. -
Constructor Summary
ConstructorsModifierConstructorDescriptionClient()Creates a new client with the given user agent by callingsetUserAgent(String).privateClient(String userAgent, Boolean doNotTrack, Boolean globalPrivacyControl, String preferredClientKind) Creates a new client with the given user agent, Do Not Track and Global Privacy Control settings.Client(UserAgentManager.Client client, UserAgentManager.Platform platform) Creates a new client with the given user agent. -
Method Summary
Modifier and TypeMethodDescription@NonNull Clientcopy()booleanChecks whether the fields of this client are equal to the fields of another client.booleanChecks whether the fields of this client are equal to the default values, i.e.voidsetDoNotTrack(Boolean doNotTrack) Updates thedoNotTrackfield.voidsetGlobalPrivacyControl(Boolean globalPrivacyControl) Updates theglobalPrivacyControlfield.private voidsetNullableUserAgent(String userAgent) Deprecated.Only to be used by Jackson for deserialisation.private voidsetPreferredClientKind(String preferredClientKind) Deprecated.Only to be used by Jackson for deserialisation.voidsetPreferredClientKind(Client.ClientKind preferredClientKind) Updates thepreferredClientKindfield.voidsetUserAgent(@NonNull String userAgent) Updates theuserAgentfield with the given one.voidsetUserAgent(UserAgentManager.Client client, UserAgentManager.Platform platform) Updates theuserAgentfield with the given parameters.@NonNull StringtoString()
-
Field Details
-
preferredClientKind
The kind of client to use for the HTTP requests. Defaults toClient.ClientKind.HTTP_CLIENT. -
userAgent
The user agent to use for the HTTP client. Defaults toFRIEDOLYNwithout a platform specified. -
doNotTrack
The Do Not Track header indicates whether the user would prefer privacy rather than personalised content. -
globalPrivacyControl
The Global Privacy Control header indicates whether the user consents to a website or service selling or sharing their personal information with third parties.
-
-
Constructor Details
-
Client
public Client()- Implementation Note:
- For some reason, when using
NoArgsConstructor,Buildercomplains that it needs "a proper constructor", so we need to define a no-argument constructor ourselves.
-
Client
Creates a new client with the given user agent.- Parameters:
client- The name of the client that the user agent should indicate.platform- The operating system or device that the user agent should indicate.
-
Client
Creates a new client with the given user agent by callingsetUserAgent(String).- Parameters:
userAgent- Same as insetUserAgent(String).
-
Client
private Client(String userAgent, Boolean doNotTrack, Boolean globalPrivacyControl, String preferredClientKind) throws IllegalArgumentException Creates a new client with the given user agent, Do Not Track and Global Privacy Control settings.- Parameters:
userAgent- The user agent to use for the HTTP client. Will be stored inuserAgent.doNotTrack-truemeans that the user prefers privacy rather than personalised content.falsemeans the opposite. Will be stored indoNotTrack.globalPrivacyControl-truemeans that the user consents to a website or service selling or sharing their personal information with third parties.falsemeans the opposite. Will be stored inglobalPrivacyControl.preferredClientKind- The kind of client to use for the HTTP requests. Will be stored inpreferredClientKind.- Throws:
IllegalArgumentException- If the user agent is blank.- Implementation Note:
- This constructor must NOT be replaced by
Lombok's@AllArgsConstructorannotation, because then the default values would be ignored, i.e. if optional fields were missing, they would be set tonullinstead of the default values.
-
-
Method Details
-
setUserAgent
public void setUserAgent(@NonNull UserAgentManager.Client client, @NonNull UserAgentManager.Platform platform) Updates theuserAgentfield with the given parameters.- Parameters:
client- The name of the client that the user agent should indicate.platform- The operating system or device that the user agent should indicate.- Throws:
IllegalStateException- If the client was not found in the user-agent collection.IllegalArgumentException- If the client is not available on the platform specified.- See Also:
-
setUserAgent
Updates theuserAgentfield with the given one.- Parameters:
userAgent- The user agent to use for the HTTP client; will be stored inuserAgent. If it contains a dot, the method will try to cast the substring before the dot to aClientand the substring after the dot to aPlatform. If there is no dot or if the cast fails, the given user agent will be used verbatim (as is).- Throws:
IllegalArgumentException- If the user agent is blank.- See Also:
-
setNullableUserAgent
@Deprecated private void setNullableUserAgent(@Nullable String userAgent) throws IllegalArgumentException Deprecated.Only to be used by Jackson for deserialisation. UsesetUserAgent(String)instead.- Parameters:
userAgent- The user agent to use for the HTTP client; will be stored inuserAgent.- Throws:
IllegalArgumentException- SeesetUserAgent(String).
-
setDoNotTrack
Updates thedoNotTrackfield.- Parameters:
doNotTrack-truemeans that the user prefers privacy rather than personalized content.falsemeans the opposite. If it is null, the field will not be updated.
-
setGlobalPrivacyControl
Updates theglobalPrivacyControlfield.- Parameters:
globalPrivacyControl-truemeans that the user consents to a website or service selling or sharing their personal information with third parties.falsemeans the opposite. If it is null, the field will not be updated.
-
setPreferredClientKind
Updates thepreferredClientKindfield.- Parameters:
preferredClientKind- The kind of client to use for the HTTP requests. If it is null, the field will not be updated.
-
setPreferredClientKind
Deprecated.Only to be used by Jackson for deserialisation. UsesetPreferredClientKind(ClientKind)instead. Updates thepreferredClientKindfield.- Parameters:
preferredClientKind- The kind of client to use for the HTTP requests. If it is null or does not match any member of theClient.ClientKindenum, the field will not be updated.
-
copy
-
toString
-
equals
-
equalsDefault
public boolean equalsDefault()Checks whether the fields of this client are equal to the default values, i.e. whether this client resembles a newly created one.- Returns:
trueif the fields are equal to the default values,falseotherwise.
-