Coverage for rdflib_ocdm / counter_handler / counter_handler.py: 100%
3 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-30 21:23 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-30 21:23 +0000
1#!/usr/bin/python
3# SPDX-FileCopyrightText: 2016 Silvio Peroni <essepuntato@gmail.com>
4# SPDX-FileCopyrightText: 2023-2026 Arcangelo Massari <arcangelo.massari@unibo.it>
5#
6# SPDX-License-Identifier: ISC
7from abc import ABC, abstractmethod
10class CounterHandler(ABC): # pragma: no cover
11 """Abstract class representing the interface for every concrete counter handler."""
13 @abstractmethod
14 def set_counter(self, new_value: int, entity_name: str) -> None:
15 """
16 Method signature for concrete implementations that allow
17 setting the counter value of provenance entities.
19 :param new_value: The new counter value to be set
20 :type new_value: int
21 :param entity_name: The entity name
22 :type entity_name: str
23 :raises NotImplementedError: always
24 :return: None
25 """
26 raise NotImplementedError
28 @abstractmethod
29 def read_counter(self, entity_name: str) -> int:
30 """
31 Method signature for concrete implementations that allow
32 reading the counter value of graph and provenance entities.
34 :param entity_name: The entity name
35 :type entity_name: str
36 :raises NotImplementedError: always
37 :return: The requested counter value.
38 """
39 raise NotImplementedError
41 @abstractmethod
42 def increment_counter(self, entity_name: str) -> int:
43 """
44 Method signature for concrete implementations that allow
45 incrementing by one unit the counter value of graph and
46 provenance entities.
48 :param entity_name: The entity name
49 :type entity_name: str
50 :raises NotImplementedError: always
51 :return: The newly-updated (already incremented) counter value.
52 """
53 raise NotImplementedError
56class SupplierAwareCounterHandler(CounterHandler, ABC):
57 supplier_prefix: str