本文整理汇总了Java中java.util.EnumSet类的典型用法代码示例。如果您正苦于以下问题:Java EnumSet类的具体用法?Java EnumSet怎么用?Java EnumSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnumSet类属于java.util包,在下文中一共展示了EnumSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMoveRename
import java.util.EnumSet; //导入依赖的package包/类
@Test
public void testMoveRename() throws BackgroundException {
final Directory directory = new MantaDirectoryFeature(session);
final Touch touch = new MantaTouchFeature(session);
final Move move = new MantaMoveFeature(session);
final Delete delete = new MantaDeleteFeature(session);
final AttributesFinder attributesFinder = new MantaAttributesFinderFeature(session);
final Path drive = new MantaDirectoryFeature(session).mkdir(randomDirectory(), "", new TransferStatus());
Path targetDirectory = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
directory.mkdir(targetDirectory, null, null);
assertNotNull(attributesFinder.find(targetDirectory));
Path touchedFile = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
touch.touch(touchedFile, new TransferStatus().withMime("x-application/cyberduck"));
assertNotNull(attributesFinder.find(touchedFile));
Path rename = new Path(targetDirectory, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
assertTrue(move.isSupported(touchedFile, rename));
assertEquals(rename, move.move(touchedFile, rename, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback()));
assertNotNull(attributesFinder.find(rename));
assertFalse(new MantaFindFeature(session).find(touchedFile));
assertTrue(new MantaFindFeature(session).find(rename));
delete.delete(Collections.singletonList(targetDirectory), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
示例2: testSetTimestamp
import java.util.EnumSet; //导入依赖的package包/类
@Test(expected = BackgroundException.class)
public void testSetTimestamp() throws Exception {
final Host host = new Host(new FTPTLSProtocol(), "test.cyberduck.ch", new Credentials(
System.getProperties().getProperty("ftp.user"), System.getProperties().getProperty("ftp.password")
));
final FTPSession session = new FTPSession(host);
assertNotNull(session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback()));
assertTrue(session.isConnected());
assertNotNull(session.getClient());
session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
final FTPWorkdirService workdir = new FTPWorkdirService(session);
final Path home = workdir.find();
final long modified = System.currentTimeMillis();
final Path test = new Path(workdir.find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
session.getFeature(Touch.class).touch(test, new TransferStatus());
new FTPUTIMETimestampFeature(session).setTimestamp(test, modified);
new FTPDeleteFeature(session).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
session.close();
}
示例3: testSetEncryptionAES256Placeholder
import java.util.EnumSet; //导入依赖的package包/类
@Test
public void testSetEncryptionAES256Placeholder() throws Exception {
final S3Session session = new S3Session(
new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
new Credentials(
System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
)));
session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
final Path container = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.volume));
final Path test = new S3DirectoryFeature(session, new S3WriteFeature(session, new S3DisabledMultipartService())).mkdir(
new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)), null, new TransferStatus());
final S3EncryptionFeature feature = new S3EncryptionFeature(session);
feature.setEncryption(test, S3EncryptionFeature.SSE_AES256);
final Encryption.Algorithm value = feature.getEncryption(test);
assertEquals("AES256", value.algorithm);
assertNull(value.key);
new S3DefaultDeleteFeature(session).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
session.close();
}
示例4: clearLocalPkg
import java.util.EnumSet; //导入依赖的package包/类
/**
* Clear the tracked visited folders & the cached {@link LocalPkgInfo} for the
* given filter types.
*
* @param filters A set of PkgType constants or {@link PkgType#PKG_ALL} to clear everything.
*/
public void clearLocalPkg(@NonNull EnumSet<PkgType> filters) {
mLegacyBuildTools = null;
synchronized (mLocalPackages) {
for (PkgType filter : filters) {
mVisitedDirs.removeAll(filter);
mLocalPackages.removeAll(filter);
}
}
// Clear the targets if the platforms or addons are being cleared
if (filters.contains(PkgType.PKG_PLATFORM) || filters.contains(PkgType.PKG_ADDON)) {
mReloadTargets = true;
}
}
示例5: createNonRecursive
import java.util.EnumSet; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public FSDataOutputStream createNonRecursive(Path f, FsPermission permission,
EnumSet<CreateFlag> flags, int bufferSize, short replication, long blockSize,
Progressable progress) throws IOException {
// Check if file should be appended or overwritten. Assume that the file
// is overwritten on if the CREATE and OVERWRITE create flags are set. Note
// that any other combinations of create flags will result in an open new or
// open with append.
final EnumSet<CreateFlag> createflags =
EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE);
boolean overwrite = flags.containsAll(createflags);
// Delegate the create non-recursive call.
return this.createNonRecursive(f, permission, overwrite,
bufferSize, replication, blockSize, progress);
}
示例6: testWrite
import java.util.EnumSet; //导入依赖的package包/类
@Test
public void testWrite() throws Exception {
final OneDriveWriteFeature feature = new OneDriveWriteFeature(session);
final Path container = new OneDriveHomeFinderFeature(session).find();
final byte[] content = RandomUtils.nextBytes(5 * 1024 * 1024);
final TransferStatus status = new TransferStatus();
status.setLength(content.length);
final Path file = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
final HttpResponseOutputStream<Void> out = feature.write(file, status, new DisabledConnectionCallback());
final ByteArrayInputStream in = new ByteArrayInputStream(content);
final byte[] buffer = new byte[32 * 1024];
assertEquals(content.length, IOUtils.copyLarge(in, out, buffer));
in.close();
out.close();
assertNull(out.getStatus());
assertTrue(new DefaultFindFeature(session).find(file));
final byte[] compare = new byte[content.length];
final InputStream stream = new OneDriveReadFeature(session).read(file, new TransferStatus().length(content.length), new DisabledConnectionCallback());
IOUtils.readFully(stream, compare);
stream.close();
assertArrayEquals(content, compare);
new OneDriveDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
示例7: testRenameVersionedFolder_DO
import java.util.EnumSet; //导入依赖的package包/类
public void testRenameVersionedFolder_DO () throws Exception {
// init
File fromFolder = new File(repositoryLocation, "from");
fromFolder.mkdirs();
File file = new File(fromFolder, "file");
file.createNewFile();
add();
commit();
File toFolder = new File(repositoryLocation, "to");
File toFile = new File(toFolder, file.getName());
// rename
h.setFilesToRefresh(new HashSet<File>(Arrays.asList(fromFolder, toFolder)));
renameDO(fromFolder, toFolder);
assertTrue(h.waitForFilesToRefresh());
// test
assertFalse(fromFolder.exists());
assertTrue(toFolder.exists());
assertEquals(EnumSet.of(Status.REMOVED_HEAD_INDEX, Status.REMOVED_HEAD_WORKING_TREE), getCache().getStatus(file).getStatus());
FileInformation info = getCache().getStatus(toFile);
assertEquals(EnumSet.of(Status.NEW_HEAD_INDEX, Status.NEW_HEAD_WORKING_TREE), info.getStatus());
assertTrue(info.isRenamed());
assertEquals(file, info.getOldFile());
}
示例8: emitGetExpectedObjectSchemaInfoMap
import java.util.EnumSet; //导入依赖的package包/类
private void emitGetExpectedObjectSchemaInfoMap(JavaWriter writer) throws IOException {
writer.emitAnnotation("Override");
writer.beginMethod(
"Map<Class<? extends RealmModel>, OsObjectSchemaInfo>",
"getExpectedObjectSchemaInfoMap",
EnumSet.of(Modifier.PUBLIC));
writer.emitStatement(
"Map<Class<? extends RealmModel>, OsObjectSchemaInfo> infoMap = " +
"new HashMap<Class<? extends RealmModel>, OsObjectSchemaInfo>(%s)", qualifiedProxyClasses.size());
for (int i = 0; i < qualifiedProxyClasses.size(); i++) {
writer.emitStatement("infoMap.put(%s.class, %s.getExpectedObjectSchemaInfo())",
qualifiedModelClasses.get(i), qualifiedProxyClasses.get(i));
}
writer.emitStatement("return infoMap");
writer.endMethod();
writer.emitEmptyLine();
}
示例9: testConvert
import java.util.EnumSet; //导入依赖的package包/类
@Test
public void testConvert() throws Exception {
final LocalSession session = new LocalSession(new Host(new LocalProtocol(), new LocalProtocol().getDefaultHostname()));
if(session.isPosixFilesystem()) {
session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
final Path file = new Path(new LocalHomeFinderFeature(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
new LocalTouchFeature(session).touch(file, new TransferStatus());
final java.nio.file.Path local = session.toPath(file);
final PosixFileAttributes posixAttributes = Files.readAttributes(local, PosixFileAttributes.class);
final LocalAttributesFinderFeature finder = new LocalAttributesFinderFeature(session);
assertEquals(PosixFilePermissions.toString(posixAttributes.permissions()), finder.find(file).getPermission().getSymbol());
Files.setPosixFilePermissions(local, PosixFilePermissions.fromString("rw-------"));
assertEquals("rw-------", finder.find(file).getPermission().getSymbol());
Files.setPosixFilePermissions(local, PosixFilePermissions.fromString("rwxrwxrwx"));
assertEquals("rwxrwxrwx", finder.find(file).getPermission().getSymbol());
Files.setPosixFilePermissions(local, PosixFilePermissions.fromString("rw-rw----"));
assertEquals("rw-rw----", finder.find(file).getPermission().getSymbol());
assertEquals(posixAttributes.size(), finder.find(file).getSize());
assertEquals(posixAttributes.lastModifiedTime().toMillis(), finder.find(file).getModificationDate());
assertEquals(posixAttributes.creationTime().toMillis(), finder.find(file).getCreationDate());
assertEquals(posixAttributes.lastAccessTime().toMillis(), finder.find(file).getAccessedDate());
new LocalDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
}
示例10: testList
import java.util.EnumSet; //导入依赖的package包/类
public void testList() throws IOException {
final FileObjectArchive archive = new FileObjectArchive(FileUtil.toFileObject(root));
Iterable<JavaFileObject> res = archive.getFiles(
"org/me", //NOI18N
null,
EnumSet.of(JavaFileObject.Kind.CLASS),
null,
false);
assertEquals(Arrays.asList("org.me.A", "org.me.B"), toInferedName(res)); //NOI18N
res = archive.getFiles(
"non-package/org/me", //NOI18N
null,
EnumSet.of(JavaFileObject.Kind.CLASS),
null,
false);
//Explicit list of non-package returns FileObejcts with prefix
assertEquals(Arrays.asList("non-package.org.me.X", "non-package.org.me.Y"), toInferedName(res)); //NOI18N
}
示例11: testMakeDirectoryEncrypted
import java.util.EnumSet; //导入依赖的package包/类
@Test
public void testMakeDirectoryEncrypted() throws Exception {
final Host host = new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials(
System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
));
final S3Session session = new S3Session(host);
session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
final Path home = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
cryptomator.create(session, null, new VaultCredentials("test"));
session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
final Path test = new CryptoDirectoryFeature<StorageObject>(session, new S3DirectoryFeature(session, new S3WriteFeature(session)), new S3WriteFeature(session), cryptomator).mkdir(new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), null, new TransferStatus());
assertTrue(test.getType().contains(Path.Type.placeholder));
assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
new CryptoDeleteFeature(session, new S3DefaultDeleteFeature(session), cryptomator).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
session.close();
}
示例12: mkdir
import java.util.EnumSet; //导入依赖的package包/类
@Override
public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException {
try {
if(containerService.isContainer(folder)) {
final CreateRoomRequest roomRequest = new CreateRoomRequest();
final UserAccountWrapper user = session.userAccount();
roomRequest.addAdminIdsItem(user.getId());
roomRequest.setAdminGroupIds(null);
roomRequest.setName(folder.getName());
final Node r = new NodesApi(session.getClient()).createRoom(StringUtils.EMPTY, null, roomRequest);
return new Path(folder.getParent(), folder.getName(), EnumSet.of(Path.Type.directory, Path.Type.volume),
new PathAttributes(folder.attributes()));
}
else {
final CreateFolderRequest folderRequest = new CreateFolderRequest();
folderRequest.setParentId(Long.parseLong(new SDSNodeIdProvider(session).getFileid(folder.getParent(), new DisabledListProgressListener())));
folderRequest.setName(folder.getName());
final Node f = new NodesApi(session.getClient()).createFolder(StringUtils.EMPTY, folderRequest, null);
return new Path(folder.getParent(), folder.getName(), folder.getType(),
new PathAttributes(folder.attributes()));
}
}
catch(ApiException e) {
throw new SDSExceptionMappingService().map("Cannot create folder {0}", e, folder);
}
}
示例13: testReadTildeInKey
import java.util.EnumSet; //导入依赖的package包/类
@Test
public void testReadTildeInKey() throws Exception {
final S3Session session = new S3Session(
new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
new Credentials(
System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
)));
session.setSignatureVersion(S3Protocol.AuthenticationHeaderSignatureVersion.AWS2);
session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
final Path container = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
container.attributes().setRegion("us-east-1");
final Path file = new Path(container, String.format("%s~", UUID.randomUUID().toString()), EnumSet.of(Path.Type.file));
new S3TouchFeature(session).touch(file, new TransferStatus());
new S3AttributesFinderFeature(session).find(file);
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
session.close();
}
示例14: testFavoredNodesEndToEndForAppend
import java.util.EnumSet; //导入依赖的package包/类
@Test(timeout = 180000)
public void testFavoredNodesEndToEndForAppend() throws Exception {
// create 10 files with random preferred nodes
for (int i = 0; i < NUM_FILES; i++) {
Random rand = new Random(System.currentTimeMillis() + i);
// pass a new created rand so as to get a uniform distribution each time
// without too much collisions (look at the do-while loop in getDatanodes)
InetSocketAddress datanode[] = getDatanodes(rand);
Path p = new Path("/filename" + i);
// create and close the file.
dfs.create(p, FsPermission.getDefault(), true, 4096, (short) 3, 4096L,
null, null).close();
// re-open for append
FSDataOutputStream out = dfs.append(p, EnumSet.of(CreateFlag.APPEND),
4096, null, datanode);
out.write(SOME_BYTES);
out.close();
BlockLocation[] locations = getBlockLocations(p);
// verify the files got created in the right nodes
for (BlockLocation loc : locations) {
String[] hosts = loc.getNames();
String[] hosts1 = getStringForInetSocketAddrs(datanode);
assertTrue(compareNodes(hosts, hosts1));
}
}
}
示例15: addAttributesToCompilationUnit
import java.util.EnumSet; //导入依赖的package包/类
/**
* It adds all the attributes need to be added to the existing compilation unit.
*/
private void addAttributesToCompilationUnit() {
if(attributesToBeAdded.size() > 0) {
ClassOrInterfaceDeclaration type = getFileType();
attributesToBeAdded.stream().forEach(attribute -> {
EnumSet<Modifier> modifiers = null;
for (Modifier modifier : attribute.getAccessModifiers()) {
modifiers = EnumSet.of(modifier);
}
VariableDeclarator vd = new VariableDeclarator(JavaParser.parseType(attribute.getDataType()), attribute.getName());
FieldDeclaration fd = new FieldDeclaration();
fd.setModifiers(modifiers);
fd.addVariable(vd);
type.addMember(fd);
((ClassStructure)existingAbstractStructure).addAttribute(attribute);
});
}
}