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();
}
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")));
}
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;
}
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);
}
}
}
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;
}
Aggregations