Coverage for rdflib_ocdm/counter_handler/counter_handler.py: 100%
1 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-11-01 22:02 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-11-01 22:02 +0000
1#!/usr/bin/python
2# -*- coding: utf-8 -*-
3# Copyright (c) 2016, Silvio Peroni <essepuntato@gmail.com>
4#
5# Permission to use, copy, modify, and/or distribute this software for any purpose
6# with or without fee is hereby granted, provided that the above copyright notice
7# and this permission notice appear in all copies.
8#
9# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
11# FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
12# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
13# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
14# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
15# SOFTWARE.
16from abc import ABC, abstractmethod
19class CounterHandler(ABC): # pragma: no cover
20 """Abstract class representing the interface for every concrete counter handler."""
22 @abstractmethod
23 def set_counter(self, new_value: int, entity_name: str) -> None:
24 """
25 Method signature for concrete implementations that allow setting the counter value
26 of provenance entities.
28 :param new_value: The new counter value to be set
29 :type new_value: int
30 :param entity_name: The entity name
31 :type entity_name: str
32 :raises NotImplementedError: always
33 :return: None
34 """
35 raise NotImplementedError
37 @abstractmethod
38 def read_counter(self, entity_name: str) -> int:
39 """
40 Method signature for concrete implementations that allow reading the counter value
41 of graph and provenance entities.
43 :param entity_name: The entity name
44 :type entity_name: str
45 :raises NotImplementedError: always
46 :return: The requested counter value.
47 """
48 raise NotImplementedError
50 @abstractmethod
51 def increment_counter(self, entity_name: str) -> int:
52 """
53 Method signature for concrete implementations that allow incrementing by one unit
54 the counter value of graph and provenance entities.
56 :param entity_name: The entity name
57 :type entity_name: str
58 :raises NotImplementedError: always
59 :return: The newly-updated (already incremented) counter value.
60 """
61 raise NotImplementedError