17 name_ = std::move(value.
value());
25 year_ = value.
value();
32void Annual::apply(std::string nameValue,
int yearValue, std::vector<std::string> analysisIdsValue) {
33 rename(std::move(nameValue));
40 analysisIds_ = std::move(value);
48 analysisIds_.push_back(std::move(value));
57 if (position >= analysisIds_.size()) {
58 analysisIds_.push_back(std::move(value));
61 analysisIds_.insert(analysisIds_.begin() +
static_cast<std::vector<std::string>::difference_type
>(position), std::move(value));
66 analysisIds_.erase(std::remove(analysisIds_.begin(), analysisIds_.end(), normalized), analysisIds_.end());
79 const auto it = std::find(analysisIds_.begin(), analysisIds_.end(), normalized);
80 if (it == analysisIds_.end()) {
81 return analysisIds_.size();
83 return static_cast<std::size_t
>(std::distance(analysisIds_.begin(), it));
88 const auto it = std::find(analysisIds_.begin(), analysisIds_.end(), normalized);
89 if (it == analysisIds_.end()) {
92 const auto current =
static_cast<std::size_t
>(std::distance(analysisIds_.begin(), it));
93 const auto item = *it;
94 analysisIds_.erase(it);
95 if (newPosition >= analysisIds_.size()) {
96 analysisIds_.push_back(item);
99 if (current < newPosition && newPosition > 0) {
102 analysisIds_.insert(analysisIds_.begin() +
static_cast<std::vector<std::string>::difference_type
>(newPosition), item);
106 return analysisIds_.size();
114 return name_.empty() && !
hasYear() && analysisIds_.empty();
117const std::string&
Annual::id() const noexcept {
return id_; }
Domain model for annual aggregates.
void moveAnalysisId(const std::string &value, std::size_t newPosition)
Moves an analysis id to a new position.
void setAnalysisIds(std::vector< std::string > value)
Replaces the linked analysis ids with normalized values.
std::size_t analysisCount() const noexcept
Returns the number of linked analysis ids.
void apply(std::string nameValue, int yearValue, std::vector< std::string > analysisIdsValue)
Applies the complete annual definition in one normalized domain step.
std::size_t indexOfAnalysisId(const std::string &value) const
Returns the index of an analysis id.
void addAnalysisId(std::string value)
Adds an analysis id when it is not already present.
void setId(std::string value)
void setUpdatedAt(std::string value)
void setYear(Year value)
Sets the annual year from a value object.
const int & year() const noexcept
void removeAnalysisId(const std::string &value)
Removes an analysis id from the annual aggregate.
const std::vector< std::string > & analysisIds() const noexcept
void setCreatedAt(std::string value)
const std::string & updatedAt() const noexcept
void clearAnalysisIds()
Clears all linked analysis ids.
bool isEmpty() const noexcept
Checks whether the annual aggregate is empty.
void insertAnalysisId(std::string value, std::size_t position)
Inserts an analysis id at a requested position.
bool containsAnalysisId(const std::string &value) const
Checks whether an analysis id exists.
void rename(EntityName value)
Renames the annual aggregate with normalized entity text.
const std::string & createdAt() const noexcept
const std::string & name() const noexcept
const std::string & id() const noexcept
bool hasYear() const noexcept
Checks whether the annual year is valid.
const std::string & value() const noexcept
int value() const noexcept
void normalizeIds(std::vector< std::string > &values)
Normalizes and deduplicates analysis ids.
bool containsAnalysisId(const std::vector< std::string > &analysisIds, const std::string &analysisId)
Checks whether an analysis id exists in a list.
bool isValidYear(int year)
Checks whether a year is valid for annual aggregates.
std::string normalizeId(std::string value)
Trims leading and trailing whitespace from an id.