List of usage examples for java.util EnumSet copyOf
public static <E extends Enum<E>> EnumSet<E> copyOf(Collection<E> c)
From source file:com.github.fge.jsonschema.core.load.configuration.LoadingConfigurationBuilder.java
/** * Build a mutable loading configuration out of a frozen one * * @param cfg the frozen configuration// www . j a v a 2s . c o m * @see LoadingConfiguration#thaw() */ LoadingConfigurationBuilder(final LoadingConfiguration cfg) { downloaders.putAll(cfg.downloaders); translatorCfg = cfg.translatorCfg; dereferencing = cfg.dereferencing; preloadedSchemas = Maps.newHashMap(cfg.preloadedSchemas); parserFeatures = EnumSet.copyOf(cfg.parserFeatures); enableCache = cfg.enableCache; }
From source file:com.google.i18n.addressinput.common.FormatInterpreter.java
private void applyFieldOrderOverrides(String regionCode, List<AddressField> fieldOrder) { List<AddressField> customFieldOrder = formOptions.getCustomFieldOrder(regionCode); if (customFieldOrder == null) { return;//from w w w . j av a 2 s .c om } // We can assert that fieldOrder and customFieldOrder contain no duplicates. // We know this by the construction above and in FormOptions but we still have to think // about fields in the custom ordering which aren't visible (the loop below will fail if // a non-visible field appears in the custom ordering). However in that case it's safe to // just ignore the extraneous field. Set<AddressField> nonVisibleCustomFields = EnumSet.copyOf(customFieldOrder); nonVisibleCustomFields.removeAll(fieldOrder); if (nonVisibleCustomFields.size() > 0) { // Local mutable copy to remove non visible fields - this shouldn't happen often. customFieldOrder = new ArrayList<AddressField>(customFieldOrder); customFieldOrder.removeAll(nonVisibleCustomFields); } // It is vital for this loop to work correctly that every element in customFieldOrder // appears in fieldOrder exactly once. for (int fieldIdx = 0, customIdx = 0; fieldIdx < fieldOrder.size(); fieldIdx++) { if (customFieldOrder.contains(fieldOrder.get(fieldIdx))) { fieldOrder.set(fieldIdx, customFieldOrder.get(customIdx++)); } } }
From source file:org.trnltk.morphology.lexicon.ImmutableRootGenerator.java
private HashSet<ImmutableRoot> generateModifiedRootNodes(final Lexeme lexeme) { final Set<LexemeAttribute> lexemeAttributes = lexeme.getAttributes(); if (lexemeAttributes.contains(LexemeAttribute.Special)) return this.handleSpecialRoots(lexeme); if (lexemeAttributes.contains(LexemeAttribute.EndsWithAyn)) { //kind of hack, didn't like it :( // if the word ends with Ayn // create roots with that attribute, and without that attribute // when creating with that attribute, add a VowelStart expectation final HashSet<ImmutableRoot> immutableRoots = new HashSet<ImmutableRoot>(); final EnumSet<LexemeAttribute> lexemeAttributesWithoutAyn = EnumSet.copyOf(lexemeAttributes); lexemeAttributesWithoutAyn.remove(LexemeAttribute.EndsWithAyn); final Lexeme lexemeWithoutAttrEndsWithAyn = new ImmutableLexeme(lexeme.getLemma(), lexeme.getLemmaRoot(), lexeme.getPrimaryPos(), lexeme.getSecondaryPos(), Sets.immutableEnumSet(lexemeAttributesWithoutAyn)); final HashSet<ImmutableRoot> rootsWithoutAynApplied = this .generateModifiedRootNodes(lexemeWithoutAttrEndsWithAyn); immutableRoots.addAll(rootsWithoutAynApplied); for (ImmutableRoot immutableRoot : rootsWithoutAynApplied) { final ImmutableSet<PhoneticAttribute> phoneticAttributesWithoutAynApplied = immutableRoot .getPhoneticAttributes(); final HashSet<PhoneticAttribute> phoneticAttributesWithAynApplied = Sets .newHashSet(phoneticAttributesWithoutAynApplied); phoneticAttributesWithAynApplied.remove(PhoneticAttribute.LastLetterVowel); phoneticAttributesWithAynApplied.add(PhoneticAttribute.LastLetterConsonant); final ImmutableRoot immutableRootWithAynApplied = new ImmutableRoot(immutableRoot.getSequence(), immutableRoot.getLexeme(), Sets.immutableEnumSet(phoneticAttributesWithAynApplied), Sets.immutableEnumSet(PhoneticExpectation.VowelStart)); immutableRoots.add(immutableRootWithAynApplied); }/* ww w .j a v a 2 s . c o m*/ // just before returning, set correct lexeme again final HashSet<ImmutableRoot> immutableRootsWithCorrectLexemeAttr = new HashSet<ImmutableRoot>(); for (ImmutableRoot immutableRoot : immutableRoots) { immutableRootsWithCorrectLexemeAttr.add(new ImmutableRoot(immutableRoot.getSequence(), lexeme, immutableRoot.getPhoneticAttributes(), immutableRoot.getPhoneticExpectations())); } return immutableRootsWithCorrectLexemeAttr; } final String lemmaRoot = lexeme.getLemmaRoot(); String modifiedRootStr = lexeme.getLemmaRoot(); final EnumSet<PhoneticAttribute> originalPhoneticAttrs = phoneticsAnalyzer .calculatePhoneticAttributes(lexeme.getLemmaRoot(), null); final EnumSet<PhoneticAttribute> modifiedPhoneticAttrs = phoneticsAnalyzer .calculatePhoneticAttributes(lexeme.getLemmaRoot(), null); final EnumSet<PhoneticExpectation> originalPhoneticExpectations = EnumSet.noneOf(PhoneticExpectation.class); final EnumSet<PhoneticExpectation> modifiedPhoneticExpectations = EnumSet.noneOf(PhoneticExpectation.class); if (CollectionUtils.containsAny(lexemeAttributes, Sets.immutableEnumSet(LexemeAttribute.Voicing, LexemeAttribute.VoicingOpt))) { final TurkicLetter lastLetter = TurkishAlphabet .getLetter(modifiedRootStr.charAt(modifiedRootStr.length() - 1)); final TurkicLetter voicedLastLetter = lemmaRoot.endsWith("nk") ? TurkishAlphabet.L_g : TurkishAlphabet.voice(lastLetter); Validate.notNull(voicedLastLetter); modifiedRootStr = modifiedRootStr.substring(0, modifiedRootStr.length() - 1) + voicedLastLetter.charValue(); modifiedPhoneticAttrs.remove(PhoneticAttribute.LastLetterVoicelessStop); if (!lexemeAttributes.contains(LexemeAttribute.VoicingOpt)) { originalPhoneticExpectations.add(PhoneticExpectation.ConsonantStart); } modifiedPhoneticExpectations.add(PhoneticExpectation.VowelStart); } if (lexemeAttributes.contains(LexemeAttribute.Doubling)) { modifiedRootStr += modifiedRootStr.charAt(modifiedRootStr.length() - 1); originalPhoneticExpectations.add(PhoneticExpectation.ConsonantStart); modifiedPhoneticExpectations.add(PhoneticExpectation.VowelStart); } if (lexemeAttributes.contains(LexemeAttribute.LastVowelDrop)) { modifiedRootStr = modifiedRootStr.substring(0, modifiedRootStr.length() - 2) + modifiedRootStr.charAt(modifiedRootStr.length() - 1); if (!PrimaryPos.Verb.equals(lexeme.getPrimaryPos())) originalPhoneticExpectations.add(PhoneticExpectation.ConsonantStart); modifiedPhoneticExpectations.add(PhoneticExpectation.VowelStart); } if (lexemeAttributes.contains(LexemeAttribute.InverseHarmony)) { originalPhoneticAttrs.add(PhoneticAttribute.LastVowelFrontal); originalPhoneticAttrs.remove(PhoneticAttribute.LastVowelBack); modifiedPhoneticAttrs.add(PhoneticAttribute.LastVowelFrontal); modifiedPhoneticAttrs.remove(PhoneticAttribute.LastVowelBack); } if (lexemeAttributes.contains(LexemeAttribute.ProgressiveVowelDrop)) { modifiedRootStr = modifiedRootStr.substring(0, modifiedRootStr.length() - 1); if (this.hasVowel(modifiedRootStr)) { modifiedPhoneticAttrs.clear(); modifiedPhoneticAttrs.addAll(phoneticsAnalyzer.calculatePhoneticAttributes(modifiedRootStr, null)); } modifiedPhoneticExpectations.add(PhoneticExpectation.VowelStart); } ImmutableRoot originalRoot = new ImmutableRoot(lexeme.getLemmaRoot(), lexeme, Sets.immutableEnumSet(originalPhoneticAttrs), Sets.immutableEnumSet(originalPhoneticExpectations)); ImmutableRoot modifiedRoot = new ImmutableRoot(modifiedRootStr, lexeme, Sets.immutableEnumSet(modifiedPhoneticAttrs), Sets.immutableEnumSet(modifiedPhoneticExpectations)); if (originalRoot.equals(modifiedRoot)) return Sets.newHashSet(originalRoot); else return Sets.newHashSet(originalRoot, modifiedRoot); }
From source file:org.rhq.core.pc.operation.OperationInvocation.java
public EnumSet<Status> getStatus() { synchronized (status) { return EnumSet.copyOf(status); } }
From source file:ch.cyberduck.core.cryptomator.impl.CryptoDirectoryProvider.java
/** * Get encrypted reference for clear text directory path. * * @param session Connection/*from w ww. j a v a 2s.co m*/ * @param directoryId Directory ID or null to read directory id from metadata file * @param directory Clear text */ public Path toEncrypted(final Session<?> session, final String directoryId, final Path directory) throws BackgroundException { if (!directory.isDirectory()) { throw new NotfoundException(directory.getAbsolute()); } if (new SimplePathPredicate(directory).test(home) || directory.isChild(home)) { final PathAttributes attributes = new PathAttributes(directory.attributes()).withVersionId(null); // Remember random directory id for use in vault final String id = this.toDirectoryId(session, directory, directoryId); if (log.isDebugEnabled()) { log.debug(String.format("Use directory ID '%s' for folder %s", id, directory)); } attributes.setDirectoryId(id); attributes.setDecrypted(directory); final String directoryIdHash = cryptomator.getCryptor().fileNameCryptor().hashDirectoryId(id); // Intermediate directory final Path intermediate = new Path(dataRoot, directoryIdHash.substring(0, 2), dataRoot.getType()); // Add encrypted type final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(directory.getType()); type.add(Path.Type.encrypted); type.remove(Path.Type.decrypted); return new Path(intermediate, directoryIdHash.substring(2), type, attributes); } throw new NotfoundException(directory.getAbsolute()); }
From source file:org.juiser.spring.boot.config.JuiserDefaultAutoConfiguration.java
@Bean @ConditionalOnMissingBean(name = "juiserForwardedUserFilter") public FilterRegistrationBean juiserForwardedUserFilter() { ForwardedUserFilterConfig cfg = juiserForwardedUserFilterConfig(); Filter filter = new SpringForwardedUserFilter(forwardedHeaderConfig().getName(), juiserRequestUserFactory(), cfg.getRequestAttributeNames()); FilterRegistrationBean bean = new FilterRegistrationBean(); bean.setFilter(filter);//www .ja va 2 s . c o m bean.setEnabled(cfg.isEnabled()); bean.setMatchAfter(cfg.isMatchAfter()); bean.setOrder(cfg.getOrder()); Set<DispatcherType> dispatcherTypes = cfg.getDispatcherTypes(); if (!CollectionUtils.isEmpty(dispatcherTypes)) { bean.setDispatcherTypes(EnumSet.copyOf(dispatcherTypes)); } Set<String> set = cfg.getServletNames(); if (!CollectionUtils.isEmpty(set)) { bean.setServletNames(set); } set = cfg.getUrlPatterns(); if (!CollectionUtils.isEmpty(set)) { bean.setUrlPatterns(set); } return bean; }
From source file:net.sf.gazpachoquest.services.core.impl.AbstractLocalizedPersistenceService.java
@Override public Set<Language> translationsSupported(final Integer entityId) { L entity = super.repository.findOne(entityId); if (entity == null) { return null; }//ww w . j av a 2s. co m TR translationExample = translationBuilder.translatedEntityId(entityId).build(); List<TR> supportedLanguages = translationRepository.findByExample(translationExample, new SearchParameters()); List<Language> list = new ArrayList<>(); for (TR tr : supportedLanguages) { list.add(tr.getLanguage()); } return list.isEmpty() ? EnumSet.noneOf(Language.class) : EnumSet.copyOf(list); }
From source file:org.trnltk.morphology.phonetics.PhoneticsAnalyzer.java
public ImmutableSet<PhoneticAttribute> calculateNewPhoneticAttributes(Set<PhoneticAttribute> phoneticAttributes, char charToApply) { final TurkishChar turkishChar = TurkishAlphabet.getChar(charToApply); final TurkicLetter letter = turkishChar.getLetter(); final EnumSet<PhoneticAttribute> newAttributes = EnumSet.copyOf(phoneticAttributes); if (letter.isVowel()) { newAttributes.remove(PhoneticAttribute.LastLetterConsonant); newAttributes.remove(PhoneticAttribute.LastLetterVoiceless); newAttributes.remove(PhoneticAttribute.LastLetterVoicelessStop); newAttributes.remove(PhoneticAttribute.HasNoVowel); newAttributes.remove(PhoneticAttribute.LastVowelFrontal); newAttributes.remove(PhoneticAttribute.LastVowelBack); newAttributes.remove(PhoneticAttribute.LastVowelRounded); newAttributes.remove(PhoneticAttribute.LastVowelUnrounded); newAttributes.add(PhoneticAttribute.LastLetterVowel); newAttributes.add(PhoneticAttribute.LastLetterNotVoiceless); if (letter.isFrontal()) newAttributes.add(PhoneticAttribute.LastVowelFrontal); else/*from w w w . ja v a 2 s . co m*/ newAttributes.add(PhoneticAttribute.LastVowelBack); if (letter.isRounded()) newAttributes.add(PhoneticAttribute.LastVowelRounded); else newAttributes.add(PhoneticAttribute.LastVowelUnrounded); } else { newAttributes.remove(PhoneticAttribute.LastLetterVowel); newAttributes.remove(PhoneticAttribute.LastLetterVoiceless); newAttributes.remove(PhoneticAttribute.LastLetterNotVoiceless); newAttributes.remove(PhoneticAttribute.LastLetterVoicelessStop); newAttributes.add(PhoneticAttribute.LastLetterConsonant); if (letter.isVoiceless()) { newAttributes.add(PhoneticAttribute.LastLetterVoiceless); if (!letter.isContinuant()) newAttributes.add(PhoneticAttribute.LastLetterVoicelessStop); } else { newAttributes.add(PhoneticAttribute.LastLetterNotVoiceless); } } return Sets.immutableEnumSet(newAttributes); }
From source file:com.github.fge.jsonschema.core.load.configuration.LoadingConfiguration.java
/** * Create a frozen loading configuration from a thawed one * * @param builder the thawed configuration * @see LoadingConfigurationBuilder#freeze() *//*from w w w .ja v a 2 s.c o m*/ LoadingConfiguration(final LoadingConfigurationBuilder builder) { downloaders = builder.downloaders.build(); translatorCfg = builder.translatorCfg; dereferencing = builder.dereferencing; preloadedSchemas = ImmutableMap.copyOf(builder.preloadedSchemas); parserFeatures = EnumSet.copyOf(builder.parserFeatures); reader = buildReader(); enableCache = builder.enableCache; }
From source file:org.rhq.core.pc.operation.OperationInvocation.java
/** * Flags this operation as being canceled. This will also interrupt the thread running the operation, if it is in * the running state. Note that if the operation has already completed, this method does nothing since it is too * late to cancel the operation.//from w w w. j a va 2 s. c o m * * @return the current state of the operation when it was canceled */ public EnumSet<Status> markAsCanceled() { synchronized (status) { EnumSet<Status> interruptedStatus = EnumSet.copyOf(status); if (!status.contains(Status.FINISHED)) { status.add(Status.CANCELED); if (operationThread != null) { operationThread.interrupt(); } } return interruptedStatus; } }