Search in sources :

Example 81 with ImmutableSet

use of com.google.common.collect.ImmutableSet in project core-java by SpineEventEngine.

the class IoUtil method loadAllProperties.

/**
     * Loads all data from {@code .properties} file(s) into memory.
     *
     * <p>Logs {@link IOException} if it occurs.
     *
     * @param propsFilePath the path of the {@code .properties} file to load
     */
public static ImmutableSet<Properties> loadAllProperties(String propsFilePath) {
    checkNotNull(propsFilePath);
    final ImmutableSet.Builder<Properties> result = ImmutableSet.builder();
    final Enumeration<URL> resources = getResources(propsFilePath);
    if (resources == null) {
        return result.build();
    }
    while (resources.hasMoreElements()) {
        final URL resourceUrl = resources.nextElement();
        final Properties properties = loadPropertiesFile(resourceUrl);
        result.add(properties);
    }
    return result.build();
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Properties(java.util.Properties) URL(java.net.URL)

Example 82 with ImmutableSet

use of com.google.common.collect.ImmutableSet in project ds3_autogen by SpectraLogic.

the class CCodeGenerator_Test method testStuctsContainsJobCreationFailedNotificationPayload.

@Test
public void testStuctsContainsJobCreationFailedNotificationPayload() throws IOException, ParseException {
    final Ds3SpecParser parser = new Ds3SpecParserImpl();
    final Ds3ApiSpec spec = parser.getSpec(CCodeGenerator_Test.class.getResourceAsStream("/input/3_2_2_contract.xml"));
    final ImmutableList<Enum> allEnums = CCodeGenerator.getAllEnums(spec);
    final ImmutableSet<String> enumNames = EnumHelper.getEnumNamesSet(allEnums);
    final ImmutableSet<String> arrayMemberTypes = CCodeGenerator.getArrayMemberTypes(spec, enumNames);
    final ImmutableSet<String> embeddedTypes = CCodeGenerator.getEmbeddedTypes(spec, enumNames);
    final ImmutableList<Request> allRequests = CCodeGenerator.getAllRequests(spec, new Ds3DocSpecEmptyImpl());
    final ImmutableSet<String> responseTypes = RequestHelper.getResponseTypes(allRequests);
    final ImmutableSet<String> paginatedTypes = CCodeGenerator.getPaginatedTypes(spec);
    final ImmutableList<Struct> allStructs = CCodeGenerator.getAllStructs(spec, enumNames, responseTypes, embeddedTypes, arrayMemberTypes, paginatedTypes);
    assertTrue(allStructs.stream().map(Struct::getName).anyMatch(name -> name.equals("ds3_job_creation_failed_notification_payload_response")));
}
Also used : Enum(com.spectralogic.ds3autogen.c.models.Enum) CoreMatchers.is(org.hamcrest.CoreMatchers.is) EnumHelper(com.spectralogic.ds3autogen.c.helpers.EnumHelper) StructHelper(com.spectralogic.ds3autogen.c.helpers.StructHelper) com.spectralogic.ds3autogen.c.models(com.spectralogic.ds3autogen.c.models) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TemplateModelException(freemarker.template.TemplateModelException) Ds3SpecParserImpl(com.spectralogic.ds3autogen.Ds3SpecParserImpl) SourceConverter(com.spectralogic.ds3autogen.c.converters.SourceConverter) LoggerFactory(org.slf4j.LoggerFactory) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Ds3ModelFixtures(com.spectralogic.ds3autogen.testutil.Ds3ModelFixtures) HashMap(java.util.HashMap) RequestConverter(com.spectralogic.ds3autogen.c.converters.RequestConverter) NameMapper(com.spectralogic.ds3autogen.NameMapper) TestFileUtilsImpl(com.spectralogic.ds3autogen.utils.TestFileUtilsImpl) Ds3SpecParser(com.spectralogic.ds3autogen.api.Ds3SpecParser) RequestHelper(com.spectralogic.ds3autogen.c.helpers.RequestHelper) Matcher(java.util.regex.Matcher) ImmutableList(com.google.common.collect.ImmutableList) Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) Map(java.util.Map) Ds3DocSpecParserImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecParserImpl) ParseException(java.text.ParseException) Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) ImmutableSet(com.google.common.collect.ImmutableSet) StructConverter(com.spectralogic.ds3autogen.c.converters.StructConverter) Logger(org.slf4j.Logger) ImmutableMap(com.google.common.collect.ImmutableMap) Ds3DocSpecParser(com.spectralogic.ds3autogen.api.Ds3DocSpecParser) Test(org.junit.Test) IOException(java.io.IOException) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec) Enum(com.spectralogic.ds3autogen.c.models.Enum) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) EnumConverter(com.spectralogic.ds3autogen.c.converters.EnumConverter) Ds3DocSpecImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl) Assert(org.junit.Assert) Ds3SpecParser(com.spectralogic.ds3autogen.api.Ds3SpecParser) Ds3SpecParserImpl(com.spectralogic.ds3autogen.Ds3SpecParserImpl) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) Test(org.junit.Test)

Example 83 with ImmutableSet

use of com.google.common.collect.ImmutableSet in project android by JetBrains.

the class ResourceManager method findValueResourceInfos.

