mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-11 06:40:18 +01:00
Introduce interface to be used by dto mappers with Instant fields
This commit is contained in:
@@ -3,14 +3,8 @@ package sonia.scm.api.v2.resources;
|
||||
import de.otto.edison.hal.HalRepresentation;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public abstract class BaseMapper<T, D extends HalRepresentation> {
|
||||
public abstract class BaseMapper<T, D extends HalRepresentation> implements InstantAttributeMapper {
|
||||
|
||||
@Mapping(target = "attributes", ignore = true) // We do not map HAL attributes
|
||||
public abstract D map(T modelObject);
|
||||
|
||||
protected Instant mapTime(Long epochMilli) {
|
||||
return epochMilli == null? null: Instant.ofEpochMilli(epochMilli);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package sonia.scm.api.v2.resources;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public interface InstantAttributeMapper {
|
||||
default Instant mapTime(Long epochMilli) {
|
||||
return epochMilli == null? null: Instant.ofEpochMilli(epochMilli);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user