@@ -0,0 +1,1695 @@
+package gq.baijie.catalog.usecase;%0A%0Aimport java.security.MessageDigest;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport gq.baijie.catalog.entity.DirectoryFile;%0Aimport gq.baijie.catalog.entity.File;%0Aimport gq.baijie.catalog.entity.Hash;%0Aimport gq.baijie.catalog.entity.RegularFile;%0A%0Apublic class GatherFileInformation implements UseCase %7B%0A%0A    private final DirectoryFile rootDirectoryFile;%0A%0A    private final Hash.Algorithm%5B%5D algorithms;%0A%0A    public GatherFileInformation(DirectoryFile rootDirectoryFile, Hash.Algorithm%5B%5D algorithms) %7B%0A        this.rootDirectoryFile = rootDirectoryFile;%0A        this.algorithms = algorithms.clone();%0A    %7D%0A%0A    @Override%0A    public void execute() %7B%0A        new ScanFileSystem(rootDirectoryFile).execute();%0A        hashFiles();%0A    %7D%0A%0A    private void hashFiles() %7B%0A        if (algorithms.length == 0) %7B%0A            return;%0A        %7D%0A        Map%3CHash.Algorithm, MessageDigest%3E messageDigestCache = new HashMap%3C%3E();%0A        hashFiles(rootDirectoryFile, messageDigestCache);%0A    %7D%0A%0A    private void hashFiles(%0A            DirectoryFile directory, Map%3CHash.Algorithm, MessageDigest%3E messageDigestCache) %7B%0A        for (final File file : directory.getContent()) %7B%0A            if (file instanceof DirectoryFile) %7B%0A                hashFiles((DirectoryFile) file, messageDigestCache);%0A            %7D else if (file instanceof RegularFile) %7B%0A                final RegularFile regularFile = (RegularFile) file;%0A                for (Hash.Algorithm algorithm : algorithms) %7B%0A                    regularFile.getHashs().add(new Hash(algorithm));%0A                %7D%0A                new HashFile(regularFile, messageDigestCache).execute();%0A            %7D%0A        %7D%0A    %7D%0A%0A%7D%0A

add GatherFileInformation Use Case