Package net.ygbstudio.powerwp4j.engine
Record Class WPCacheMeta
java.lang.Object
java.lang.Record
net.ygbstudio.powerwp4j.engine.WPCacheMeta
- Record Components:
totalPages- the total pagestotalPosts- the total postslastUpdated- the last updated timestamp
public record WPCacheMeta(long totalPages, long totalPosts, @Nullable LocalDate lastUpdated)
extends Record
Metadata for the cache file.
- Author:
- Yoham Gabriel @ YGBStudio
-
Constructor Summary
ConstructorsConstructorDescriptionWPCacheMeta(long totalPages, long totalPosts, @Nullable LocalDate lastUpdated) Creates an instance of aWPCacheMetarecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static Optional<WPCacheMeta> Reads the metadata file from the given cache file path and returns an optional WPCacheMeta object.final inthashCode()Returns a hash code value for this object.@Nullable LocalDateReturns the value of thelastUpdatedrecord component.final StringtoString()Returns a string representation of this record class.longReturns the value of thetotalPagesrecord component.longReturns the value of thetotalPostsrecord component.static Optional<WPCacheMeta> updateCacheMeta(@NotNull WPSiteInfo siteInfo, Path cachePath, boolean ignoreSSLHandshakeException) Updates the cache metadata by making a request to the WordPress REST API and returns an optional WPCacheMeta object.static voidwriteCacheMetadata(Path metaPath, WPCacheMeta cacheMetaObj) Writes the WPCacheMeta object to the metadata file at the specified path in the local file system.
-
Constructor Details
-
WPCacheMeta
Creates an instance of aWPCacheMetarecord class.- Parameters:
totalPages- the value for thetotalPagesrecord componenttotalPosts- the value for thetotalPostsrecord componentlastUpdated- the value for thelastUpdatedrecord component
-
-
Method Details
-
from
Reads the metadata file from the given cache file path and returns an optional WPCacheMeta object.- Parameters:
cachePath- the path to the cache file- Returns:
- an optional WPCacheMeta object
-
writeCacheMetadata
Writes the WPCacheMeta object to the metadata file at the specified path in the local file system.- Parameters:
metaPath- the path to the metadata filecacheMetaObj- the WPCacheMeta object to write- Throws:
CacheMetaDataException- if there is an error in metadata object write to the fs.
-
updateCacheMeta
public static Optional<WPCacheMeta> updateCacheMeta(@NotNull @NotNull WPSiteInfo siteInfo, Path cachePath, boolean ignoreSSLHandshakeException) Updates the cache metadata by making a request to the WordPress REST API and returns an optional WPCacheMeta object.- Parameters:
siteInfo- the WPSiteInfo object containing the necessary information to make the requestcachePath- the path to the cache fileignoreSSLHandshakeException- a boolean indicating if SSL Handshake Exception should be ignored- Returns:
- an optional WPCacheMeta object
- Throws:
CacheMetaDataException- if response headers are incomplete, non-exposed or blocked.
-
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. -
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
totalPages
public long totalPages()Returns the value of thetotalPagesrecord component.- Returns:
- the value of the
totalPagesrecord component
-
totalPosts
public long totalPosts()Returns the value of thetotalPostsrecord component.- Returns:
- the value of the
totalPostsrecord component
-
lastUpdated
Returns the value of thelastUpdatedrecord component.- Returns:
- the value of the
lastUpdatedrecord component
-