Class AclInterfaceCacheImpl

  • All Implemented Interfaces:
    AclInterfaceCache

    @Singleton
    public class AclInterfaceCacheImpl
    extends java.lang.Object
    implements AclInterfaceCache
    Implementation of the AclInterfaceCache interface.
    Author:
    Thomas Pantelis
    • Constructor Detail

      • AclInterfaceCacheImpl

        public AclInterfaceCacheImpl()
    • Method Detail

      • addOrUpdate

        public AclInterface addOrUpdate​(@NonNull java.lang.String interfaceId,
                                        java.util.function.BiConsumer<AclInterface,​AclInterface.Builder> updateFunction)
        Description copied from interface: AclInterfaceCache
        Adds a new AclInterface if not already existing, otherwise updates the existing instance. In either case, the given updateFunction is used to build a new instance.
        Specified by:
        addOrUpdate in interface AclInterfaceCache
        Parameters:
        interfaceId - the interface Id
        updateFunction - the function used to build a new instance from the provided AclInterface.Builder. If an instance already exists in the cache, the previous instance is passed to the function and the Builder is initially populated from the existing instance.
        Returns:
        the new or updated AclInterface
      • updateIfPresent

        public AclInterface updateIfPresent​(java.lang.String interfaceId,
                                            java.util.function.BiFunction<AclInterface,​AclInterface.Builder,​java.lang.Boolean> updateFunction)
        Description copied from interface: AclInterfaceCache
        Updates an existing AclInterface instance in the cache. The given updateFunction is used to build a new instance.
        Specified by:
        updateIfPresent in interface AclInterfaceCache
        Parameters:
        interfaceId - the interface Id
        updateFunction - the function used to build a new instance from the provided AclInterface.Builder. The previous instance is passed to the function and the Builder is initially populated from the existing instance. The function returns a boolean indicating if any updates were actually made.
        Returns:
        the updated AclInterface or null if no instance was present or no updates were made
      • remove

        public @Nullable AclInterface remove​(java.lang.String interfaceId)
        Description copied from interface: AclInterfaceCache
        Removes an AclInterface instance from the cache.
        Specified by:
        remove in interface AclInterfaceCache
        Parameters:
        interfaceId - the interface Id
        Returns:
        the AclInterface if present, null oherwise
      • get

        public AclInterface get​(java.lang.String interfaceId)
        Description copied from interface: AclInterfaceCache
        Gets an AclInterface instance from the cache if present.
        Specified by:
        get in interface AclInterfaceCache
        Parameters:
        interfaceId - the interface Id
        Returns:
        the AclInterface instance if found, null otherwise