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

com.innovenso.townplan.dsl.aspects.timemachine.FatherTimeConfigurer.groovy Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package com.innovenso.townplan.dsl.aspects.timemachine

import com.innovenso.townplan.api.command.AddFatherTimeAspectCommand
import com.innovenso.townplan.api.value.aspects.FatherTimeType
import com.innovenso.townplan.domain.TownPlanImpl
import com.innovenso.townplan.dsl.TownPlanConfigurer
import com.innovenso.townplan.dsl.aspects.AbstractAspectConfigurer
import com.innovenso.townplan.dsl.traits.HasOptionalDescription
import com.innovenso.townplan.dsl.traits.HasRequiredKey
import com.innovenso.townplan.dsl.traits.HasRequiredTitle
import jakarta.validation.constraints.NotNull
import lombok.NonNull

import java.time.LocalDate

class FatherTimeConfigurer extends AbstractAspectConfigurer implements HasRequiredKey, HasOptionalDescription, HasRequiredTitle {
	private final FatherTimeType fatherTimeType
	@NotNull
	private LocalDate pointInTime

	FatherTimeConfigurer(@NonNull TownPlanConfigurer townPlanConfigurer, @NonNull String conceptKey, @NonNull FatherTimeType fatherTimeType) {
		super(townPlanConfigurer, conceptKey)
		this.fatherTimeType = fatherTimeType
		this.title(fatherTimeType.label)
	}

	void date(LocalDate date) {
		this.pointInTime = date
	}

	def apply(@NonNull TownPlanImpl townPlan) {
		townPlan.execute(AddFatherTimeAspectCommand.builder()
				.key(this.key)
				.fatherTimeType(this.fatherTimeType)
				.pointInTime(this.pointInTime)
				.description(this.description)
				.title(this.title)
				.conceptKey(this.conceptKey)
				.build())
	}


	@Override
	String aspectType() {
		return "Lifecycle - ${fatherTimeType.label}"
	}

	@Override
	List getDefaultKeyComponents() {
		return [
			conceptKey,
			aspectType(),
			title
		]
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy