org.jruby.RubyClass.replaceSubclass()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(72)

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

RubyClass.replaceSubclass介绍

[英]Replace an existing subclass with a new one.
[中]用新的子类替换现有的子类。

代码示例

代码示例来源:origin: org.jruby/jruby-core

/**
 * Actually proceed with including the specified module above the given target
 * in a hierarchy. Return the new module wrapper.
 *
 * @param insertAbove The hierarchy target above which to include the wrapped module
 * @param moduleToInclude The module to wrap and include
 * @return The new module wrapper resulting from this include
 */
private RubyModule proceedWithInclude(RubyModule insertAbove, RubyModule moduleToInclude) {
  // In the current logic, if we getService here we know that module is not an
  // IncludedModuleWrapper, so there's no need to fish out the delegate. But just
  // in case the logic should change later, let's do it anyway
  RubyClass wrapper = new IncludedModuleWrapper(getRuntime(), insertAbove.getSuperClass(), moduleToInclude);
  // if the insertion point is a class, update subclass lists
  if (insertAbove instanceof RubyClass) {
    RubyClass insertAboveClass = (RubyClass)insertAbove;
    // if there's a non-null superclass, we're including into a normal class hierarchy;
    // update subclass relationships to avoid stale parent/child relationships
    if (insertAboveClass.getSuperClass() != null) {
      insertAboveClass.getSuperClass().replaceSubclass(insertAboveClass, wrapper);
    }
    wrapper.addSubclass(insertAboveClass);
  }
  insertAbove.setSuperClass(wrapper);
  insertAbove = insertAbove.getSuperClass();
  return insertAbove;
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Actually proceed with including the specified module above the given target
 * in a hierarchy. Return the new module wrapper.
 *
 * @param insertAbove The hierarchy target above which to include the wrapped module
 * @param moduleToInclude The module to wrap and include
 * @return The new module wrapper resulting from this include
 */
private RubyModule proceedWithInclude(RubyModule insertAbove, RubyModule moduleToInclude) {
  // In the current logic, if we getService here we know that module is not an
  // IncludedModuleWrapper, so there's no need to fish out the delegate. But just
  // in case the logic should change later, let's do it anyway
  RubyClass wrapper = new IncludedModuleWrapper(getRuntime(), insertAbove.getSuperClass(), moduleToInclude);
  // if the insertion point is a class, update subclass lists
  if (insertAbove instanceof RubyClass) {
    RubyClass insertAboveClass = (RubyClass)insertAbove;
    // if there's a non-null superclass, we're including into a normal class hierarchy;
    // update subclass relationships to avoid stale parent/child relationships
    if (insertAboveClass.getSuperClass() != null) {
      insertAboveClass.getSuperClass().replaceSubclass(insertAboveClass, wrapper);
    }
    wrapper.addSubclass(insertAboveClass);
  }
  insertAbove.setSuperClass(wrapper);
  insertAbove = insertAbove.getSuperClass();
  return insertAbove;
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

insertAboveClass.getSuperClass().replaceSubclass(insertAboveClass, wrapper);

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

insertAboveClass.getSuperClass().replaceSubclass(insertAboveClass, wrapper);

代码示例来源:origin: org.jruby/jruby-complete

insertBelowClass.getSuperClass().replaceSubclass(insertBelowClass, prep);

代码示例来源:origin: org.jruby/jruby-core

insertBelowClass.getSuperClass().replaceSubclass(insertBelowClass, prep);

相关文章

微信公众号

最新文章

更多

RubyClass类方法