@Override public DatabaseBranches clone() { DatabaseBranches clonedBranches = new DatabaseBranches(); clonedBranches.branches.putAll(branches); return clonedBranches; } }
/** * This methods takes a Map containing DatabaseVersions (headers only) and loads these headers into {@link DatabaseBranches}. * In addition, the local branch is added to this. The resulting DatabaseBranches will contain all headers exactly once, * for the client that created that version. * * @param localBranch {@link DatabaseBranch} containing the locally known headers. * @param remoteDatabaseHeaders Map from {@link DatabaseRemoteFile}s (important for client names) to the {@link DatabaseVersion}s that are * contained in these files. * * @return DatabaseBranches filled with all the headers that originated from either of the parameters. */ private DatabaseBranches populateDatabaseBranches(DatabaseBranch localBranch, SortedMap<DatabaseRemoteFile, List<DatabaseVersion>> remoteDatabaseHeaders) { DatabaseBranches allBranches = new DatabaseBranches(); allBranches.put(config.getMachineName(), localBranch.clone()); for (DatabaseRemoteFile remoteDatabaseFile : remoteDatabaseHeaders.keySet()) { // Populate branches DatabaseBranch remoteClientBranch = allBranches.getBranch(remoteDatabaseFile.getClientName(), true); for (DatabaseVersion remoteDatabaseVersion : remoteDatabaseHeaders.get(remoteDatabaseFile)) { DatabaseVersionHeader header = remoteDatabaseVersion.getHeader(); remoteClientBranch.add(header); } } logger.log(Level.INFO, "Populated unknown branches: " + allBranches); return allBranches; }