![JAR search and dependency download from the Maven repository](/logo.png)
io.imunity.rest.mappers.EntityInformationMapper Maven / Gradle / Ivy
/*
* Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
* See LICENCE.txt file for licensing information.
*/
package io.imunity.rest.mappers;
import java.util.Optional;
import io.imunity.rest.api.types.basic.RestEntityInformation;
import pl.edu.icm.unity.base.entity.EntityInformation;
import pl.edu.icm.unity.base.entity.EntityScheduledOperation;
import pl.edu.icm.unity.base.entity.EntityState;
public class EntityInformationMapper
{
static RestEntityInformation map(EntityInformation entityInformation)
{
return RestEntityInformation.builder()
.withEntityId(entityInformation.getId())
.withState(Optional.ofNullable(entityInformation.getEntityState())
.map(s -> s.name())
.orElse(null))
.withRemovalByUserTime(entityInformation.getRemovalByUserTime())
.withScheduledOperationTime(entityInformation.getScheduledOperationTime())
.withScheduledOperation(Optional.ofNullable(entityInformation.getScheduledOperation())
.map(s -> s.name())
.orElse(null))
.build();
}
static EntityInformation map(RestEntityInformation restEntityInformation)
{
EntityInformation entityInformation = new EntityInformation(restEntityInformation.entityId);
entityInformation.setEntityState(Optional.ofNullable(restEntityInformation.state)
.map(s -> EntityState.valueOf(s))
.orElse(null));
entityInformation.setRemovalByUserTime(restEntityInformation.removalByUserTime);
entityInformation.setScheduledOperation(Optional.ofNullable(restEntityInformation.scheduledOperation)
.map(s -> EntityScheduledOperation.valueOf(s))
.orElse(null));
entityInformation.setScheduledOperationTime(restEntityInformation.scheduledOperationTime);
return entityInformation;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy