public class InterfacesHelper {
+ private InterfacesHelper() {
+ }
+
public static Set<Class<?>> getAllInterfaces(Class<?> clazz) {
if (clazz.isInterface()) {
throw new IllegalArgumentException(clazz
}
private static Set<Class<?>> getAllSuperInterfaces(Set<Class<?>> ifcs) {
- ifcs = new HashSet<>(ifcs); // create copy to modify
+ Set<Class<?>> interfaces = new HashSet<>(ifcs); // create copy to modify
// each interface can extend other interfaces
Set<Class<?>> result = new HashSet<>();
- while (ifcs.size() > 0) {
- Iterator<Class<?>> iterator = ifcs.iterator();
+ while (!interfaces.isEmpty()) {
+ Iterator<Class<?>> iterator = interfaces.iterator();
Class<?> ifc = iterator.next();
iterator.remove();
if (ifc.isInterface() == false) {
throw new IllegalArgumentException(ifc + " should be an interface");
}
- ifcs.addAll(Arrays.asList(ifc.getInterfaces()));
+ interfaces.addAll(Arrays.asList(ifc.getInterfaces()));
result.add(ifc);
}
return result;
*/
public static Set<Class<?>> getOsgiRegistrationTypes(
Class<? extends Module> configBeanClass) {
- // TODO test with service interface hierarchy
Set<Class<?>> serviceInterfaces = getServiceInterfaces(configBeanClass);
Set<Class<?>> result = new HashSet<>();
for (Class<?> clazz : serviceInterfaces) {
return result;
}
+ public static Set<String> getQNames(Set<ServiceInterfaceAnnotation> siAnnotations) {
+ Set<String> qNames = new HashSet<>();
+ for (ServiceInterfaceAnnotation sia: siAnnotations) {
+ qNames.add(sia.value());
+ }
+ return Collections.unmodifiableSet(qNames);
+ }
public static Set<ServiceInterfaceAnnotation> getServiceInterfaceAnnotations(ModuleFactory factory) {
Set<Class<? extends AbstractServiceInterface>> implementedServiceIntefaces = Collections.unmodifiableSet(factory.getImplementedServiceIntefaces());
result.add(annotation);
}
}
- return result;
+ return Collections.unmodifiableSet(result);
}
static Set<Class<? extends AbstractServiceInterface>> getAllAbstractServiceInterfaceClasses(