List of usage examples for java.util HashSet addAll
boolean addAll(Collection<? extends E> c);
From source file:org.apache.samza.execution.JobNode.java
/** * Serializes the {@link Serde} instances for operators, adds them to the provided config, and * sets the serde configuration for the input/output/intermediate streams appropriately. * * We try to preserve the number of Serde instances before and after serialization. However we don't * guarantee that references shared between these serdes instances (e.g. an Jackson ObjectMapper shared * between two json serdes) are shared after deserialization too. * * Ideally all the user defined objects in the application should be serialized and de-serialized in one pass * from the same output/input stream so that we can maintain reference sharing relationships. * * @param configs the configs to add serialized serde instances and stream serde configs to *///from ww w . ja v a2 s . co m void addSerdeConfigs(Map<String, String> configs) { // collect all key and msg serde instances for streams Map<String, Serde> streamKeySerdes = new HashMap<>(); Map<String, Serde> streamMsgSerdes = new HashMap<>(); Map<StreamSpec, InputOperatorSpec> inputOperators = streamGraph.getInputOperators(); inEdges.forEach(edge -> { String streamId = edge.getStreamSpec().getId(); InputOperatorSpec inputOperatorSpec = inputOperators.get(edge.getStreamSpec()); streamKeySerdes.put(streamId, inputOperatorSpec.getKeySerde()); streamMsgSerdes.put(streamId, inputOperatorSpec.getValueSerde()); }); Map<StreamSpec, OutputStreamImpl> outputStreams = streamGraph.getOutputStreams(); outEdges.forEach(edge -> { String streamId = edge.getStreamSpec().getId(); OutputStreamImpl outputStream = outputStreams.get(edge.getStreamSpec()); streamKeySerdes.put(streamId, outputStream.getKeySerde()); streamMsgSerdes.put(streamId, outputStream.getValueSerde()); }); // collect all key and msg serde instances for stores Map<String, Serde> storeKeySerdes = new HashMap<>(); Map<String, Serde> storeMsgSerdes = new HashMap<>(); streamGraph.getAllOperatorSpecs().forEach(opSpec -> { if (opSpec instanceof StatefulOperatorSpec) { ((StatefulOperatorSpec) opSpec).getStoreDescriptors().forEach(storeDescriptor -> { storeKeySerdes.put(storeDescriptor.getStoreName(), storeDescriptor.getKeySerde()); storeMsgSerdes.put(storeDescriptor.getStoreName(), storeDescriptor.getMsgSerde()); }); } }); // collect all key and msg serde instances for tables Map<String, Serde> tableKeySerdes = new HashMap<>(); Map<String, Serde> tableValueSerdes = new HashMap<>(); tables.forEach(tableSpec -> { tableKeySerdes.put(tableSpec.getId(), tableSpec.getSerde().getKeySerde()); tableValueSerdes.put(tableSpec.getId(), tableSpec.getSerde().getValueSerde()); }); // for each unique stream or store serde instance, generate a unique name and serialize to config HashSet<Serde> serdes = new HashSet<>(streamKeySerdes.values()); serdes.addAll(streamMsgSerdes.values()); serdes.addAll(storeKeySerdes.values()); serdes.addAll(storeMsgSerdes.values()); serdes.addAll(tableKeySerdes.values()); serdes.addAll(tableValueSerdes.values()); SerializableSerde<Serde> serializableSerde = new SerializableSerde<>(); Base64.Encoder base64Encoder = Base64.getEncoder(); Map<Serde, String> serdeUUIDs = new HashMap<>(); serdes.forEach(serde -> { String serdeName = serdeUUIDs.computeIfAbsent(serde, s -> serde.getClass().getSimpleName() + "-" + UUID.randomUUID().toString()); configs.putIfAbsent(String.format(SerializerConfig.SERDE_SERIALIZED_INSTANCE(), serdeName), base64Encoder.encodeToString(serializableSerde.toBytes(serde))); }); // set key and msg serdes for streams to the serde names generated above streamKeySerdes.forEach((streamId, serde) -> { String streamIdPrefix = String.format(StreamConfig.STREAM_ID_PREFIX(), streamId); String keySerdeConfigKey = streamIdPrefix + StreamConfig.KEY_SERDE(); configs.put(keySerdeConfigKey, serdeUUIDs.get(serde)); }); streamMsgSerdes.forEach((streamId, serde) -> { String streamIdPrefix = String.format(StreamConfig.STREAM_ID_PREFIX(), streamId); String valueSerdeConfigKey = streamIdPrefix + StreamConfig.MSG_SERDE(); configs.put(valueSerdeConfigKey, serdeUUIDs.get(serde)); }); // set key and msg serdes for stores to the serde names generated above storeKeySerdes.forEach((storeName, serde) -> { String keySerdeConfigKey = String.format(StorageConfig.KEY_SERDE(), storeName); configs.put(keySerdeConfigKey, serdeUUIDs.get(serde)); }); storeMsgSerdes.forEach((storeName, serde) -> { String msgSerdeConfigKey = String.format(StorageConfig.MSG_SERDE(), storeName); configs.put(msgSerdeConfigKey, serdeUUIDs.get(serde)); }); // set key and msg serdes for tables to the serde names generated above tableKeySerdes.forEach((tableId, serde) -> { String keySerdeConfigKey = String.format(JavaTableConfig.TABLE_KEY_SERDE, tableId); configs.put(keySerdeConfigKey, serdeUUIDs.get(serde)); }); tableValueSerdes.forEach((tableId, serde) -> { String valueSerdeConfigKey = String.format(JavaTableConfig.TABLE_VALUE_SERDE, tableId); configs.put(valueSerdeConfigKey, serdeUUIDs.get(serde)); }); }
From source file:ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE.java
@Transient public Set<RoleAssignmentPE> getAllPersonRoles() { HashSet<RoleAssignmentPE> result = new HashSet<RoleAssignmentPE>(getRoleAssignments()); for (AuthorizationGroupPE ag : getAuthorizationGroups()) { result.addAll(ag.getRoleAssignments()); }/*from ww w. jav a 2 s . c om*/ return result; }
From source file:com.github.frapontillo.pulse.crowd.remstopword.simple.SimpleStopWordRemover.java
/** * Return the dictionary specified by a file name, building it if it wasn't built sooner. * If the dictionary cannot be built (maybe because files were missing or because files were * empty), no error is thrown, and the returned dictionary will simply be empty, thus removing * no words at all./* w ww . j a v a 2 s. c o m*/ * * @param fileName The name of the file referencing the dictionary (should exist in the * classpath resources). * * @return A {@link HashSet<String>} containing all of the dictionary terms. */ private HashSet<String> getDictionaryByFileName(String fileName) { if (!dictionaries.containsKey(fileName)) { HashSet<String> newDictionary = new HashSet<>(); try { List<String> lines = IOUtils.readLines(getClass().getClassLoader().getResourceAsStream(fileName)); lines = lines.stream().map(String::toLowerCase).collect(Collectors.toList()); newDictionary.addAll(lines); } catch (Exception ignored) { } dictionaries.put(fileName, newDictionary); } return dictionaries.get(fileName); }
From source file:org.dataconservancy.packaging.tool.model.dprofile.NodeType.java
/** * Calculates the HashCode of the NodeType. * Note: Lists are converted to HashSets in this method to make them order independent. * @return The hashcode of the NodeType. *///from www . jav a 2s . c om @Override public int hashCode() { HashSet<URI> domainTypeSet = null; if (domain_types != null) { domainTypeSet = new HashSet<>(); domainTypeSet.addAll(domain_types); } HashSet<NodeConstraint> parentConstraintSet = null; if (parent_constraints != null) { parentConstraintSet = new HashSet<>(); parentConstraintSet.addAll(parent_constraints); } HashSet<PropertyConstraint> propertyConstraintSet = null; if (property_constraints != null) { propertyConstraintSet = new HashSet<>(); propertyConstraintSet.addAll(property_constraints); } HashSet<PropertyType> inheritablePropertySet = null; if (inheritable_properties != null) { inheritablePropertySet = new HashSet<>(); inheritablePropertySet.addAll(inheritable_properties); } HashSet<Property> defaultPropertyValueSet = null; if (default_property_values != null) { defaultPropertyValueSet = new HashSet<>(); defaultPropertyValueSet.addAll(default_property_values); } final int prime = 31; int result = super.hashCode(); result = prime * result + ((child_file_constraint == null) ? 0 : child_file_constraint.hashCode()); result = prime * result + ((defaultPropertyValueSet == null) ? 0 : defaultPropertyValueSet.hashCode()); result = prime * result + ((domainTypeSet == null) ? 0 : domainTypeSet.hashCode()); result = prime * result + ((file_assoc == null) ? 0 : file_assoc.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((inheritablePropertySet == null) ? 0 : inheritablePropertySet.hashCode()); result = prime * result + ((parentConstraintSet == null) ? 0 : parentConstraintSet.hashCode()); result = prime * result + ((profile == null || profile.getIdentifier() == null) ? 0 : profile.getIdentifier().hashCode()); result = prime * result + ((propertyConstraintSet == null) ? 0 : propertyConstraintSet.hashCode()); result = prime * result + ((supplied_properties == null) ? 0 : supplied_properties.hashCode()); result = prime * result + ((preferredParentType == null) ? 0 : preferredParentType.getIdentifier().hashCode()); return result; }
From source file:edu.internet2.middleware.shibboleth.common.attribute.provider.ShibbolethSAML2AttributeAuthority.java
/** {@inheritDoc} */ public Map<String, BaseAttribute> getAttributes( SAMLProfileRequestContext<? extends RequestAbstractType, ? extends StatusResponseType, NameID, ? extends AbstractSAML2ProfileConfiguration> requestContext) throws AttributeRequestException { HashSet<String> requestedAttributes = new HashSet<String>(); // get attributes from the message Set<String> queryAttributeIds = getAttributeIds(requestContext.getInboundSAMLMessage()); requestedAttributes.addAll(queryAttributeIds); // get attributes from metadata Set<String> metadataAttributeIds = getAttribtueIds(requestContext.getPeerEntityMetadata()); requestedAttributes.addAll(metadataAttributeIds); requestContext.setRequestedAttributes(requestedAttributes); // Resolve attributes Map<String, BaseAttribute> attributes = attributeResolver.resolveAttributes(requestContext); // Filter resulting attributes if (filteringEngine != null) { attributes = filteringEngine.filterAttributes(attributes, requestContext); }/*from w ww .j a v a2s . co m*/ return attributes; }
From source file:ca.uhn.fhir.rest.method.SearchParameter.java
@SuppressWarnings({ "unchecked", "unused" }) public void setType(FhirContext theContext, final Class<?> type, Class<? extends Collection<?>> theInnerCollectionType, Class<? extends Collection<?>> theOuterCollectionType) { this.myType = type; if (IQueryParameterType.class.isAssignableFrom(type)) { myParamBinder = new QueryParameterTypeBinder((Class<? extends IQueryParameterType>) type, myCompositeTypes);// w w w. j av a 2s. c om } else if (IQueryParameterOr.class.isAssignableFrom(type)) { myParamBinder = new QueryParameterOrBinder((Class<? extends IQueryParameterOr<?>>) type, myCompositeTypes); } else if (IQueryParameterAnd.class.isAssignableFrom(type)) { myParamBinder = new QueryParameterAndBinder((Class<? extends IQueryParameterAnd<?>>) type, myCompositeTypes); } else if (String.class.equals(type)) { myParamBinder = new StringBinder(); myParamType = RestSearchParameterTypeEnum.STRING; } else if (Date.class.equals(type)) { myParamBinder = new DateBinder(); myParamType = RestSearchParameterTypeEnum.DATE; } else if (Calendar.class.equals(type)) { myParamBinder = new CalendarBinder(); myParamType = RestSearchParameterTypeEnum.DATE; } else if (IPrimitiveType.class.isAssignableFrom(type) && ReflectionUtil.isInstantiable(type)) { RuntimePrimitiveDatatypeDefinition def = (RuntimePrimitiveDatatypeDefinition) theContext .getElementDefinition((Class<? extends IPrimitiveType<?>>) type); if (def.getNativeType() != null) { if (def.getNativeType().equals(Date.class)) { myParamBinder = new FhirPrimitiveBinder((Class<IPrimitiveType<?>>) type); myParamType = RestSearchParameterTypeEnum.DATE; } else if (def.getNativeType().equals(String.class)) { myParamBinder = new FhirPrimitiveBinder((Class<IPrimitiveType<?>>) type); myParamType = RestSearchParameterTypeEnum.STRING; } } } else { throw new ConfigurationException("Unsupported data type for parameter: " + type.getCanonicalName()); } RestSearchParameterTypeEnum typeEnum = ourParamTypes.get(type); if (typeEnum != null) { Set<String> builtInQualifiers = ourParamQualifiers.get(typeEnum); if (builtInQualifiers != null) { if (myQualifierWhitelist != null) { HashSet<String> qualifierWhitelist = new HashSet<String>(); qualifierWhitelist.addAll(myQualifierWhitelist); qualifierWhitelist.addAll(builtInQualifiers); myQualifierWhitelist = qualifierWhitelist; } else { myQualifierWhitelist = Collections.unmodifiableSet(builtInQualifiers); } } } if (myParamType == null) { myParamType = typeEnum; } if (myParamType != null) { // ok } else if (StringDt.class.isAssignableFrom(type)) { myParamType = RestSearchParameterTypeEnum.STRING; } else if (BaseIdentifierDt.class.isAssignableFrom(type)) { myParamType = RestSearchParameterTypeEnum.TOKEN; } else if (BaseQuantityDt.class.isAssignableFrom(type)) { myParamType = RestSearchParameterTypeEnum.QUANTITY; } else if (ReferenceParam.class.isAssignableFrom(type)) { myParamType = RestSearchParameterTypeEnum.REFERENCE; } else if (HasParam.class.isAssignableFrom(type)) { myParamType = RestSearchParameterTypeEnum.STRING; } else { throw new ConfigurationException("Unknown search parameter type: " + type); } // NB: Once this is enabled, we should return true from handlesMissing if // it's a collection type // if (theInnerCollectionType != null) { // this.parser = new CollectionBinder(this.parser, theInnerCollectionType); // } // // if (theOuterCollectionType != null) { // this.parser = new CollectionBinder(this.parser, theOuterCollectionType); // } }
From source file:org.apache.cocoon.servletservice.ServletServiceContext.java
public Set getResourcePaths(String path) { if (path == null) { return Collections.EMPTY_SET; }//from www. ja v a 2 s .co m String pathPrefix; if (this.contextPath.startsWith("file:")) { pathPrefix = this.contextPath.substring("file:".length()); } else { pathPrefix = this.contextPath; } path = pathPrefix + path; File file = new File(path); if (!file.exists()) { return Collections.EMPTY_SET; } HashSet set = new HashSet(); set.addAll(getDirectoryList(file, pathPrefix)); return set; }
From source file:it.cnr.icar.eric.client.xml.registry.infomodel.ConceptImpl.java
public HashSet<Concept> getComposedObjects() throws JAXRException { @SuppressWarnings("unchecked") HashSet<Concept> composedObjects = super.getComposedObjects(); composedObjects.addAll(children); composedObjects.addAll(getChildrenConcepts()); return composedObjects; }
From source file:com.mentor.questa.ucdb.jenkins.QuestaCoverageHistory.java
public Set<String> getTrendableAttributes() { HashSet<String> attrSet = new HashSet<String>(); for (QuestaAttributeGraphTab pub : getAttributesPublishers()) { attrSet.addAll(pub.getAttributes()); }/*w w w . j a va2s. co m*/ return attrSet; }
From source file:org.apache.ode.bpel.memdao.ProcessInstanceDaoImpl.java
public Set<CorrelationSetDAO> getCorrelationSets() { HashSet<CorrelationSetDAO> res = new HashSet<CorrelationSetDAO>(); for (ScopeDAO scopeDAO : _scopes.values()) { res.addAll(scopeDAO.getCorrelationSets()); }/*from w w w .j a v a 2 s. c om*/ return res; }