FOSSredder 0.5.0
Loading...
Searching...
No Matches
Statement.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include <algorithm>
9#include <iterator>
10#include <string>
11#include <vector>
12#include <utility>
13
16
17namespace core::domain {
18
19class Statement {
20public:
22
23 Statement(const Statement&) = delete;
24 Statement& operator=(const Statement&) = delete;
25 Statement(Statement&&) = delete;
27
32 void rename(EntityName value);
37 void rename(std::string value);
38
43 void addTransaction(std::string value);
44
49 void setTransactionIds(std::vector<std::string> value);
50
56 void insertTransaction(std::string value, std::size_t position);
57
62 void removeTransaction(const std::string& value);
63
69 [[nodiscard]] std::size_t indexOfTransaction(const std::string& value) const;
70
76 [[nodiscard]] bool hasTransactionAt(std::size_t index) const noexcept;
77
83 void moveTransaction(const std::string& value, std::size_t newPosition);
84
90 [[nodiscard]] bool containsTransaction(const std::string& value) const;
91
95 void clearTransactions();
100 [[nodiscard]] std::size_t transactionCount() const noexcept;
105 [[nodiscard]] bool empty() const noexcept;
106
107private:
108 std::string id_;
109 std::string name_;
110 std::vector<std::string> transactionIds_;
111 std::string createdAt_;
112 std::string updatedAt_;
113
114public:
115 // Read accessors
116 [[nodiscard]] const std::string& id() const noexcept;
117 [[nodiscard]] const std::string& name() const noexcept;
118 [[nodiscard]] const std::vector<std::string>& transactionIds() const noexcept;
119 [[nodiscard]] const std::string& createdAt() const noexcept;
120 [[nodiscard]] const std::string& updatedAt() const noexcept;
121
122 // Technical hydration
123 void setId(std::string value);
124 void setCreatedAt(std::string value);
125 void setUpdatedAt(std::string value);
126};
127
128} // namespace core::domain
Small value object for normalized entity display names.
Shared statement membership and normalization helpers.
const std::string & updatedAt() const noexcept
Statement & operator=(Statement &&)=delete
void addTransaction(std::string value)
Adds a normalized transaction id when it is not already present.
Definition Statement.cpp:24
std::size_t transactionCount() const noexcept
Returns the number of linked transactions.
Definition Statement.cpp:90
bool containsTransaction(const std::string &value) const
Checks whether a transaction id exists.
Definition Statement.cpp:82
Statement(const Statement &)=delete
void removeTransaction(const std::string &value)
Removes a transaction id from the statement.
Definition Statement.cpp:50
void moveTransaction(const std::string &value, std::size_t newPosition)
Moves a transaction id to a new position.
Definition Statement.cpp:63
const std::string & name() const noexcept
Definition Statement.cpp:99
const std::string & createdAt() const noexcept
void clearTransactions()
Clears all linked transactions.
Definition Statement.cpp:86
void setTransactionIds(std::vector< std::string > value)
Replaces the transaction id list with normalized values.
Definition Statement.cpp:32
void setCreatedAt(std::string value)
void insertTransaction(std::string value, std::size_t position)
Inserts a transaction id at a requested position.
Definition Statement.cpp:37
const std::vector< std::string > & transactionIds() const noexcept
bool empty() const noexcept
Checks whether the statement is empty.
Definition Statement.cpp:94
std::size_t indexOfTransaction(const std::string &value) const
Returns the index of a transaction id.
Definition Statement.cpp:55
void setId(std::string value)
void setUpdatedAt(std::string value)
bool hasTransactionAt(std::size_t index) const noexcept
Checks whether a transaction exists at a given index.
Definition Statement.cpp:59
void rename(EntityName value)
Renames the statement with normalized entity text.
Definition Statement.cpp:16
Statement(Statement &&)=delete
Statement & operator=(const Statement &)=delete