Class CachedInfoResponse


  • public class CachedInfoResponse
    extends java.lang.Object
    Cached info response.

    This class holds an info response array, and can produce a filtered response holding only those items asked for.

    Since:
    5.0.8
    Author:
    Mark Rotteveel
    • Constructor Summary

      Constructors 
      Constructor Description
      CachedInfoResponse​(byte[] infoResponse)
      Constructs a cached info response.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static CachedInfoResponse empty()  
      boolean equals​(java.lang.Object obj)  
      byte[] filtered​(byte[] requestItems)
      Produces a response with only the items in requestItems, allowing items to be missing.
      java.util.Optional<byte[]> filteredComplete​(byte[] requestItems)
      Produces a response with only the items in requestItems, requiring all items to be present.
      int hashCode()  
      byte[] infoResponse()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CachedInfoResponse

        public CachedInfoResponse​(byte[] infoResponse)
        Constructs a cached info response.
        Parameters:
        infoResponse - byte array with info response; the caller of the constructor is responsible for cloning/copying the array if needed
    • Method Detail

      • empty

        public static CachedInfoResponse empty()
        Returns:
        a — possibly cached — empty cached info response
      • filtered

        public byte[] filtered​(byte[] requestItems)
        Produces a response with only the items in requestItems, allowing items to be missing.

        If there are no matching items, or the cached response is empty, then a byte array with only ISCConstants.isc_info_end is returned.

        Parameters:
        requestItems - requested info items
        Returns:
        an info response with only the requested items, ending in ISCConstants.isc_info_end
        See Also:
        filteredComplete(byte[])
      • filteredComplete

        public java.util.Optional<byte[]> filteredComplete​(byte[] requestItems)
        Produces a response with only the items in requestItems, requiring all items to be present.

        If at least one item in requestItems (excluding ISCConstants.isc_info_end) is not found in this cached info response, empty is returned.

        Parameters:
        requestItems - requested info items
        Returns:
        an optional with an info response with only the requested items, and ending in ISCConstants.isc_info_end, or empty if at least one of the requested items where not found in the cached response, or if the cached response is empty
        See Also:
        filtered(byte[])
      • infoResponse

        public byte[] infoResponse()
        Returns:
        a copy of the full info response array
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object