List of usage examples for com.google.common.collect Sets immutableEnumSet
@GwtCompatible(serializable = true) public static <E extends Enum<E>> ImmutableSet<E> immutableEnumSet(Iterable<E> elements)
From source file:io.crate.metadata.FunctionInfo.java
@Override public void readFrom(StreamInput in) throws IOException { ident = new FunctionIdent(); ident.readFrom(in);//from w w w . j a va 2 s . co m returnType = DataTypes.fromStream(in); type = Type.values()[in.readVInt()]; int enumElements = in.readVInt(); this.features = Sets.immutableEnumSet(EnumSets.unpackFromInt(enumElements, Feature.class)); }
From source file:org.csstudio.utility.ldap.treeconfiguration.LdapEpicsControlsConfiguration.java
/** * {@inheritDoc} */ @Override public ImmutableSet<LdapEpicsControlsConfiguration> getNestedContainerTypes() { return Sets.immutableEnumSet(_nestedClasses); }
From source file:com.google.jimfs.PosixAttributeProvider.java
@SuppressWarnings("unchecked") // only cast after checking each element's type private static ImmutableSet<PosixFilePermission> toPermissions(Set<?> set) { ImmutableSet<?> copy = ImmutableSet.copyOf(set); for (Object obj : copy) { if (!(obj instanceof PosixFilePermission)) { throw new IllegalArgumentException("invalid element for attribute 'posix:permissions': " + "should be Set<PosixFilePermission>, found element of type " + obj.getClass()); }/*from w w w . j av a 2 s .c o m*/ } return Sets.immutableEnumSet((ImmutableSet<PosixFilePermission>) copy); }
From source file:org.trnltk.model.morpheme.MorphemeContainer.java
public MorphemeContainer(Root root, SuffixGraphState rootState, String remainingSurface) { this.root = root; this.rootState = rootState; this.surfaceSoFar = root.getSequence(); this.remainingSurface = remainingSurface; this.suffixTransitions = new LinkedList<SuffixTransition>(); this.lastState = this.rootState; this.wholeSurface = Strings.nullToEmpty(this.surfaceSoFar.getUnderlyingString()) + Strings.nullToEmpty(this.remainingSurface); this.phoneticExpectations = Sets.immutableEnumSet(root.getPhoneticExpectations()); this.lexemeAttributes = Sets.immutableEnumSet(this.root.getLexeme().getAttributes()); this.phoneticAttributes = Sets.immutableEnumSet(this.root.getPhoneticAttributes()); }
From source file:com.android.build.gradle.internal.pipeline.OriginalStream.java
private OriginalStream(@NonNull Set<ContentType> contentTypes, @NonNull Scope scope, @NonNull Supplier<Collection<File>> jarFiles, @NonNull Supplier<Collection<File>> folders, @NonNull List<? extends Object> dependencies) { super(contentTypes, Sets.immutableEnumSet(scope), dependencies); this.jarFiles = jarFiles; this.folders = folders; }
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 va2s. com*/ // 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.csstudio.utility.ldap.treeconfiguration.LdapEpicsAuthorizeIdConfiguration.java
/** * {@inheritDoc} */ @Override public ImmutableSet<LdapEpicsAuthorizeIdConfiguration> getNestedContainerTypes() { return Sets.immutableEnumSet(_nestedClasses); }
From source file:org.trnltk.morphology.lexicon.LexemeCreator.java
private Lexeme createLexeme(String lemma, String rootStr, PrimaryPos primaryPos, SecondaryPos secondaryPos, Set<LexemeAttribute> lexemeAttributes) { String lemmaRoot = rootStr;/* w w w . j a v a 2 s . c o m*/ if (primaryPos == null) { if (rootStr.endsWith("mek") || rootStr.endsWith("mak")) { primaryPos = PrimaryPos.Verb; lemmaRoot = rootStr.substring(0, rootStr.length() - 3); } else { primaryPos = PrimaryPos.Noun; } } lexemeAttributes = this.inferMorphemicAttributes(lemmaRoot, primaryPos, lexemeAttributes); return new ImmutableLexeme(lemma, lemmaRoot, primaryPos, secondaryPos, Sets.immutableEnumSet(lexemeAttributes)); }
From source file:com.opengamma.strata.basics.date.ImmutableHolidayCalendar.java
/** * Obtains an instance from a set of holiday dates and weekend days. * <p>//from ww w. ja v a 2 s . co m * The holiday dates will be extracted into a set with duplicates ignored. * The minimum supported date for query is the start of the year of the earliest holiday. * The maximum supported date for query is the end of the year of the latest holiday. * <p> * The weekend days may be empty, in which case the holiday dates should contain any weekends. * * @param id the identifier * @param holidays the set of holiday dates * @param weekendDays the days that define the weekend, if empty then weekends are treated as business days * @return the holiday calendar */ public static ImmutableHolidayCalendar of(HolidayCalendarId id, Iterable<LocalDate> holidays, Iterable<DayOfWeek> weekendDays) { return new ImmutableHolidayCalendar(id, ImmutableSortedSet.copyOf(holidays), Sets.immutableEnumSet(weekendDays)); }
From source file:edu.mit.streamjit.util.bytecode.Klass.java
/** * Creates a new immutable Klass instance representing the given class, * recursively creating new Klass instances as required to resolve * references from the given class./*from w w w.jav a 2 s . com*/ * @param klass * @param module * @return */ public Klass(Class<?> klass, Module module) { checkNotNull(klass); checkNotNull(module); checkArgument(module.getKlass(klass.getName()) == null, "klass named %s already in module", klass.getName()); this.backingClass = klass; this.name = klass.getName(); this.modifiers = Sets.immutableEnumSet(Modifier.fromClassBits(Shorts.checkedCast(klass.getModifiers()))); //We're committed now. Even through we aren't fully constructed, //register us with the module so any circular dependencies can find us. //Note that this means we can't use any of the klasses we recurse for //during our own construction! module.klasses().add(this); //sets parent if (klass.getSuperclass() != null) this.superclass = module.getKlass(klass.getSuperclass()); else if (klass.isInterface()) //At the JVM level, interfaces have Object as superclass. this.superclass = module.getKlass(Object.class); else { assert klass.equals(Object.class) || klass.isPrimitive(); this.superclass = null; } ImmutableList.Builder<Klass> interfacesB = ImmutableList.builder(); for (Class<?> c : klass.getInterfaces()) interfacesB.add(module.getKlass(c)); this.interfaces = interfacesB.build(); }