Skip to content

Commit

Permalink
Rename some bolt interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielsherry committed Jan 10, 2024
1 parent 773a220 commit 8694a98
Show file tree
Hide file tree
Showing 30 changed files with 109 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

import org.peakaboo.framework.bolt.Bolt;
import org.peakaboo.framework.bolt.plugin.config.container.BoltConfigContainer;
import org.peakaboo.framework.bolt.plugin.core.BoltPluginPrototype;
import org.peakaboo.framework.bolt.plugin.core.PluginDescriptor;
import org.peakaboo.framework.bolt.plugin.core.PluginRegistry;
import org.peakaboo.framework.bolt.plugin.core.container.BoltContainer;

public class BoltConfigPluginPrototype<T extends BoltConfigPlugin> implements BoltPluginPrototype<T> {
public class BoltConfigPluginDescriptor<T extends BoltConfigPlugin> implements PluginDescriptor<T> {

private BoltConfigPluginBuilder<T> builder;
private Class<T> pluginClass;
private T reference;
private BoltConfigContainer<T> container;
private PluginRegistry<T> registry;

public BoltConfigPluginPrototype(PluginRegistry<T> registry, BoltConfigPluginBuilder<T> builder, Class<T> pluginClass, BoltConfigContainer<T> container) {
public BoltConfigPluginDescriptor(PluginRegistry<T> registry, BoltConfigPluginBuilder<T> builder, Class<T> pluginClass, BoltConfigContainer<T> container) {
this.builder = builder;
this.pluginClass = pluginClass;
this.container = container;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import org.peakaboo.framework.bolt.plugin.config.BoltConfigPlugin;
import org.peakaboo.framework.bolt.plugin.config.BoltConfigPluginBuilder;
import org.peakaboo.framework.bolt.plugin.config.BoltConfigPluginPrototype;
import org.peakaboo.framework.bolt.plugin.core.BoltPluginPrototype;
import org.peakaboo.framework.bolt.plugin.config.BoltConfigPluginDescriptor;
import org.peakaboo.framework.bolt.plugin.core.PluginDescriptor;
import org.peakaboo.framework.bolt.plugin.core.BoltPluginSet;
import org.peakaboo.framework.bolt.plugin.core.PluginRegistry;
import org.peakaboo.framework.bolt.plugin.core.container.BoltURLContainer;
Expand All @@ -28,7 +28,7 @@ public BoltConfigContainer(PluginRegistry<T> manager, URL url, Class<T> pluginCl
this.manager = manager;

plugins = new BoltPluginSet<>(manager);
BoltConfigPluginPrototype<T> plugin = new BoltConfigPluginPrototype<>(this.manager, builder, pluginClass, this);
BoltConfigPluginDescriptor<T> plugin = new BoltConfigPluginDescriptor<>(this.manager, builder, pluginClass, this);
plugins.addPlugin(plugin);
}

Expand All @@ -37,7 +37,7 @@ public InputStream openStream() throws IOException {
}

@Override
public List<BoltPluginPrototype<? extends T>> getPlugins() {
public List<PluginDescriptor<? extends T>> getPlugins() {
return plugins.getPlugins();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public String getAssetPath() {
}

@Override
public final synchronized List<BoltPluginPrototype<? extends P>> getPlugins() {
public final synchronized List<PluginDescriptor<? extends P>> getPlugins() {
load();
return plugins.getPlugins();
}
Expand Down Expand Up @@ -108,9 +108,9 @@ private List<BoltIssue<? extends P>> findIssues() {
//we're not responsible for detecting empty containers
if (container.isEmpty()) { continue; }

for (BoltPluginPrototype<? extends P> plugin : container.getPlugins()) {
for (PluginDescriptor<? extends P> plugin : container.getPlugins()) {
//look up the newest version of this plugin by UUID
BoltPluginPrototype<? extends P> newest = getByUUID(plugin.getUUID());
PluginDescriptor<? extends P> newest = getByUUID(plugin.getUUID());
if (newest.isNewerThan(plugin)) {
outdated = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* Convenience class to manage plugins and issues. Not generally intended for
* high-level use.
*/
public class BoltPluginSet<T extends BoltPlugin> implements BoltPluginCollection<T> {
public class BoltPluginSet<T extends BoltPlugin> implements PluginCollection<T> {

private ArrayList<BoltPluginPrototype<? extends T>> plugins = new ArrayList<>();
private ArrayList<PluginDescriptor<? extends T>> plugins = new ArrayList<>();
private ArrayList<BoltIssue<? extends T>> issues = new ArrayList<>();

private PluginRegistry<T> manager;
Expand All @@ -22,19 +22,19 @@ public BoltPluginSet(PluginRegistry<T> manager) {
this.manager = manager;
}

public List<BoltPluginPrototype<? extends T>> getPlugins() {
public List<PluginDescriptor<? extends T>> getPlugins() {
return Collections.unmodifiableList(plugins);
}

public void addPlugin(BoltPluginPrototype<? extends T> plugin) {
public void addPlugin(PluginDescriptor<? extends T> plugin) {
if (plugins.contains(plugin)) {
return;
}
String uuid = plugin.getUUID();
if (this.hasUUID(uuid)) {
//there is already a plugin with the same UUID.
//we have to choose which of these to load
BoltPluginPrototype<? extends T> existingPlugin = this.getByUUID(uuid);
PluginDescriptor<? extends T> existingPlugin = this.getByUUID(uuid);

if (plugin.isUpgradeFor(existingPlugin)) {
plugins.remove(existingPlugin);
Expand All @@ -50,8 +50,8 @@ public void addPlugin(BoltPluginPrototype<? extends T> plugin) {

}

public void loadFrom(BoltPluginCollection<? extends T> pluginset) {
for (BoltPluginPrototype<? extends T> t : pluginset.getPlugins()) {
public void loadFrom(PluginCollection<? extends T> pluginset) {
for (PluginDescriptor<? extends T> t : pluginset.getPlugins()) {
addPlugin(t);
}
for (BoltIssue<? extends T> i : pluginset.getIssues()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
* Interface for exposing a set of {@link BoltPlugin}s and {@link BoltIssue}s
* in a read-only way.
*/
public interface BoltPluginCollection<T extends BoltPlugin> extends Iterable<BoltPluginPrototype<? extends T>> {
public interface PluginCollection<T extends BoltPlugin> extends Iterable<PluginDescriptor<? extends T>> {

List<BoltPluginPrototype<? extends T>> getPlugins();
List<PluginDescriptor<? extends T>> getPlugins();

default Iterator<BoltPluginPrototype<? extends T>> iterator() {
default Iterator<PluginDescriptor<? extends T>> iterator() {
return getPlugins().iterator();
}

Expand All @@ -30,16 +30,16 @@ default List<T> newInstances() {

PluginRegistry<T> getManager();

default BoltPluginPrototype<? extends T> getByUUID(String uuid) {
for (BoltPluginPrototype<? extends T> plugin : getPlugins()) {
default PluginDescriptor<? extends T> getByUUID(String uuid) {
for (PluginDescriptor<? extends T> plugin : getPlugins()) {
if (plugin.getUUID().equals(uuid)) {
return plugin;
}
}
return null;
}

default Optional<BoltPluginPrototype<? extends T>> getByClass(Class<? extends T> cls) {
default Optional<PluginDescriptor<? extends T>> getByClass(Class<? extends T> cls) {
synchronized(this) {
for (var plugin : getPlugins()) {
if (plugin.getReferenceInstance().getClass().equals(cls)) {
Expand Down Expand Up @@ -72,7 +72,7 @@ default boolean isEmpty() {
* @param other the other collection to compare against
* @return true if this collection is a proper upgrade for the other, false otherwise
*/
default boolean isUpgradeFor(BoltPluginCollection<? extends T> other) {
default boolean isUpgradeFor(PluginCollection<? extends T> other) {
//get all the UUIDs from the other plugin set
List<String> otherUUIDs = other.getPlugins().stream().map(p -> p.getUUID()).collect(Collectors.toList());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import org.peakaboo.framework.bolt.plugin.core.container.BoltContainer;

/**
* A BoltPluginPrototype wraps a single plugin and allows it to be managed and introspected.
* A {@link PluginDescriptor} wraps a single plugin and allows it to be introspected and new instances created.
* @author NAS
*
* @param <T>
*/
public interface BoltPluginPrototype<T extends BoltPlugin> {
public interface PluginDescriptor<T extends BoltPlugin> {

Class<? extends T> getImplementationClass();

Expand Down Expand Up @@ -58,7 +58,7 @@ public interface BoltPluginPrototype<T extends BoltPlugin> {
* @param other the plugin to test against
* @return true if this plugin's version is newer or the same, false if this plugin version is older, or if the UUIDs don't match
*/
default boolean isUpgradeFor(BoltPluginPrototype<?> other) {
default boolean isUpgradeFor(PluginDescriptor<?> other) {
if (!getUUID().equals(other.getUUID())) {
return false;
}
Expand All @@ -72,7 +72,7 @@ default boolean isUpgradeFor(BoltPluginPrototype<?> other) {
}
}

default boolean isNewerThan(BoltPluginPrototype<?> other) {
default boolean isNewerThan(PluginDescriptor<?> other) {
if (!getUUID().equals(other.getUUID())) {
return false;
}
Expand All @@ -88,8 +88,8 @@ default boolean isNewerThan(BoltPluginPrototype<?> other) {

/**
* Returns a SavedPlugin object describing the plugin represented by this
* prototype. The SavedPlugin will be based on a freshly created instance of the
* plugin.
* {@link PluginDescriptor}. The SavedPlugin will be based on a freshly created
* instance of the plugin.
*/
default SavedPlugin save() {
return new SavedPlugin(create());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
public interface PluginPreset<P extends BoltPlugin> {

/**
* Returns a prototype of the preset choice of implementation for this plugin
* interface, if one has been set.
* Returns a {@link PluginDescriptor} of the preset choice of implementation for
* this plugin interface, if one has been set.
*/
BoltPluginPrototype<? extends P> getPreset();
PluginDescriptor<? extends P> getPreset();

default P getPresetInstance() {
return getPreset().create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.peakaboo.framework.bolt.plugin.core.issue.BoltIssue;
import org.peakaboo.framework.bolt.plugin.core.loader.BoltLoader;

public interface PluginRegistry <P extends BoltPlugin> extends BoltPluginCollection<P> {
public interface PluginRegistry <P extends BoltPlugin> extends PluginCollection<P> {

/**
* Gets a string containing only letters, numbers and dashes. This string identifies the type of plugins
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.peakaboo.framework.bolt.plugin.core.container;

import org.peakaboo.framework.bolt.plugin.core.BoltPlugin;
import org.peakaboo.framework.bolt.plugin.core.BoltPluginCollection;
import org.peakaboo.framework.bolt.plugin.core.PluginCollection;

public interface BoltContainer<T extends BoltPlugin> extends BoltPluginCollection<T> {
public interface BoltContainer<T extends BoltPlugin> extends PluginCollection<T> {

String getSourcePath();
String getSourceName();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package org.peakaboo.framework.bolt.plugin.core.issue;

import org.peakaboo.framework.bolt.plugin.core.BoltPlugin;
import org.peakaboo.framework.bolt.plugin.core.BoltPluginPrototype;
import org.peakaboo.framework.bolt.plugin.core.PluginDescriptor;

/**
* This plugin is out of date
*/
public class BoltOldPluginIssue<T extends BoltPlugin> implements BoltPluginIssue<T> {

protected BoltPluginPrototype<? extends T> proto;
protected PluginDescriptor<? extends T> proto;

public BoltOldPluginIssue(BoltPluginPrototype<? extends T> proto) {
public BoltOldPluginIssue(PluginDescriptor<? extends T> proto) {
this.proto = proto;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
import java.util.logging.Level;

import org.peakaboo.framework.bolt.Bolt;
import org.peakaboo.framework.bolt.plugin.core.BoltPluginPrototype;
import org.peakaboo.framework.bolt.plugin.core.PluginDescriptor;
import org.peakaboo.framework.bolt.plugin.core.PluginRegistry;
import org.peakaboo.framework.bolt.plugin.core.container.BoltContainer;

public class BoltJavaPluginPrototype<T extends BoltJavaPlugin> implements BoltPluginPrototype<T> {
public class BoltJavaPluginDescriptor<T extends BoltJavaPlugin> implements PluginDescriptor<T> {

private Class<T> pluginClass;
private Class<? extends T> implClass;
private BoltContainer<T> container;
private T instance;
private PluginRegistry<T> registry;

public BoltJavaPluginPrototype(PluginRegistry<T> registry, Class<T> pluginClass, Class<? extends T> implClass, BoltContainer<T> container) {
public BoltJavaPluginDescriptor(PluginRegistry<T> registry, Class<T> pluginClass, Class<? extends T> implClass, BoltContainer<T> container) {
this.pluginClass = pluginClass;
this.implClass = implClass;
this.container = container;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import java.util.logging.Level;

import org.peakaboo.framework.bolt.Bolt;
import org.peakaboo.framework.bolt.plugin.core.BoltPluginPrototype;
import org.peakaboo.framework.bolt.plugin.core.PluginDescriptor;
import org.peakaboo.framework.bolt.plugin.core.BoltPluginSet;
import org.peakaboo.framework.bolt.plugin.core.PluginRegistry;
import org.peakaboo.framework.bolt.plugin.core.container.BoltContainer;
import org.peakaboo.framework.bolt.plugin.core.issue.BoltIssue;
import org.peakaboo.framework.bolt.plugin.java.BoltJar;
import org.peakaboo.framework.bolt.plugin.java.BoltJavaPlugin;
import org.peakaboo.framework.bolt.plugin.java.BoltJavaPluginPrototype;
import org.peakaboo.framework.bolt.plugin.java.BoltJavaPluginDescriptor;
import org.peakaboo.framework.bolt.plugin.java.issue.BoltBrokenJavaPluginIssue;

public abstract class BoltJavaContainer<T extends BoltJavaPlugin> implements BoltContainer<T> {
Expand All @@ -28,7 +28,7 @@ public BoltJavaContainer(PluginRegistry<T> manager, Class<T> targetClass) {
}

@Override
public List<BoltPluginPrototype<? extends T>> getPlugins() {
public List<PluginDescriptor<? extends T>> getPlugins() {
return plugins.getPlugins();
}

Expand All @@ -46,7 +46,7 @@ protected void add(Class<? extends T> loadedClass) {
return;
}

BoltPluginPrototype<T> plugin = new BoltJavaPluginPrototype<>(this.manager, targetClass, loadedClass, this);
PluginDescriptor<T> plugin = new BoltJavaPluginDescriptor<>(this.manager, targetClass, loadedClass, this);

if (plugin.isEnabled()) {
plugins.addPlugin(plugin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.peakaboo.curvefit.peak.table.PeakTable;
import org.peakaboo.curvefit.peak.transition.ITransitionSeries;
import org.peakaboo.display.plot.PlotData;
import org.peakaboo.framework.bolt.plugin.core.BoltPluginPrototype;
import org.peakaboo.framework.bolt.plugin.core.PluginDescriptor;
import org.peakaboo.framework.cyclops.spectrum.SpectrumView;
import org.peakaboo.framework.cyclops.util.Mutable;
import org.peakaboo.framework.eventful.EventfulType;
Expand Down Expand Up @@ -416,14 +416,14 @@ public void setFWHMBase(float base) {
setUndoPoint("Change Peak Shape");
}

public void setFittingFunction(BoltPluginPrototype<? extends FittingFunction> cls) {
public void setFittingFunction(PluginDescriptor<? extends FittingFunction> cls) {
fittingModel.selections.getFittingParameters().setFittingFunction(cls);
fittingModel.proposals.getFittingParameters().setFittingFunction(cls);
fittingDataInvalidated();
setUndoPoint("Change Peak Model");
}

public BoltPluginPrototype<? extends FittingFunction> getFittingFunction() {
public PluginDescriptor<? extends FittingFunction> getFittingFunction() {
return fittingModel.selections.getFittingParameters().getFittingFunction();
}

Expand Down Expand Up @@ -600,7 +600,7 @@ public List<String> load(SavedFittings saved) {

//Restore the fitting function
try {
BoltPluginPrototype<? extends FittingFunction> oProto = FittingFunctionRegistry.system().getByUUID(saved.model.uuid);
PluginDescriptor<? extends FittingFunction> oProto = FittingFunctionRegistry.system().getByUUID(saved.model.uuid);
if (oProto == null) {
errors.add("Failed to load Fitting Function: " + saved.model.name);
oProto = FittingFunctionRegistry.system().getPreset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.peakaboo.curvefit.peak.fitting.FittingFunctionRegistry;
import org.peakaboo.curvefit.peak.transition.ITransitionSeries;
import org.peakaboo.curvefit.peak.transition.SerializedTransitionSeries;
import org.peakaboo.framework.bolt.plugin.core.BoltPluginPrototype;
import org.peakaboo.framework.bolt.plugin.core.PluginDescriptor;

@Deprecated(since = "6", forRemoval = true)
public class SavedFittingSessionV1 {
Expand Down Expand Up @@ -93,7 +93,7 @@ public List<String> loadInto(FittingController controller) {
//Restore the fitting function
try {
var fittingFunctionClass = (Class<? extends FittingFunction>) Class.forName(function);
BoltPluginPrototype<? extends FittingFunction> fitfnProto = FittingFunctionRegistry.system()
PluginDescriptor<? extends FittingFunction> fitfnProto = FittingFunctionRegistry.system()
.getByClass(fittingFunctionClass)
.orElse(FittingFunctionRegistry.system().getPreset());
controller.fittingModel.selections.getFittingParameters().setFittingFunction(fitfnProto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.logging.Level;

import org.peakaboo.app.PeakabooLog;
import org.peakaboo.framework.bolt.plugin.core.BoltPluginPrototype;
import org.peakaboo.framework.bolt.plugin.core.PluginDescriptor;
import org.peakaboo.framework.bolt.plugin.core.BoltPluginRegistry;
import org.peakaboo.framework.bolt.plugin.core.PluginPreset;
import org.peakaboo.framework.bolt.plugin.java.loader.BoltJavaBuiltinLoader;
Expand Down Expand Up @@ -48,7 +48,7 @@ public String getInterfaceDescription() {
return "Channel view modes determine how the spectra in a dataset are presented to the user";
}
@Override
public BoltPluginPrototype<? extends ChannelViewMode> getPreset() {
public PluginDescriptor<? extends ChannelViewMode> getPreset() {
return this.getByClass(AverageViewMode.class).orElseThrow();
}

Expand Down
Loading

0 comments on commit 8694a98

Please sign in to comment.