Class NoOpDtoCache

java.lang.Object
org.litebridge.orm.persistence.NoOpDtoCache
All Implemented Interfaces:
DtoCache

public final class NoOpDtoCache extends Object implements DtoCache
A no-operation implementation of the DtoCache interface. This implementation does not perform any caching and is designed to always return null or perform no action when its methods are invoked. It can be used in scenarios where caching is not required or desirable.

This class is implemented as a singleton, and the single instance can be accessed via the INSTANCE field.

This class is immutable and thread-safe.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final NoOpDtoCache
    The singleton instance of the NoOpDtoCache class.
  • Method Summary

    Modifier and Type
    Method
    Description
    <DTO> @Nullable DTO
    get(Class<DTO> dtoClass, List<Object> id)
    Retrieves a cached Data Transfer Object (DTO) of the specified class type and identifier.
    <DTO> @Nullable List<DTO>
    getAll(Class<DTO> dtoClass)
    Retrieves a list of all cached Data Transfer Objects (DTOs) of the specified class type.
    void
    put(List<Object> id, @Nullable Object dto)
    Stores a Data Transfer Object (DTO) in the cache associated with the provided identifier.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • INSTANCE

      public static final NoOpDtoCache INSTANCE
      The singleton instance of the NoOpDtoCache class. This instance represents a no-operation implementation of the DtoCache interface that does not perform any caching functionality. All methods invoked on this instance either return null or take no action.

      Use this constant when caching is not required or should be explicitly disabled, ensuring no resources are consumed or maintained for caching operations.

      This instance is immutable, stateless, and thread-safe.

  • Method Details

    • get

      public <DTO> @Nullable DTO get(Class<DTO> dtoClass, List<Object> id)
      Description copied from interface: DtoCache
      Retrieves a cached Data Transfer Object (DTO) of the specified class type and identifier. If no matching DTO is found in the cache, this method returns null.
      Specified by:
      get in interface DtoCache
      Type Parameters:
      DTO - The type of the Data Transfer Object.
      Parameters:
      dtoClass - The class type of the DTO to retrieve.
      id - The identifier used to locate the DTO in the cache. This is typically a list of keys representing a unique identifier for the DTO.
      Returns:
      The cached instance of the specified DTO type matching the given identifier, or null if no such DTO is found.
    • put

      public void put(List<Object> id, @Nullable Object dto)
      Description copied from interface: DtoCache
      Stores a Data Transfer Object (DTO) in the cache associated with the provided identifier. The identifier is typically a list of keys that uniquely represents the DTO. If the provided DTO is null, this method may effectively remove any existing entry associated with the given identifier, depending on the implementation.
      Specified by:
      put in interface DtoCache
      Parameters:
      id - The identifier used to associate the DTO with a cached entry. This is typically a list of keys representing a unique identifier for the DTO.
      dto - The Data Transfer Object to store in the cache. It can be null if the entry should be removed or not stored.
    • getAll

      public <DTO> @Nullable List<DTO> getAll(Class<DTO> dtoClass)
      Description copied from interface: DtoCache
      Retrieves a list of all cached Data Transfer Objects (DTOs) of the specified class type. If no DTOs of the given type are found, this method returns null.
      Specified by:
      getAll in interface DtoCache
      Type Parameters:
      DTO - The type of the Data Transfer Objects.
      Parameters:
      dtoClass - The class type of the DTOs to retrieve.
      Returns:
      A list of DTOs of the specified type currently in the cache, or null if no DTOs of the given class type are found.