@SuppressWarnings( "unchecked" ) public <T extends Repository> Repository clone(T repo, String newId) throws RepositoryException { if (repo instanceof RemoteRepository ) { return this.clone((RemoteRepository)repo, newId); } else if (repo instanceof ManagedRepository) { return this.clone((ManagedRepository)repo, newId); } else { throw new RepositoryException("This repository class is not supported "+ repo.getClass().getName()); } }