Fix formatting
This commit is contained in:
parent
c4770ac40f
commit
d444ab4d54
@ -10,80 +10,80 @@ import java.util.Optional;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class PathVariableAnnotationController {
|
public class PathVariableAnnotationController {
|
||||||
@GetMapping("/api/employees/{id}")
|
@GetMapping("/api/employees/{id}")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getEmployeesById(@PathVariable String id) {
|
public String getEmployeesById(@PathVariable String id) {
|
||||||
return "ID: " + id;
|
return "ID: " + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/api/employeeswithvariable/{id}")
|
@GetMapping("/api/employeeswithvariable/{id}")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getEmployeesByIdWithVariableName(@PathVariable("id") String employeeId) {
|
public String getEmployeesByIdWithVariableName(@PathVariable("id") String employeeId) {
|
||||||
return "ID: " + employeeId;
|
return "ID: " + employeeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/api/employees/{id}/{name}")
|
@GetMapping("/api/employees/{id}/{name}")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getEmployeesByIdAndName(@PathVariable String id, @PathVariable String name) {
|
public String getEmployeesByIdAndName(@PathVariable String id, @PathVariable String name) {
|
||||||
return "ID: " + id + ", name: " + name;
|
return "ID: " + id + ", name: " + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/api/employeeswithmapvariable/{id}/{name}")
|
@GetMapping("/api/employeeswithmapvariable/{id}/{name}")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getEmployeesByIdAndNameWithMapVariable(@PathVariable Map<String, String> pathVarsMap) {
|
public String getEmployeesByIdAndNameWithMapVariable(@PathVariable Map<String, String> pathVarsMap) {
|
||||||
String id = pathVarsMap.get("id");
|
String id = pathVarsMap.get("id");
|
||||||
String name = pathVarsMap.get("name");
|
String name = pathVarsMap.get("name");
|
||||||
if (id != null && name != null) {
|
if (id != null && name != null) {
|
||||||
return "ID: " + id + ", name: " + name;
|
return "ID: " + id + ", name: " + name;
|
||||||
} else {
|
} else {
|
||||||
return "Missing Parameters";
|
return "Missing Parameters";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = { "/api/employeeswithrequired", "/api/employeeswithrequired/{id}" })
|
@GetMapping(value = { "/api/employeeswithrequired", "/api/employeeswithrequired/{id}" })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getEmployeesByIdWithRequired(@PathVariable String id) {
|
public String getEmployeesByIdWithRequired(@PathVariable String id) {
|
||||||
return "ID: " + id;
|
return "ID: " + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = { "/api/employeeswithrequiredfalse", "/api/employeeswithrequiredfalse/{id}" })
|
@GetMapping(value = { "/api/employeeswithrequiredfalse", "/api/employeeswithrequiredfalse/{id}" })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getEmployeesByIdWithRequiredFalse(@PathVariable(required = false) String id) {
|
public String getEmployeesByIdWithRequiredFalse(@PathVariable(required = false) String id) {
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
return "ID: " + id;
|
return "ID: " + id;
|
||||||
} else {
|
} else {
|
||||||
return "ID missing";
|
return "ID missing";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = { "/api/employeeswithoptional", "/api/employeeswithoptional/{id}" })
|
@GetMapping(value = { "/api/employeeswithoptional", "/api/employeeswithoptional/{id}" })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getEmployeesByIdWithOptional(@PathVariable Optional<String> id) {
|
public String getEmployeesByIdWithOptional(@PathVariable Optional<String> id) {
|
||||||
if (id.isPresent()) {
|
if (id.isPresent()) {
|
||||||
return "ID: " + id.get();
|
return "ID: " + id.get();
|
||||||
} else {
|
} else {
|
||||||
return "ID missing";
|
return "ID missing";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = { "/api/defaultemployeeswithoptional", "/api/defaultemployeeswithoptional/{id}" })
|
@GetMapping(value = { "/api/defaultemployeeswithoptional", "/api/defaultemployeeswithoptional/{id}" })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getDefaultEmployeesByIdWithOptional(@PathVariable Optional<String> id) {
|
public String getDefaultEmployeesByIdWithOptional(@PathVariable Optional<String> id) {
|
||||||
if (id.isPresent()) {
|
if (id.isPresent()) {
|
||||||
return "ID: " + id.get();
|
return "ID: " + id.get();
|
||||||
} else {
|
} else {
|
||||||
return "ID: Default Employee";
|
return "ID: Default Employee";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = { "/api/employeeswithmap/{id}", "/api/employeeswithmap" })
|
@GetMapping(value = { "/api/employeeswithmap/{id}", "/api/employeeswithmap" })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getEmployeesByIdWithMap(@PathVariable Map<String, String> pathVarsMap) {
|
public String getEmployeesByIdWithMap(@PathVariable Map<String, String> pathVarsMap) {
|
||||||
String id = pathVarsMap.get("id");
|
String id = pathVarsMap.get("id");
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
return "ID: " + id;
|
return "ID: " + id;
|
||||||
} else {
|
} else {
|
||||||
return "ID missing";
|
return "ID missing";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user