Skip to content

Commit

Permalink
Add age to the model
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatan-ivanov committed Dec 16, 2022
1 parent 05252c3 commit e8044c0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/resourceater/model/resource/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import java.time.Duration;
import java.time.Instant;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import org.springframework.hateoas.RepresentationModel;

/**
Expand All @@ -14,12 +16,14 @@
public abstract class Model<R extends Resource<R>> extends RepresentationModel<Model<R>> {
protected final String id;
protected final Duration ttl;
protected final Duration age;
protected final Instant createdAt;
protected final Instant diesAt;

public Model(R resource){
this.id = resource.getId();
this.ttl = resource.getTtl().orElse(null);
this.age = resource.getAge();
this.createdAt = resource.getCreatedAt();
this.diesAt = resource.getDiesAt();
}
Expand Down

0 comments on commit e8044c0

Please sign in to comment.