Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2011 UrsaJ Ltd ( Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
import static com.ursaj.hfs.util.HfsUtils.UUID_COMPARATOR;

In-memory service to work with stored files information (for tests or example usage).

<T> File information type your application works with.
public final class HfsMemoryFileService<T extends HfsFileInfoimplements HfsFileService<T> {
Uploaded files storage.
    public Map<UUID, T> getFiles(Set<UUIDfileIds) {
        Map<UUID, T> map = new HashMap<>(fileIds.size(), 1.0f);
        for (UUID fileId : fileIds)
        return Collections.unmodifiableMap(map);
    public void storeFiles(Collection<T> fileInfosthrows IOException {
        for (T fileInfo : fileInfos)
            if (.putIfAbsent(fileInfo.getFileId(), fileInfo) != null)
                throw new IOException("Failed to store file information with duplicated ID: " + fileInfo.getFileId());
    public boolean collectAliveFiles(UUID fromIdConsumer<UUIDIOExceptionconsumerthrows IOException {
        for (UUID fileId : .tailMap(fromId).keySet())
            if (!consumer.offer(fileId))
                return false;
        return true;
New to GrepCode? Check out our FAQ X