List of usage examples for java.util EnumSet noneOf
public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType)
From source file:org.apache.hadoop.fs.TestEnhancedByteBufferAccess.java
@Test public void testZeroCopyReadsNoFallback() throws Exception { HdfsConfiguration conf = initZeroCopyTest(); MiniDFSCluster cluster = null;//from w w w .j a v a 2 s. co m final Path TEST_PATH = new Path("/a"); FSDataInputStream fsIn = null; final int TEST_FILE_LENGTH = 3 * BLOCK_SIZE; FileSystem fs = null; try { cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build(); cluster.waitActive(); fs = cluster.getFileSystem(); DFSTestUtil.createFile(fs, TEST_PATH, TEST_FILE_LENGTH, (short) 1, 7567L); try { DFSTestUtil.waitReplication(fs, TEST_PATH, (short) 1); } catch (InterruptedException e) { Assert.fail("unexpected InterruptedException during " + "waitReplication: " + e); } catch (TimeoutException e) { Assert.fail("unexpected TimeoutException during " + "waitReplication: " + e); } fsIn = fs.open(TEST_PATH); byte original[] = new byte[TEST_FILE_LENGTH]; IOUtils.readFully(fsIn, original, 0, TEST_FILE_LENGTH); fsIn.close(); fsIn = fs.open(TEST_PATH); HdfsDataInputStream dfsIn = (HdfsDataInputStream) fsIn; ByteBuffer result; try { result = dfsIn.read(null, BLOCK_SIZE + 1, EnumSet.noneOf(ReadOption.class)); Assert.fail("expected UnsupportedOperationException"); } catch (UnsupportedOperationException e) { // expected } result = dfsIn.read(null, BLOCK_SIZE, EnumSet.of(ReadOption.SKIP_CHECKSUMS)); Assert.assertEquals(BLOCK_SIZE, result.remaining()); Assert.assertEquals(BLOCK_SIZE, dfsIn.getReadStatistics().getTotalBytesRead()); Assert.assertEquals(BLOCK_SIZE, dfsIn.getReadStatistics().getTotalZeroCopyBytesRead()); Assert.assertArrayEquals(Arrays.copyOfRange(original, 0, BLOCK_SIZE), byteBufferToArray(result)); } finally { if (fsIn != null) fsIn.close(); if (fs != null) fs.close(); if (cluster != null) cluster.shutdown(); } }
From source file:com.vmware.admiral.host.BaseManagementHostClusterIT.java
private static <T extends ServiceDocument> boolean equals(T documentA, T documentB, Class<T> type) { EnumSet<ServiceOption> options = EnumSet.noneOf(ServiceOption.class); ServiceDocumentDescription buildDescription = Builder.create().buildDescription(type, options); documentA.documentUpdateTimeMicros = 0; documentA.documentExpirationTimeMicros = 0; documentB.documentUpdateTimeMicros = 0; documentB.documentExpirationTimeMicros = 0; return ServiceDocument.equals(buildDescription, documentA, documentB); }
From source file:org.dcm4che.tool.findscu.FindSCU.java
private static EnumSet<QueryOption> queryOptionsOf(FindSCU main, CommandLine cl) { EnumSet<QueryOption> queryOptions = EnumSet.noneOf(QueryOption.class); if (cl.hasOption("relational")) queryOptions.add(QueryOption.RELATIONAL); if (cl.hasOption("datetime")) queryOptions.add(QueryOption.DATETIME); if (cl.hasOption("fuzzy")) queryOptions.add(QueryOption.FUZZY); if (cl.hasOption("timezone")) queryOptions.add(QueryOption.TIMEZONE); return queryOptions; }
From source file:org.wso2.carbon.esb.mediator.test.enrich.jsonpath.EnrichIntegrationJsonPathTestCase.java
private void setJsonPathConfiguration() { Configuration.setDefaults(new Configuration.Defaults() { private final JsonProvider jsonProvider = new GsonJsonProvider( new GsonBuilder().serializeNulls().create()); private final MappingProvider mappingProvider = new GsonMappingProvider(); public JsonProvider jsonProvider() { return jsonProvider; }//from w w w. j a v a 2 s . c o m public MappingProvider mappingProvider() { return mappingProvider; } public Set<Option> options() { return EnumSet.noneOf(Option.class); } }); }
From source file:org.opencb.opencga.catalog.auth.authorization.CatalogAuthorizationManager.java
private FileAclEntry resolveFilePermissions(long studyId, String userId, String groupId, Map<String, FileAclEntry> userAclMap) throws CatalogException { if (userId.equals(ANONYMOUS)) { if (userAclMap.containsKey(userId)) { return userAclMap.get(userId); } else {//from www . ja v a2 s. co m return transformStudyAclToFileAcl(getStudyAclBelonging(studyId, userId, groupId)); } } // Registered user EnumSet<FileAclEntry.FilePermissions> permissions = EnumSet.noneOf(FileAclEntry.FilePermissions.class); boolean flagPermissionFound = false; if (userAclMap.containsKey(userId)) { permissions.addAll(userAclMap.get(userId).getPermissions()); flagPermissionFound = true; } if (StringUtils.isNotEmpty(groupId) && userAclMap.containsKey(groupId)) { permissions.addAll(userAclMap.get(groupId).getPermissions()); flagPermissionFound = true; } if (userAclMap.containsKey(ANONYMOUS)) { permissions.addAll(userAclMap.get(ANONYMOUS).getPermissions()); flagPermissionFound = true; } if (userAclMap.containsKey(OTHER_USERS_ID)) { permissions.addAll(userAclMap.get(OTHER_USERS_ID).getPermissions()); flagPermissionFound = true; } if (flagPermissionFound) { return new FileAclEntry(userId, permissions); } else { return transformStudyAclToFileAcl(getStudyAclBelonging(studyId, userId, groupId)); } }
From source file:io.lavagna.service.PermissionService.java
private static Set<Permission> toSet(List<RoleAndPermission> rp) { Set<Permission> permissions = EnumSet.noneOf(Permission.class); for (RoleAndPermission rap : rp) { if (rap.getPermission() != null) { permissions.add(rap.getPermission()); }/* w ww. j a v a2 s. c o m*/ } return permissions; }
From source file:org.broadinstitute.gatk.utils.commandline.ParsingEngine.java
/** * Validates the list of command-line argument matches. */ public void validate() { validate(EnumSet.noneOf(ValidationType.class)); }
From source file:org.apache.accumulo.core.util.shell.commands.SetIterCommand.java
protected void setNamespaceProperties(final CommandLine cl, final Shell shellState, final int priority, final Map<String, String> options, final String classname, final String name) throws AccumuloException, AccumuloSecurityException, ShellCommandException, NamespaceNotFoundException { // remove empty values final String namespace = OptUtil.getNamespaceOpt(cl, shellState); if (!shellState.getConnector().namespaceOperations().testClassLoad(namespace, classname, SortedKeyValueIterator.class.getName())) { throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable to load " + classname + " as type " + SortedKeyValueIterator.class.getName()); }/*from w w w .j a v a 2 s . c o m*/ final String aggregatorClass = options.get("aggregatorClass"); @SuppressWarnings("deprecation") String deprecatedAggregatorClassName = org.apache.accumulo.core.iterators.aggregation.Aggregator.class .getName(); if (aggregatorClass != null && !shellState.getConnector().namespaceOperations().testClassLoad(namespace, aggregatorClass, deprecatedAggregatorClassName)) { throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable to load " + aggregatorClass + " as type " + deprecatedAggregatorClassName); } for (Iterator<Entry<String, String>> i = options.entrySet().iterator(); i.hasNext();) { final Entry<String, String> entry = i.next(); if (entry.getValue() == null || entry.getValue().isEmpty()) { i.remove(); } } final EnumSet<IteratorScope> scopes = EnumSet.noneOf(IteratorScope.class); if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(mincScopeOpt.getOpt())) { scopes.add(IteratorScope.minc); } if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(majcScopeOpt.getOpt())) { scopes.add(IteratorScope.majc); } if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(scanScopeOpt.getOpt())) { scopes.add(IteratorScope.scan); } if (scopes.isEmpty()) { throw new IllegalArgumentException("You must select at least one scope to configure"); } final IteratorSetting setting = new IteratorSetting(priority, name, classname, options); shellState.getConnector().namespaceOperations().attachIterator(namespace, setting, scopes); }
From source file:com.compomics.pride_asa_pipeline.core.logic.modification.PTMMapper.java
/** * Map a Modification from mzIdentMl onto the pipeline Modification * * @param modificationItem the ModificationItem * @param peptideSequence the peptide sequence * @return the mapped modification// w w w . ja va 2 s .com */ public static Modification mapModificationWithParameters( uk.ac.ebi.jmzidml.model.mzidml.Modification modificationItem, String peptideSequence) { Integer modificationLocation = modificationItem.getLocation(); Modification.Location location; int sequenceIndex; if (modificationLocation == 0) { location = Modification.Location.N_TERMINAL; sequenceIndex = 0; } else if (0 < modificationLocation && modificationLocation < (peptideSequence.length() + 1)) { location = Modification.Location.NON_TERMINAL; sequenceIndex = modificationLocation - 1; } else if (modificationLocation == (peptideSequence.length() + 1)) { location = Modification.Location.C_TERMINAL; sequenceIndex = peptideSequence.length() - 1; } else { //in this case, return null for the modification return null; } double monoIsotopicMassShift = (modificationItem.getMonoisotopicMassDelta()); //if average mass shift is empty, use the monoisotopic mass. double averageMassShift; try { averageMassShift = modificationItem.getAvgMassDelta(); } catch (NullPointerException e) { LOGGER.error("Average mass shift not found, setting to mono isotopic mass shift"); averageMassShift = monoIsotopicMassShift; } String accession = modificationItem.getCvParam().get(0).getAccession(); String accessionValue = modificationItem.getCvParam().get(0).getValue(); Modification modification = new Modification(accessionValue, monoIsotopicMassShift, averageMassShift, location, EnumSet.noneOf(AminoAcid.class), accession, accessionValue); modification.getAffectedAminoAcids() .add(AminoAcid.getAA(peptideSequence.substring(sequenceIndex, sequenceIndex + 1))); modification.setOrigin(Modification.Origin.PRIDE); return modification; }
From source file:org.apache.hadoop.hive.ql.security.authorization.StorageBasedAuthorizationProvider.java
/** * Given a Privilege[], find out what all FsActions are required *//*from w ww . j a va 2 s .c o m*/ protected EnumSet<FsAction> getFsActions(Privilege[] privs) { EnumSet<FsAction> actions = EnumSet.noneOf(FsAction.class); if (privs == null) { return actions; } for (Privilege priv : privs) { actions.add(getFsAction(priv)); } return actions; }