public void move(final YardLocation location, final Instant occurredOn, final…
- User
public void move(final YardLocation location, final Instant occurredOn, final ConfigurableEventProducer eventProducer) { Objects.requireNonNull(location, "Location can't be null.");
updateLocation(location, occurredOn); completeMovement(occurredOn, eventProducer); } public void completeMovement(final Instant occurredOn, final ConfigurableEventProducer<YardContentCompletedMovementEvent> eventProducer) { this.updateMovingStatus(false, occurredOn); eventProducer.fire(new YardContentCompletedMovementEvent(this)); } public void startMovement(final YardLocation location, final Instant occurredOn, final ConfigurableEventProducer<YardContentStartedMovementEvent> eventProducer) { Objects.requireNonNull(location, "Location can't be null."); updateLocation(location,occurredOn); updateMovingStatus(true, occurredOn); eventProducer.fire(new YardContentStartedMovementEvent(this)); } public void out(final Instant occurredOn, final ConfigurableEventProducer<YardContentOutEvent> eventProducer) { if (this.getLocation() != null) { YardLocation lastLocation = this.getLocation(); this.updateLocation(null, occurredOn); eventProducer.fire(new YardContentOutEvent(this, lastLocation)); } }can you add javadoc to the above
here is the full class package eu.reply.lea.services.yard.entity;
import jakarta.persistence.AttributeOverride; import jakarta.persistence.AttributeOverrides; import jakarta.persistence.Column; import jakarta.persistence.Embedded; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; import jakarta.persistence.ManyToOne; import jakarta.persistence.NamedQueries; import jakarta.persistence.NamedQuery; import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min; import java.time.Instant; import java.util.Objects;
import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter;
import eu.reply.lea.services.yard.event.YardContentCompletedMovementEvent; import eu.reply.lea.services.yard.event.YardContentOutEvent; import eu.reply.lea.services.yard.event.YardContentStartedMovementEvent; import eu.reply.lea.services.yard.util.ColSizes; import eu.reply.lea.services.yard.util.ZeroTrimmer; import eu.reply.sce.backend.core.entity.JsonEntityReference; import eu.reply.sce.backend.core.entity.StringCustomizableEntity; import eu.reply.sce.backend.core.event.ConfigurableEventProducer;
@Getter @Setter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity @NamedQueries({@NamedQuery(name = YardContent.Q_BY_ENTITY_REF, query = "select yc from YardContent yc where " + "yc.logisticUnit.module = :module " + "and yc.logisticUnit.entityName = :entityName " + "and yc.logisticUnit.entityId = :entityId")}) public class YardContent extends StringCustomizableEntity {
public static final String Q_BY_ENTITY_REF = "YardContent.Q_BY_ENTITY_REF"; public enum ContainerStatus { GOOD, DAMAGED; } public enum PriorityLevel { LOW, MEDIUM, HIGH; } @Column(length = ColSizes.CODE) private String code; @Column(length = ColSizes.CODE) private String visibleLabel; @AttributeOverrides({ @AttributeOverride(column = @Column(name = "logUnit_businesskey", length = ColSizes.ER_BK), name = "businessKey"), @AttributeOverride(column = @Column(name = "logUnit_entityid", length = ColSizes.ER_ID), name = "entityId"), @AttributeOverride(column = @Column(name = "logUnit_entityname", length = ColSizes.ER_ENT), name = "entityName"), @AttributeOverride(column = @Column(name = "logUnit_module", length = ColSizes.ER_MOD), name = "module"), @AttributeOverride(column = @Column(name = "logUnit_description", length = ColSizes.ER_DESC), name = "description")}) @Embedded private JsonEntityReference logisticUnit; @Column(length = ColSizes.CODE) private String siteCode; @Column(length = ColSizes.ENUM) @Enumerated(EnumType.STRING) private PriorityLevel priorityLevel; @Column(length = ColSizes.ENUM) @Enumerated(EnumType.STRING) private ContainerStatus containerStatus; private boolean emptyContainer; private boolean moving; // level for stacks @Min(value = 0) @Max(value = 99) private Integer level; /** * Number of containers in a transit */ private Integer containerCount; /** * Activates look and feel with colored header on FE. */ private boolean transitStyle; @Embedded private YardContentChangeTracker yardContentChangeTracker; @ManyToOne private YardLocation location; public YardContent(final JsonEntityReference logisticUnit, final Boolean isTransit, final Instant initializedOn) { this.code = logisticUnit.getBusinessKey(); this.logisticUnit = logisticUnit; this.transitStyle = isTransit; this.containerCount = 0; this.moving = false; this.updateVisibleLabel(); this.yardContentChangeTracker = new YardContentChangeTracker(initializedOn); } private void updateVisibleLabel() { String label = code != null ? code : (logisticUnit != null ? logisticUnit.getBusinessKey() : ""); this.visibleLabel = ZeroTrimmer.trimLeadingZeros(label); } public void addLoadingUnit() { if (!this.transitStyle) { throw new IllegalStateException("It's only possible to add a loading unit to a transit"); } this.containerCount++; } public void removeLoadingUnit() { if (!this.transitStyle) { throw new IllegalStateException("It's only possible to add a loading unit to a transit"); } this.containerCount = this.containerCount == 0 ? 0 : this.containerCount - 1; } /** * Updates the location of the YardContent if allowed by the change tracker. * * @param newLocation the new YardLocation * @param occurredOn the timestamp of the change */ private void updateLocation(final YardLocation newLocation,final Instant occurredOn) { Objects.requireNonNull(occurredOn, "Change time must be provided."); if (this.yardContentChangeTracker.canChangeLocation(occurredOn)) { if (this.getLocation() != null) { this.location.removeContent(this); } this.location = newLocation; if (newLocation != null) { this.location.addContent(this); } this.yardContentChangeTracker = this.yardContentChangeTracker.locationChangedOn(occurredOn); } else { throw new IllegalStateException("Location cannot be changed because a more recent change has occurred."); } } /** * Updates the moving status of the YardContent if allowed by the change tracker. * * @param isMoving the new moving status * @param occurredOn the timestamp of the change */ public void updateMovingStatus(boolean isMoving, final Instant occurredOn) { Objects.requireNonNull(occurredOn, "Change time must be provided."); if (this.yardContentChangeTracker.canChangeMoving(occurredOn)) { this.moving = isMoving; this.yardContentChangeTracker = this.yardContentChangeTracker.movingChangedOn(occurredOn); } else { throw new IllegalStateException("Moving status cannot be changed because a more recent change has occurred."); } } public void move(final YardLocation location, final Instant occurredOn, final ConfigurableEventProducer<YardContentCompletedMovementEvent> eventProducer) { Objects.requireNonNull(location, "Location can't be null."); updateLocation(location, occurredOn); completeMovement(occurredOn, eventProducer); } public void completeMovement(final Instant occurredOn, final ConfigurableEventProducer<YardContentCompletedMovementEvent> eventProducer) { this.updateMovingStatus(false, occurredOn); eventProducer.fire(new YardContentCompletedMovementEvent(this)); } public void startMovement(final YardLocation location, final Instant occurredOn, final ConfigurableEventProducer<YardContentStartedMovementEvent> eventProducer) { Objects.requireNonNull(location, "Location can't be null."); updateLocation(location,occurredOn); updateMovingStatus(true, occurredOn); eventProducer.fire(new YardContentStartedMovementEvent(this)); } public void out(final Instant occurredOn, final ConfigurableEventProducer<YardContentOutEvent> eventProducer) { if (this.getLocation() != null) { YardLocation lastLocation = this.getLocation(); this.updateLocation(null, occurredOn); eventProducer.fire(new YardContentOutEvent(this, lastLocation)); } } - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.