You have the following object in your project:
Java
public class Car {
private Long id;
private String model;
private int price;
// constructors, getters, and setters
}
Kotlin
data class Car(
private val id: Long,
private val model: String,
private val price: Int
)
You want to implement a method for the PUT request handling. Match the annotations with the numbers to make the following controller's method correct.
Java
@RestController
public class CarController {
private ConcurrentMap<Long, Car> carMap = new ConcurrentHashMap<>();
{1}("/cars/{id}")
Car updateCar({2} Car updatedCar, {3} Long id) {
carMap.put(id, updatedCar);
return updatedCar;
}
}
Kotlin
@RestController
class CarController {
private val carMap = ConcurrentHashMap<Long, Car>();
{1}("/cars/{id}")
fun updateCar({2} updatedCar: Car, {3} id: Long): Car {
carMap[id] = updatedCar
return updatedCar
}
}