org.scijava.plugin.Plugin.type()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中org.scijava.plugin.Plugin.type()方法的一些代码示例,展示了Plugin.type()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Plugin.type()方法的具体详情如下:
包路径:org.scijava.plugin.Plugin
类名称:Plugin
方法名:type

Plugin.type介绍

暂无

代码示例

代码示例来源:origin: org.scijava/scijava-common

/**
 * Gets the plugin type of the given plugin class, as declared by its
 * {@code @Plugin} annotation (i.e., {@link Plugin#type()}).
 * 
 * @param pluginClass The plugin class whose plugin type is needed.
 * @return The plugin type, or null if no {@link Plugin} annotation exists for
 *         the given class.
 */
public static <PT extends SciJavaPlugin, P extends PT> Class<PT> getPluginType(
  final Class<P> pluginClass)
{
  final Plugin annotation = pluginClass.getAnnotation(Plugin.class);
  if (annotation == null) return null;
  @SuppressWarnings("unchecked")
  final Class<PT> type = (Class<PT>) annotation.type();
  return type;
}

代码示例来源:origin: scijava/scijava-common

/**
 * Gets the plugin type of the given plugin class, as declared by its
 * {@code @Plugin} annotation (i.e., {@link Plugin#type()}).
 * 
 * @param pluginClass The plugin class whose plugin type is needed.
 * @return The plugin type, or null if no {@link Plugin} annotation exists for
 *         the given class.
 */
public static <PT extends SciJavaPlugin, P extends PT> Class<PT> getPluginType(
  final Class<P> pluginClass)
{
  final Plugin annotation = pluginClass.getAnnotation(Plugin.class);
  if (annotation == null) return null;
  @SuppressWarnings("unchecked")
  final Class<PT> type = (Class<PT>) annotation.type();
  return type;
}

代码示例来源:origin: imagej/imagej-ops

/**
 * Gets the type of op, as specified via {@code @Plugin(type = <type>)}).
 */
public Class<? extends Op> getType() {
  // HACK: The CommandInfo.getPluginType() method returns Command.class.
  // But we want to get the actual type of the wrapped PluginInfo.
  // CommandInfo does not have a getPluginInfo() unwrap method, though.
  // So let's extract the type directly from the @Plugin annotation.
  final Class<? extends SciJavaPlugin> type = cInfo.getAnnotation().type();
  if (type == null || !Op.class.isAssignableFrom(type)) {
    throw new IllegalStateException("Op type " + type + " is not an Op!");
  }
  @SuppressWarnings("unchecked")
  final Class<? extends Op> opType = (Class<? extends Op>) type;
  return opType;
}

代码示例来源:origin: imagej/imagej-ops

/**
 * Similar to {@link #opString(ModuleInfo)} but prints a cleaner,
 * more abstract representation of the Op method call in the format
 * {@code return <= baseOp(param1, param2)}. Intended to be presented to users
 * as the limited information reduces utility for debugging.
 */
public static String simpleString(final CommandInfo info) {
  final StringBuilder sb = new StringBuilder();
  final String outputString = paramString(outputs(info), null, ", ").trim();
  if (!outputString.isEmpty()) sb.append("" + outputString + "  <=  ");
  final Class<? extends SciJavaPlugin> type = info.getAnnotation().type();
  sb.append(type.getSimpleName());
  sb.append("(" + paramString(inputs(info), null, ", ") + ")");
  return sb.toString().replaceAll("\n|\t", "");
}

代码示例来源:origin: imagej/imagej-ops

/**
 * Returns a method call for the given {@link Op} using its name and the
 * correct count of parameters. Assumes the op will be called via an
 * {@link OpService} of the name "ops".
 */
public static String opCall(final CommandInfo info) {
  StringBuilder sb = new StringBuilder();
  sb.append("ops.run(");
  try {
    // try using the short name
    final String shortName = getOpName(info);
    sb.append("\"");
    sb.append(shortName);
    sb.append("\"");
  } catch (final Exception e) {
    // Use the class name if any errors pop up
    sb.append(info.getAnnotation().type().getName());
  }
  for (final ModuleItem<?> item : inputs(info)) {
    sb.append(", ");
    sb.append(item.getType().getSimpleName());
  }
  sb.append(")");
  return sb.toString();
}

代码示例来源:origin: org.scijava/scijava-common

private PluginInfo<SciJavaPlugin> createInfo(
  final IndexItem<Plugin> item, final ClassLoader classLoader)
{
  final String className = item.className();
  final Plugin plugin = item.annotation();
  @SuppressWarnings("unchecked")
  final Class<SciJavaPlugin> pluginType =
    (Class<SciJavaPlugin>) plugin.type();
  return new PluginInfo<>(className, pluginType, plugin, classLoader);
}

代码示例来源:origin: scijava/scijava-common

private PluginInfo<SciJavaPlugin> createInfo(
  final IndexItem<Plugin> item, final ClassLoader classLoader)
{
  final String className = item.className();
  final Plugin plugin = item.annotation();
  @SuppressWarnings("unchecked")
  final Class<SciJavaPlugin> pluginType =
    (Class<SciJavaPlugin>) plugin.type();
  return new PluginInfo<>(className, pluginType, plugin, classLoader);
}

相关文章

微信公众号

最新文章

更多