Collection<Object> (Object object) { MetaClass metaClass = DefaultGroovyMethods.getMetaClass(object); List<MetaMethod> getSourcePaths = metaClass.respondsTo(object, "getSourcePaths"); if (!getSourcePaths.isEmpty()) { //noinspection unchecked,SSBasedInspection return (Collection<Object>)getSourcePaths.get(0).invoke(object, new Object[0]); } else if (metaClass.hasProperty(object, "sourcePaths") != null) { //noinspection unchecked return (Collection<Object>)metaClass.getProperty(object, "sourcePaths"); } return null; }