Example usage for java.util EnumSet of

List of usage examples for java.util EnumSet of

Introduction

In this page you can find the example usage for java.util EnumSet of.

Prototype

public static <E extends Enum<E>> EnumSet<E> of(E e) 

Source Link

Document

Creates an enum set initially containing the specified element.

Usage

From source file:io.wcm.tooling.netbeans.sightly.completion.classLookup.ClassLookupResolver.java

/**
 * returns a list with all classes matchting the given filter
 *//*from  ww  w .j  a v a  2  s  .  co  m*/
public List<CompletionItem> resolve(String filter, int startOffset, int caretOffset) {
    final Set<ElementHandle<TypeElement>> result = classpath.getClassIndex().getDeclaredTypes("",
            ClassIndex.NameKind.PREFIX, EnumSet.of(ClassIndex.SearchScope.SOURCE));
    List<CompletionItem> ret = new ArrayList<>();

    for (ElementHandle<TypeElement> te : result) {
        if (te.getKind().isClass()) {
            String binaryName = te.getBinaryName();
            if (!StringUtils.equals(binaryName, "") && StringUtils.startsWith(binaryName, filter)) {
                ret.add(new BasicCompletionItem(te.getBinaryName(), false, startOffset, caretOffset));
            }
        }
    }
    return ret;
}

From source file:com.flipkart.zjsonpatch.CompatibilityTest.java

@Test
public void withFlagAddShouldTreatMissingValuesAsNulls() throws IOException {
    JsonNode expected = mapper.readTree("{\"a\":null}");
    JsonNode result = JsonPatch.apply(addNodeWithMissingValue, mapper.createObjectNode(),
            EnumSet.of(MISSING_VALUES_AS_NULLS));
    assertThat(result, equalTo(expected));
}

From source file:ch.cyberduck.core.googledrive.DriveSearchFeatureTest.java

@Test
public void testSearchRoot() throws Exception {
    final String name = new AlphanumericRandomStringService().random();
    final Path workdir = new DriveHomeFinderService(session).find();
    final Path file = new DriveTouchFeature(session).touch(new Path(workdir, name, EnumSet.of(Path.Type.file)),
            new TransferStatus());
    final DriveSearchFeature feature = new DriveSearchFeature(session);
    assertTrue(/* w w w . j av a2 s.  com*/
            feature.search(workdir, new SearchFilter(name), new DisabledListProgressListener()).contains(file));
    // Supports prefix matching only
    assertFalse(feature.search(workdir, new SearchFilter(StringUtils.substring(name, 2)),
            new DisabledListProgressListener()).contains(file));
    assertTrue(feature.search(workdir, new SearchFilter(StringUtils.substring(name, 0, name.length() - 2)),
            new DisabledListProgressListener()).contains(file));
    final Path subdir = new Path(workdir, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.directory));
    assertFalse(
            feature.search(subdir, new SearchFilter(name), new DisabledListProgressListener()).contains(file));
    new DriveDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
}

From source file:ch.cyberduck.cli.SingleTransferItemFinderTest.java

@Test
public void testNoLocalInOptionsDownload() throws Exception {
    final CommandLineParser parser = new PosixParser();
    final CommandLine input = parser.parse(TerminalOptionsBuilder.options(),
            new String[] { "--download", "rackspace://cdn.cyberduck.ch/remote" });

    final Set<TransferItem> found = new SingleTransferItemFinder().find(input, TerminalAction.download,
            new Path("/cdn.cyberduck.ch/remote", EnumSet.of(Path.Type.file)));
    assertFalse(found.isEmpty());/*ww  w .  ja v a 2s .  c  o  m*/
    assertEquals(new TransferItem(new Path("/cdn.cyberduck.ch/remote", EnumSet.of(Path.Type.file)),
            LocalFactory.get(System.getProperty("user.dir") + "/remote")), found.iterator().next());
}

From source file:ch.cyberduck.core.googledrive.DriveReadFeatureTest.java

@Test
public void testAppend() throws Exception {
    assertTrue(new DriveReadFeature(null).offset(new Path("/", EnumSet.of(Path.Type.file))));
}

From source file:ch.cyberduck.cli.TerminalTransferFactoryTest.java

@Test
public void testCreate() throws Exception {
    final CommandLineParser parser = new PosixParser();

    final Transfer transfer = new TerminalTransferFactory().create(
            parser.parse(TerminalOptionsBuilder.options(),
                    new String[] { "--download", "rackspace://cdn.cyberduck.ch/remote" }),
            new Host(new SwiftProtocol()), new Path("/remote", EnumSet.of(Path.Type.directory)),
            Collections.<TransferItem>emptyList());
    assertEquals(Transfer.Type.download, transfer.getType());
}

