|\n| `java.net.URI` | Any standard URI. | `https://example.com/webhook` |\n\n## Enum Types\n\nAny `Enum` type is resolved automatically — no manual registration needed.\n\n| Java Type | Accepted Input | Example Input |\n|----------------|--------------------------------------|---------------|\n| Any `Enum` | The exact name of an enum constant. | `SURVIVAL` |\n\nTab-completion suggestions are automatically generated from the enum constants.\n\n### Example\n\n```java\npublic enum GameMode { SURVIVAL, CREATIVE, ADVENTURE }\n\n@RootCommand(\"setmode\")\npublic class SetModeCommand {\n\n @Execute\n public void setMode(PLATFORMSOURCE source, @Named(\"mode\") GameMode mode) {\n source.reply(\"Mode set to \" + mode.name());\n }\n}\n```\n\n`/setmode CREATIVE` → parses `CREATIVE` as `GameMode.CREATIVE`.\n\n## Generic / Wrapper Types\n\nImperat can automatically resolve generic wrapper types as long as the **inner type**(`T`) is itself a registered type.\n\n### `Optional`\n\nWraps the parsed value in `java.util.Optional`. If parsing fails, the result is `Optional.empty()`.\n\n```java\n@Execute\npublic void greet(PLATFORMSOURCE source, @Named(\"name\") Optional name) {\n source.reply(\"Hello, \" + name.orElse(\"world\") + \"!\");\n}\n```\n\n:::note\nThis does **NOT** make the argument **optional** in the sense that it can be omitted from the command input. \nThe argument is still required, but if the user provides an invalid value, it will be treated as `Optional.empty()` instead of causing a parsing error.\n:::\n\n### `CompletableFuture`\n\nParses the value asynchronously, returning a `CompletableFuture`.\n\n```java\n@Execute\npublic void lookup(PLATFORMSOURCE source, @Named(\"id\") CompletableFuture id) {\n id.thenAccept(uuid -> source.reply(\"UUID: \" + uuid));\n}\n```\n\n### `Either`\n\nTries to parse the input as type `A` first. If that fails, it falls back to type `B`.\n\n```java\n@Execute\npublic void find(PLATFORMSOURCE source, @Named(\"target\") Either target) {\n target.getPrimary().ifPresent(id -> source.reply(\"Found by ID: \" + id));\n target.getFallback().ifPresent(name -> source.reply(\"Found by name: \" + name));\n}\n```\n\n`/find 42` → parses as `Integer` (primary). \n`/find Steve` → fails integer parse, falls back to `String`.\n\n## Collection Types\n\nImperat supports collection parameters. The element type must be a registered type. Collections are **greedy** — they consume multiple space-separated arguments.\n\n| Java Type | Default Implementation |\n|---------------------|------------------------|\n| `List` | `ArrayList` |\n| `Set` | `HashSet` |\n| `Queue` | `LinkedList` |\n| `Deque` | `ArrayDeque` |\n| `Collection` | `ArrayList` |\n\nMany concrete implementations are also supported (`LinkedList`, `TreeSet`, `CopyOnWriteArrayList`, `PriorityQueue`, etc.).\n\n:::tip\nYou can define specific implementations as the type and they will be used instead.\nALL java collection implementations are supported, as long as the element type is registered.\n:::\n\n### Example\n\n```java\n@Execute\npublic void ban(PLATFORMSOURCE source, @Named(\"players\") List players) {\n for (String player : players) {\n source.reply(\"Banned: \" + player);\n }\n}\n```\n\n`/ban Alice Bob Charlie` → `players` = `[\"Alice\", \"Bob\", \"Charlie\"]`\n\n## Array Types\n\nArray parameters work identically to collections — they consume multiple arguments greedily.\n:::info\nAny `T[]` type is supported, as long as `T` is a registered type.\n:::\n\n```java\n@Execute\npublic void tag(PLATFORMSOURCE source, @Named(\"names\") String[] names) {\n source.reply(\"Tagged \" + names.length + \" players.\");\n}\n```\n\n## Map Types\n\nMap parameters parse entries in `key=value` format, separated by spaces.\n\n| Java Type | Default Implementation |\n|------------------------|------------------------|\n| `Map` | `HashMap` |\n| `LinkedHashMap` | `LinkedHashMap` |\n| `TreeMap` | `TreeMap` |\n| `ConcurrentHashMap` | `ConcurrentHashMap` |\n\n:::info\nAny pre-defined `Map` type is supported, as long as both `K` and `V` are registered types.\n:::\n\n### Example\n\n```java\n@Execute\npublic void config(PLATFORMSOURCE source, @Named(\"settings\") Map settings) {\n settings.forEach((k, v) -> source.reply(k + \" = \" + v));\n}\n```\n\n`/config render_distance=16 max_fps=120` → `{\"render_distance\": 16, \"max_fps\": 120}`\n\n## Registering a Custom Type\n\nIf you need a type that is not built-in, register it on the config builder:\n\n```java\nPLATFORMIMPERAT imperat = PLATFORMIMPERAT.builder(plugin)\n .registerArgType(MyType.class, new MyTypeArgument())\n .build();\n```\n\nWhere `MyTypeArgument` extends `ArgumentType` and implements the `parse` method.\n\n","frontmatter":{"title":"Supported Types","description":"The pre-defines argument types that are supported on all platforms, and how to register custom types.","order":4},"project":"Imperat","version":"v4","category":"Arguments Masterclass","extension":".mdx","lastUpdatedAt":"2026-04-27T07:18:41+03:00","contributors":[{"name":"Mqzn","email":"mezoahmed2507@gmail.com"}],"toc":[{"level":2,"text":"Simple Types","id":"simple-types"},{"level":2,"text":"Numeric Types","id":"numeric-types"},{"level":2,"text":"Date / Time Types","id":"date-time-types"},{"level":2,"text":"Misc JDK Types","id":"misc-jdk-types"},{"level":2,"text":"Enum Types","id":"enum-types"},{"level":3,"text":"Example","id":"example"},{"level":2,"text":"Generic / Wrapper Types","id":"generic-wrapper-types"},{"level":3,"text":"`Optional`","id":"optionalt"},{"level":3,"text":"`CompletableFuture`","id":"completablefuturet"},{"level":3,"text":"`Either`","id":"eithera-b"},{"level":2,"text":"Collection Types","id":"collection-types"},{"level":3,"text":"Example","id":"example-1"},{"level":2,"text":"Array Types","id":"array-types"},{"level":2,"text":"Map Types","id":"map-types"},{"level":3,"text":"Example","id":"example-2"},{"level":2,"text":"Registering a Custom Type","id":"registering-a-custom-type"}]}
Skip to content