Notes/Advanced Programming/Annotation Repository.md
2024-12-07 21:07:38 +01:00

40 lines
819 B
Markdown

---
type: practical
---
## Lombok
### `@AllArgsConstructor`(onConstructor_=@Annotation)
- Creates a public constructor which takes in all args
- `onConstructor_`: Places an annotation on the constructor
### `@Data`
A shortcut for `@ToString`, `@EqualsAndHashCode`, `@Getter` on all fields, and `@Setter` on all non-final fields
## Spring
### `RestController`
Extends Controller. Used to declare a class as a REST controller
### `@Autowired`
- Annotates a constructor
- Basically, it figures out dependency injection on its own
### `@[Get/Post/Put/Delete]Mapping("/path/")`
Makes an endpoint at path.
### `@RequestParam`
Describe the param and type
```java
@GetMapping("/api/foos")
@ResponseBody
public String getFoos(@RequestParam String id) {
return "ID: " + id;
}
```
### Beans
![[Beans.canvas|Beans]]