Record Class WPCacheMeta

java.lang.Object
java.lang.Record
net.ygbstudio.powerwp4j.engine.WPCacheMeta
Record Components:
totalPages - the total pages
totalPosts - the total posts
lastUpdated - 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

    Constructors
    Constructor
    Description
    WPCacheMeta(long totalPages, long totalPosts, @Nullable LocalDate lastUpdated)
    Creates an instance of a WPCacheMeta record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    from(Path cachePath)
    Reads the metadata file from the given cache file path and returns an optional WPCacheMeta object.
    final int
    Returns a hash code value for this object.
    @Nullable LocalDate
    Returns the value of the lastUpdated record component.
    final String
    Returns a string representation of this record class.
    long
    Returns the value of the totalPages record component.
    long
    Returns the value of the totalPosts record component.
    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 void
    writeCacheMetadata(Path metaPath, WPCacheMeta cacheMetaObj)
    Writes the WPCacheMeta object to the metadata file at the specified path in the local file system.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • WPCacheMeta

      public WPCacheMeta(long totalPages, long totalPosts, @Nullable @Nullable LocalDate lastUpdated)
      Creates an instance of a WPCacheMeta record class.
      Parameters:
      totalPages - the value for the totalPages record component
      totalPosts - the value for the totalPosts record component
      lastUpdated - the value for the lastUpdated record component
  • Method Details

    • from

      public static Optional<WPCacheMeta> from(Path cachePath)
      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

      public static void writeCacheMetadata(Path metaPath, WPCacheMeta cacheMetaObj)
      Writes the WPCacheMeta object to the metadata file at the specified path in the local file system.
      Parameters:
      metaPath - the path to the metadata file
      cacheMetaObj - 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 request
      cachePath - the path to the cache file
      ignoreSSLHandshakeException - 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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • totalPages

      public long totalPages()
      Returns the value of the totalPages record component.
      Returns:
      the value of the totalPages record component
    • totalPosts

      public long totalPosts()
      Returns the value of the totalPosts record component.
      Returns:
      the value of the totalPosts record component
    • lastUpdated

      @Nullable public @Nullable LocalDate lastUpdated()
      Returns the value of the lastUpdated record component.
      Returns:
      the value of the lastUpdated record component