java.lang.Object
page.codeberg.friedolyn.meta.Downloadable
- Direct Known Subclasses:
PolledMetadata
,UserAgentManager
Represents a file or other resource that can be fetched from a remote location, such as a web server.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
download()
Fetches the resource represented by the object from the remote location that it is available at.static boolean
wasDownloadedWithin
(String dateTimeLastDownload, @NonNull Duration duration) Checks if the date and time of the last download is within the specified duration from (until) now.abstract boolean
wasDownloadedWithin
(@NonNull Duration duration) Checks if the resource represented by the object was downloaded more recently than the specified duration, i.e.
-
Constructor Details
-
Downloadable
public Downloadable()
-
-
Method Details
-
download
public abstract boolean download()Fetches the resource represented by the object from the remote location that it is available at.- Returns:
true
if the download was successful,false
otherwise.
-
wasDownloadedWithin
Checks if the resource represented by the object was downloaded more recently than the specified duration, i.e. whether the resource was downloaded within `now - duration`.- Parameters:
duration
- The time between the oldest acceptable download date and now.- Returns:
true
if the resource was downloaded within the specified duration,false
otherwise.
-
wasDownloadedWithin
public static boolean wasDownloadedWithin(String dateTimeLastDownload, @NonNull @NonNull Duration duration) Checks if the date and time of the last download is within the specified duration from (until) now.- Parameters:
dateTimeLastDownload
- The date and time of the last download in a format that can be parsed byLocalDateTime.parse(CharSequence)
.duration
- The time between the oldest acceptable download date and now.- Returns:
true
if the resource was downloaded within the specified duration,false
otherwise.False
if the date and time of the last download could not be parsed or could not becompared with the current date and time.
-