Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.eclipse.cargotracker.domain.model.cargo;

import java.io.Serializable;
import java.util.Optional;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
Expand All @@ -13,7 +14,6 @@
import org.eclipse.cargotracker.domain.model.handling.HandlingEvent;
import org.eclipse.cargotracker.domain.model.handling.HandlingHistory;
import org.eclipse.cargotracker.domain.model.location.Location;
import org.eclipse.cargotracker.domain.shared.DomainObjectUtils;

/**
* A Cargo. This is the central class in the domain model, and it is the root of the
Expand Down Expand Up @@ -120,7 +120,7 @@ public Delivery getDelivery() {

/** @return The itinerary. Never null. */
public Itinerary getItinerary() {
return DomainObjectUtils.nullSafe(this.itinerary, Itinerary.EMPTY_ITINERARY);
return Optional.ofNullable(this.itinerary).orElse(Itinerary.EMPTY_ITINERARY);
}

/** Specifies a new route for this cargo. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Iterator;
import java.util.Optional;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.persistence.Embedded;
Expand All @@ -28,7 +29,6 @@
import org.eclipse.cargotracker.domain.model.handling.HandlingHistory;
import org.eclipse.cargotracker.domain.model.location.Location;
import org.eclipse.cargotracker.domain.model.voyage.Voyage;
import org.eclipse.cargotracker.domain.shared.DomainObjectUtils;

/**
* The actual transportation of the cargo, as opposed to the customer requirement
Expand Down Expand Up @@ -139,7 +139,7 @@ public void setTransportStatus(TransportStatus transportStatus) {
}

public Location getLastKnownLocation() {
return DomainObjectUtils.nullSafe(lastKnownLocation, Location.UNKNOWN);
return Optional.ofNullable(this.lastKnownLocation).orElse(Location.UNKNOWN);
}

public void setLastKnownLocation(Location lastKnownLocation) {
Expand All @@ -151,7 +151,7 @@ public void setLastEvent(HandlingEvent lastEvent) {
}

public Voyage getCurrentVoyage() {
return DomainObjectUtils.nullSafe(currentVoyage, Voyage.NONE);
return Optional.ofNullable(this.currentVoyage).orElse(Voyage.NONE);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Optional;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
Expand All @@ -21,7 +22,6 @@
import org.eclipse.cargotracker.domain.model.cargo.TrackingId;
import org.eclipse.cargotracker.domain.model.location.Location;
import org.eclipse.cargotracker.domain.model.voyage.Voyage;
import org.eclipse.cargotracker.domain.shared.DomainObjectUtils;

/**
* A HandlingEvent is used to register the event when, for instance, a cargo is unloaded from a
Expand Down Expand Up @@ -157,7 +157,7 @@ public Type getType() {
}

public Voyage getVoyage() {
return DomainObjectUtils.nullSafe(this.voyage, Voyage.NONE);
return Optional.ofNullable(this.voyage).orElse(Voyage.NONE);
}

public LocalDateTime getCompletionTime() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.eclipse.cargotracker.domain.service.RoutingService;
import org.eclipse.cargotracker.domain.shared.AbstractSpecification;
import org.eclipse.cargotracker.domain.shared.AndSpecification;
import org.eclipse.cargotracker.domain.shared.DomainObjectUtils;
import org.eclipse.cargotracker.domain.shared.NotSpecification;
import org.eclipse.cargotracker.domain.shared.OrSpecification;
import org.eclipse.cargotracker.domain.shared.Specification;
Expand Down Expand Up @@ -119,7 +118,6 @@ public static WebArchive createDeployment() {
.addClass(HandlingActivity.class)
.addClass(RoutingStatus.class)
.addClass(HandlingHistory.class)
.addClass(DomainObjectUtils.class)
.addClass(CargoRepository.class)
.addClass(LocationRepository.class)
.addClass(VoyageRepository.class)
Expand Down