Name) Product(SKU("132456"), Price(4, 99), Name("Brot")) data class SKU(val value: String) { private val regex = "[\\w\\d]{5,20}".toRegex() init { if(!regex.matches(value)) throw IllegalArgumentException("...") } } fun putProductInto(product: Product, quantity: Quantity): ShoppingCart { checkMaximumProductCount() val newAmount: ShoppingCartAmount = overallAmount + (product.price * quantity) val existingQuantity: Quantity? = cartItems[product] if(existingQuantity == null) { cartItems[product] = quantity } else { cartItems[product] = existingQuantity.copy(value = existingQuantity.value + quantity.value) } Die Domain