tutorial:interface_injection
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| tutorial:interface_injection [2025/11/10 02:07] – Add headings to interface injection article earthcomputer | tutorial:interface_injection [2025/11/10 03:38] (current) – Add info on how to inject generic interfaces earthcomputer | ||
|---|---|---|---|
| Line 70: | Line 70: | ||
| :!: Sometimes, your interface injections may need to include the '' | :!: Sometimes, your interface injections may need to include the '' | ||
| + | |||
| + | ==== Generic interfaces ==== | ||
| + | |||
| + | If your interface has generics, you can specify them when you add the injected interface. For this, you need to add ''<>'' | ||
| + | |||
| + | ^ Description | ||
| + | | Class type | '' | ||
| + | | Array type | '' | ||
| + | | Primitive type (may appear as array elements) | '' | ||
| + | | Type variable | ||
| + | | Generic class type | '' | ||
| + | | Wildcard | ||
| + | | Extends wildcard bound | ''? | ||
| + | | Super wildcard bound | ''? | ||
| + | |||
| + | Here is a full example using generics: | ||
| + | <code json fabric.mod.json [enable_line_numbers=" | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | which would generate the implementation: | ||
| + | < | ||
| + | public class class_3609 implements MyGenericInterface<? | ||
| + | // ... | ||
| + | } | ||
| + | </ | ||
| ===== Step 4: Using the Injected Method ===== | ===== Step 4: Using the Injected Method ===== | ||
tutorial/interface_injection.1762740421.txt.gz · Last modified: 2025/11/10 02:07 by earthcomputer