<dependency>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>2.8.2</version>
<scope>provided</scope>
</dependency>
import org.immutables.value.Value;
@Value.Immutable
public interface Car {
String getLicensePlate();
String getBrand();
String getModel();
double getDailyRentalPrice();
}
import org.immutables.value.Value;
@Value.Immutable
public interface RentalOrder {
String getOrderNumber();
LocalDate getStartDate();
LocalDate getEndDate();
int getRentalDays();
Car getRentedCar();
Customer getCustomer();
}
import org.immutables.value.Value;
@Value.Immutable
public interface Customer {
String getCustomerId();
String getName();
String getContact();
}
public final class ImmutableCar extends org.immutables.value.internal.$AutoValue_Car {
ImmutableCar(String licensePlate, String brand, String model, double dailyRentalPrice) {
super(licensePlate, brand, model, dailyRentalPrice);
}
}
public final class ImmutableRentalOrder extends org.immutables.value.internal.$AutoValue_RentalOrder {
ImmutableRentalOrder(String orderNumber, LocalDate startDate, LocalDate endDate, int rentalDays, Car rentedCar, Customer customer) {
super(orderNumber, startDate, endDate, rentalDays, rentedCar, customer);
}
}
public final class ImmutableCustomer extends org.immutables.value.internal.$AutoValue_Customer {
ImmutableCustomer(String customerId, String name, String contact) {
super(customerId, name, contact);
}
}
Car car = ImmutableCar.builder()
.brand("BMW")
.model("X5")
.dailyRentalPrice(500.0)
.build();