@NotNull
public List<ValueResourceInfoImpl> findValueResourceInfos(@NotNull String resourceType, @NotNull final String resourceName, final boolean distinguishDelimetersInName, boolean searchAttrs) {
    final ResourceType type = resourceType.startsWith("+") ? ResourceType.ID : ResourceType.getEnum(resourceType);
    if (type == null || !AndroidResourceUtil.VALUE_RESOURCE_TYPES.contains(type) && (type != ResourceType.ATTR || !searchAttrs)) {
        return Collections.emptyList();
    }
    final GlobalSearchScope scope = GlobalSearchScope.allScope(myProject);
    final List<ValueResourceInfoImpl> result = new ArrayList<ValueResourceInfoImpl>();
    final Set<VirtualFile> valueResourceFiles = getAllValueResourceFiles();
    FileBasedIndex.getInstance().processValues(AndroidValueResourcesIndex.INDEX_ID, AndroidValueResourcesIndex.createTypeNameMarkerKey(resourceType, resourceName), null, new FileBasedIndex.ValueProcessor<ImmutableSet<AndroidValueResourcesIndex.MyResourceInfo>>() {

        @Override
        public boolean process(@NotNull VirtualFile file, ImmutableSet<AndroidValueResourcesIndex.MyResourceInfo> infos) {
            for (AndroidValueResourcesIndex.MyResourceInfo info : infos) {
                final String name = info.getResourceEntry().getName();
                if (AndroidUtils.equal(resourceName, name, distinguishDelimetersInName)) {
                    if (valueResourceFiles.contains(file)) {
                        result.add(new ValueResourceInfoImpl(info.getResourceEntry().getName(), type, file, myProject, info.getOffset()));
                    }
                }
            }
            return true;
        }
    }, scope);
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ResourceType(com.android.resources.ResourceType) ImmutableSet(com.google.common.collect.ImmutableSet) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) AndroidValueResourcesIndex(org.jetbrains.android.AndroidValueResourcesIndex) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex) NotNull(org.jetbrains.annotations.NotNull)

Example 84 with ImmutableSet

use of com.google.common.collect.ImmutableSet in project gerrit by GerritCodeReview.

the class Helper method recursivelyExpandGroups.

private void recursivelyExpandGroups(final Set<String> groupDNs, final LdapSchema schema, final DirContext ctx, final String groupDN) {
    if (groupDNs.add(groupDN) && schema.accountMemberField != null && schema.accountMemberExpandGroups) {
        ImmutableSet<String> cachedParentsDNs = parentGroups.getIfPresent(groupDN);
        if (cachedParentsDNs == null) {
            // Recursively identify the groups it is a member of.
            ImmutableSet.Builder<String> dns = ImmutableSet.builder();
            try {
                final Name compositeGroupName = new CompositeName().add(groupDN);
                final Attribute in = ctx.getAttributes(compositeGroupName, schema.accountMemberFieldArray).get(schema.accountMemberField);
                if (in != null) {
                    final NamingEnumeration<?> groups = in.getAll();
                    try {
                        while (groups.hasMore()) {
                            dns.add((String) groups.next());
                        }
                    } catch (PartialResultException e) {
                    // Ignored
                    }
                }
            } catch (NamingException e) {
                LdapRealm.log.warn("Could not find group " + groupDN, e);
            }
            cachedParentsDNs = dns.build();
            parentGroups.put(groupDN, cachedParentsDNs);
        }
        for (String dn : cachedParentsDNs) {
            recursivelyExpandGroups(groupDNs, schema, ctx, dn);
        }
    }
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Attribute(javax.naming.directory.Attribute) CompositeName(javax.naming.CompositeName) PartialResultException(javax.naming.PartialResultException) NamingException(javax.naming.NamingException) ParameterizedString(com.google.gerrit.common.data.ParameterizedString) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name)

Example 85 with ImmutableSet

use of com.google.common.collect.ImmutableSet in project incubator-atlas by apache.

the class TypeConverterUtil method classificationToTypesDef.

private static TypesDef classificationToTypesDef(AtlasClassificationType classificationType, AtlasTypeRegistry registry) throws AtlasBaseException {
    String typeName = classificationType.getClassificationDef().getName();
    String typeDesc = classificationType.getClassificationDef().getDescription();
    String typeVersion = classificationType.getClassificationDef().getTypeVersion();
    ImmutableSet superTypes = ImmutableSet.copyOf(classificationType.getClassificationDef().getSuperTypes());
    AttributeDefinition[] attributes = getAttributes(classificationType, registry);
    HierarchicalTypeDefinition traitType = TypesUtil.createTraitTypeDef(typeName, typeDesc, typeVersion, superTypes, attributes);
    TypesDef ret = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(traitType), ImmutableList.<HierarchicalTypeDefinition<ClassType>>of());
    return ret;
}
Also used : HierarchicalTypeDefinition(org.apache.atlas.typesystem.types.HierarchicalTypeDefinition) ImmutableSet(com.google.common.collect.ImmutableSet) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) TypesDef(org.apache.atlas.typesystem.TypesDef) TraitType(org.apache.atlas.typesystem.types.TraitType) AttributeDefinition(org.apache.atlas.typesystem.types.AttributeDefinition) ClassType(org.apache.atlas.typesystem.types.ClassType)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)212 Path (java.nio.file.Path)66 BuildTarget (com.facebook.buck.model.BuildTarget)58 ImmutableList (com.google.common.collect.ImmutableList)48 ImmutableMap (com.google.common.collect.ImmutableMap)48 IOException (java.io.IOException)43 Optional (java.util.Optional)39 Test (org.junit.Test)35 SourcePath (com.facebook.buck.rules.SourcePath)31 Set (java.util.Set)31 Map (java.util.Map)30 TargetNode (com.facebook.buck.rules.TargetNode)28 List (java.util.List)28 BuildRule (com.facebook.buck.rules.BuildRule)26 HumanReadableException (com.facebook.buck.util.HumanReadableException)23 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)22 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)21 HashMap (java.util.HashMap)21 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)20 VisibleForTesting (com.google.common.annotations.VisibleForTesting)20