Skip to content

Instantly share code, notes, and snippets.

@sandokandias
Last active March 25, 2025 18:40
Show Gist options
  • Save sandokandias/73aad58498540cf6a6a5c5ebe498593a to your computer and use it in GitHub Desktop.
Save sandokandias/73aad58498540cf6a6a5c5ebe498593a to your computer and use it in GitHub Desktop.
Java class that represents a Order with immutable properties
public class Order {
public final UUID id;
public final ZonedDateTime createdAt;
public final String customerName;
public final List<String> items;
public final Integer totalAmount;
public Order(UUID id, ZonedDateTime createdAt, String customerName, List<String> items, Integer totalAmount) {
this.id = id;
this.createdAt = createdAt;
this.customerName = customerName;
this.items = List.copyOf(items);
this.totalAmount = totalAmount;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment