All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.vige.school.Converters Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
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;
		}
	};
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy