Class MetricSnapshotMapper
java.lang.Object
com.nmontytskyi.monitoring.server.mapper.MetricSnapshotMapper
Stateless mapper between the
MetricRecordEntity JPA entity
and the MetricSnapshot core domain model.
The MetricRecordEntity.MetricSource is preserved through conversion so that
business logic can distinguish between Actuator-pulled data and
starter-pushed data when computing aggregates.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MetricRecordEntitytoEntity(MetricSnapshot snapshot, MetricRecordEntity.MetricSource source, RegisteredServiceEntity service) Converts aMetricSnapshotcore domain object into aMetricRecordEntityready to be persisted.static MetricSnapshottoModel(MetricRecordEntity entity) Converts aMetricRecordEntity(loaded from the database) into aMetricSnapshotcore domain object.
-
Constructor Details
-
MetricSnapshotMapper
public MetricSnapshotMapper()
-
-
Method Details
-
toModel
Converts aMetricRecordEntity(loaded from the database) into aMetricSnapshotcore domain object.- Parameters:
entity- the JPA entity to convert; must not benull- Returns:
- the corresponding domain model
-
toEntity
public static MetricRecordEntity toEntity(MetricSnapshot snapshot, MetricRecordEntity.MetricSource source, RegisteredServiceEntity service) Converts aMetricSnapshotcore domain object into aMetricRecordEntityready to be persisted.The caller must set the
RegisteredServiceEntityassociation on the returned entity before saving, as the snapshot only carries a string service ID (not the full entity reference).- Parameters:
snapshot- the domain model to convert; must not benullsource- the origin of this snapshot (PULL or PUSH)service- the owning service entity- Returns:
- the JPA entity without a persisted ID
-