找到一个类所有的子类

Welcome

Latest version of Rebound is version 0.2

Rebound is a Java library for looking up subclasses of a given class or interface using Java reflection. Rebound allows your to look up your classes within a jar file and should work with maven. It finds your classes in your classpath and does not load every class into memory so it should be efficient and fast.

If there is any problem, you are welcome to report them. I will try to help.

Changes from 0.1.4

  1. new rebound constructor was added to allow exclusion of either abstract or interface
  2. remove log4j.properties inside the library
  3. updated junit and fixed minor bugs

Usages

You can use rebound to find subclasses under a given package. By default, Rebound does not include abstract classes and interfaces.

import gigadot.exp.reflects.core.Processor;

Rebound r = new Rebound("gigadot.exp.reflects");
Set<Class<? extends Processor>> classes = r.getSubClassesOf(Processor.class);

If you want to include abstract classes and interfaces, you can use the other constructor to specify the inclusion.

import gigadot.exp.reflects.core.Processor;

Rebound r = new Rebound("gigadot.exp.reflects", true);
Set<Class<? extends Processor>> classes = r.getSubClassesOf(Processor.class);

Notice that the prefix given for filtering does not filter out your given superclass. This is very useful because your superclass is usually not from the same package of your subclasses.

Cautions

Rebound can find your subclasses inside the jar files under your classpath even if the package prefix is empty. However, this process is lengthy and memory consuming. Thus, it is highly recommended not to use Rebound without package prefix.

Rebound has been test with standard maven project but it may not behave correctly when it is integrated with OSGi framework.

Download

Rebound can be downloaded from here - rebound-0.2.jar

Maven

Add the following repository and dependency to your pom.xml in oreder to include Rebound in your project. Rebound depends on apache log4j. You may need to include log4j in your project dependency.

<dependencies>
    <dependency>
        <groupId>gigadot.rebound</groupId>
        <artifactId>rebound</artifactId>
        <version>0.2</version>
    </dependency>
</dependencies>
<repositories>
    <repository>
        <id>gigadot.net</id>
        <url>https://maven2.gigadot.net/</url>
    </repository>
</repositories>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值