From source file:ch.cyberduck.core.cryptomator.CryptoOutputStreamTest.java

private CryptoVault getVault() throws Exception {
    final Path home = new Path("/vault", EnumSet.of(Path.Type.directory));
    final NullSession session = new NullSession(new Host(new TestProtocol())) {
        @Override/*from ww w.j a v a 2  s .co  m*/
        @SuppressWarnings("unchecked")
        public <T> T _getFeature(final Class<T> type) {
            if (type == Directory.class) {
                return (T) new Directory() {

                    @Override
                    public Path mkdir(final Path folder, final String region, final TransferStatus status)
                            throws BackgroundException {
                        assertTrue(folder.equals(home) || folder.isChild(home));
                        return folder;
                    }

                    @Override
                    public boolean isSupported(final Path workdir) {
                        return true;
                    }

                    @Override
                    public Directory withWriter(final Write writer) {
                        return this;
                    }
                };
            }
            return super._getFeature(type);
        }
    };
    final CryptoVault vault = new CryptoVault(home, new DisabledPasswordStore());
    vault.create(session, null, new VaultCredentials("test"));
    return vault;
}

From source file:ch.cyberduck.core.cryptomator.impl.CryptoDirectoryProviderTest.java

@Test(expected = NotfoundException.class)
public void testToEncryptedInvalidArgument() throws Exception {
    final Path home = new Path("/vault", EnumSet.of(Path.Type.directory));
    final CryptoVault vault = new CryptoVault(home, new DisabledPasswordStore());
    final CryptoDirectoryProvider provider = new CryptoDirectoryProvider(home, vault);
    provider.toEncrypted(new NullSession(new Host(new TestProtocol())), null,
            new Path("/vault/f", EnumSet.of(Path.Type.file)));
}

From source file:ch.cyberduck.core.dropbox.DropboxSearchFeatureTest.java

@Test
public void testSearch() throws Exception {
    final String name = new AlphanumericRandomStringService().random();
    final Path workdir = new DefaultHomeFinderService(session).find();
    final Path file = new Path(workdir, name, EnumSet.of(Path.Type.file));
    new DropboxTouchFeature(session).touch(file, new TransferStatus());
    final DropboxSearchFeature feature = new DropboxSearchFeature(session);
    assertTrue(/*w  w w .  j a v a2 s  .  c om*/
            feature.search(workdir, new SearchFilter(name), new DisabledListProgressListener()).contains(file));
    // Supports prefix matching only
    assertFalse(feature.search(workdir, new SearchFilter(StringUtils.substring(name, 2)),
            new DisabledListProgressListener()).contains(file));
    assertTrue(feature.search(workdir, new SearchFilter(StringUtils.substring(name, 0, name.length() - 2)),
            new DisabledListProgressListener()).contains(file));
    try {
        assertFalse(feature.search(
                new Path(workdir, new AlphanumericRandomStringService().random(),
                        EnumSet.of(Path.Type.directory)),
                new SearchFilter(name), new DisabledListProgressListener()).contains(file));
        fail();
    } catch (NotfoundException e) {
        //
    }
    final Path subdir = new Path(workdir, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.directory));
    new DropboxDirectoryFeature(session).mkdir(subdir, null, new TransferStatus());
    assertFalse(
            feature.search(subdir, new SearchFilter(name), new DisabledListProgressListener()).contains(file));
    final Path filesubdir = new DropboxTouchFeature(session).touch(
            new Path(subdir, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)),
            new TransferStatus());
    {
        final AttributedList<Path> result = feature.search(workdir, new SearchFilter(filesubdir.getName()),
                new DisabledListProgressListener());
        assertTrue(result.contains(filesubdir));
        assertEquals(subdir, result.find(new SimplePathPredicate(filesubdir)).getParent());
    }
    new DropboxDeleteFeature(session).delete(Arrays.asList(file, filesubdir, subdir),
            new DisabledLoginCallback(), new Delete.DisabledCallback());
}

From source file:ch.cyberduck.cli.UploadTransferItemFinder.java

protected TransferItem resolve(final Path remote, final Local local) {
    if (local.isDirectory()) {
        // Local path resolves to folder
        if (remote.isDirectory()) {
            // Keep from input
            return new TransferItem(remote, local);
        }/*from   w ww .j a v a 2  s.c  o  m*/
        return new TransferItem(new Path(remote.getAbsolute(), EnumSet.of(Path.Type.directory)), local);
    }
    // Local path resolves to file
    if (remote.isDirectory()) {
        // Append local name to remote target
        return new TransferItem(new Path(remote, local.getName(), EnumSet.of(Path.Type.file)), local);
    }
    // Keep from input for file transfer
    return new TransferItem(remote, local);
}