it.vige.school.Converters Maven / Gradle / Ivy
package it.vige.school;
import java.util.function.Function;
import it.vige.school.dto.Presence;
import it.vige.school.dto.User;
import it.vige.school.model.PresenceEntity;
import it.vige.school.model.PresenceId;
public interface Converters {
Function StringToUser = new Function() {
public User apply(String t) {
User user = new User();
user.setId(t);
return user;
}
};
Function PresenceEntityToPresence = new Function() {
public Presence apply(PresenceEntity t) {
Presence presence = new Presence();
presence.setDay(t.getId().getDay());
presence.setUser(StringToUser.apply(t.getId().getUser()));
return presence;
}
};
Function PresenceToPresenceEntity = new Function() {
public PresenceEntity apply(Presence t) {
PresenceEntity presenceEntity = new PresenceEntity();
PresenceId presenceId = new PresenceId();
presenceId.setDay(t.getDay());
presenceId.setUser(t.getUser().getId());
presenceEntity.setId(presenceId);
return presenceEntity;
}
};
}