org.cryptomator.cryptofs.attr.AttributeViewModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cryptofs Show documentation
Show all versions of cryptofs Show documentation
This library provides the Java filesystem provider used by Cryptomator.
package org.cryptomator.cryptofs.attr;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.ClassKey;
import dagger.multibindings.IntoMap;
import javax.inject.Provider;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.DosFileAttributeView;
import java.nio.file.attribute.FileAttributeView;
import java.nio.file.attribute.FileOwnerAttributeView;
import java.nio.file.attribute.PosixFileAttributeView;
import java.util.Map;
import java.util.Optional;
@Module
abstract class AttributeViewModule {
@Binds
@IntoMap
@ClassKey(BasicFileAttributeView.class)
@AttributeViewScoped
public abstract FileAttributeView provideBasicFileAttributeView(CryptoBasicFileAttributeView view);
@Binds
@IntoMap
@ClassKey(PosixFileAttributeView.class)
@AttributeViewScoped
public abstract FileAttributeView providePosixFileAttributeView(CryptoPosixFileAttributeView view);
@Binds
@IntoMap
@ClassKey(DosFileAttributeView.class)
@AttributeViewScoped
public abstract FileAttributeView provideDosFileAttributeView(CryptoDosFileAttributeView view);
@Binds
@IntoMap
@ClassKey(FileOwnerAttributeView.class)
@AttributeViewScoped
public abstract FileAttributeView provideFileOwnerAttributeView(CryptoFileOwnerAttributeView view);
@Provides
@AttributeViewScoped
public static Optional provideAttributeView(Map, Provider> providers, Class extends FileAttributeView> requestedType) {
Provider provider = providers.get(requestedType);
if (provider == null) {
return Optional.empty();
} else {
return Optional.of(provider.get());
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy