jdaugherty commented on code in PR #15409: URL: https://github.com/apache/grails-core/pull/15409#discussion_r2926343387
########## grails-core/src/main/groovy/org/apache/grails/core/plugins/GrailsPluginInfo.java: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.grails.core.plugins; + +import org.springframework.core.io.Resource; + +/** + * Lightweight value class holding plugin metadata needed for ordering and + * configuration loading. Wraps {@link GrailsPluginLoadMetadata} + * with an additional configuration resource reference. + */ +public final class GrailsPluginInfo { + + private final GrailsPluginLoadMetadata metadata; + private final GrailsPluginDescriptor pluginDescriptor; + private final Resource configResource; + private final boolean dynamic; + + /** + * Creates a new {@code PluginInfo}. + * + * @param metadata the plugin metadata from {@link GrailsPluginDiscovery} + * @param configResource the plugin's configuration resource ({@code plugin.yml} or + * {@code plugin.groovy}), or {@code null} if no config file exists + */ + GrailsPluginInfo(GrailsPluginDescriptor pluginDescriptor, GrailsPluginLoadMetadata metadata, Resource configResource, boolean dynamic) { + this.metadata = metadata; + this.pluginDescriptor = pluginDescriptor; + this.configResource = configResource; + this.dynamic = dynamic; + } + + public String name() { + return metadata.name(); + } + + public String pluginVersion() { + return metadata.pluginVersion(); + } + + public Class<?> pluginClass() { + return metadata.pluginClass(); + } + + public Resource configResource() { + return configResource; + } + + public GrailsPluginLoadMetadata metadata() { + return metadata; + } + + public String[] loadAfterNames() { + return metadata.loadAfterNames(); + } + + public String[] loadBeforeNames() { + return metadata.loadBeforeNames(); + } + + public String[] dependsOnNames() { + return metadata.dependsOnNames(); + } + + public String[] observedPluginNames() { + return metadata.observedPluginNames(); + } + + public boolean isDynamic() { + return dynamic; + } + + public String grailsVersion() { + return metadata().grailsVersion(); + } + + public String[] evictions() { + return metadata.evictions(); + } + + public GrailsPluginDescriptor pluginDescriptor() { + return pluginDescriptor; + } Review Comment: I originally tried to have 1 record that was just loaded into, but then I realized that there were nested holders all over the place. My initial attempt was to combine them into one, and my assumption is we'd clean this stuff up later - most likely in Grails 8. The other main benefit was just to pretty names when reference lambda functions; i.e. `GrailsPluginInfo::name` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
