Represents an implementation of the plain Plugin plugin. @since 1.0
| 17 | * @since 1.0 |
| 18 | */ |
| 19 | public final class JetPlugin implements Plugin { |
| 20 | |
| 21 | private final PluginMetadata metadata; |
| 22 | private final Object instance; |
| 23 | |
| 24 | private final URLClassLoader classLoader; |
| 25 | |
| 26 | /** |
| 27 | * Constructs the {@linkplain JetPlugin plugin}. |
| 28 | * |
| 29 | * @param metadata a metadata that the plugin should have |
| 30 | * @param instance an instance that should be associated with the plugin |
| 31 | * @param classLoader a class loader that the plugin has been loaded with |
| 32 | * @since 1.0 |
| 33 | */ |
| 34 | public JetPlugin(@NonNull PluginMetadata metadata, @NonNull Object instance, @NonNull URLClassLoader classLoader) { |
| 35 | this.metadata = Objects.requireNonNull(metadata, "metadata"); |
| 36 | this.instance = Objects.requireNonNull(instance, "instance"); |
| 37 | this.classLoader = Objects.requireNonNull(classLoader, "class loader"); |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public @NonNull String name() { |
| 42 | return this.metadata.name(); |
| 43 | } |
| 44 | |
| 45 | @Override |
| 46 | public @NonNull String version() { |
| 47 | return this.metadata.version(); |
| 48 | } |
| 49 | |
| 50 | @Override |
| 51 | public @NonNull Set<String> authors() { |
| 52 | return this.metadata.authors(); |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public @NonNull Set<PluginDependency> dependencies() { |
| 57 | return this.metadata.dependencies(); |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public @Nullable String getEntrypoint(@NonNull Key key) { |
| 62 | return this.metadata.entrypoints().get(key); |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public @NonNull Object instance() { |
| 67 | return this.instance; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Gets {@linkplain URLClassLoader an URL class loader}, which was used to load the plugin. |
| 72 | * |
| 73 | * @return the URL class loader |
| 74 | * @since 1.0 |
| 75 | */ |
| 76 | public @NonNull URLClassLoader classLoader() { |
nothing calls this directly
no outgoing calls
no test coverage detected