package org.openur.module.persistence.rdbms.entity.application;

import org.apache.commons.lang3.StringUtils;
import org.openur.module.domain.application.OpenURApplication;
import org.openur.module.domain.application.OpenURApplicationBuilder;

/**
 * @author uwe
 * 
 * maps entity-data from and to immutable.
 */
public class ApplicationMapper
{
	public static PApplication mapFromImmutable(OpenURApplication immutable)
	{
		PApplication persistable = new PApplication();
		persistable.setApplicationName(immutable.getApplicationName());

		return persistable;
	}

	public static OpenURApplication mapFromEntity(PApplication persistable)
	{
		OpenURApplicationBuilder immutableBuilder = new OpenURApplicationBuilder(persistable.getApplicationName());

		if (StringUtils.isNotEmpty(persistable.getIdentifier()))
		{
			immutableBuilder.identifier(persistable.getIdentifier());
		}

		immutableBuilder
				.creationDate(persistable.getCreationDate())
				.lastModifiedDate(persistable.getLastModifiedDate())
				.build();

		return immutableBuilder.build();
	}
}

@@ -877,16 +877,23 @@
 %0A%09%09%7D%0A%0A%09%09
+return 
 immutabl
@@ -1024,44 +1024,8 @@
 d();
-%0A%0A%09%09return immutableBuilder.build();
 %0A%09%7D%0A

create and return only one instance of immutable, not two.