List of usage examples for java.util LinkedHashMap putAll
void putAll(Map<? extends K, ? extends V> m);
From source file:org.biokoframework.utils.json.JSonParser.java
@SuppressWarnings("unchecked") public LinkedHashMap<String, Object> parseToMap(String json) { LinkedHashMap<String, Object> hashMap = new LinkedHashMap<String, Object>(); Object parsed = JSONValue.parse(json); if (parsed != null) { hashMap.putAll((Map<String, Object>) parsed); }/* ww w . ja v a 2s . c om*/ return hashMap; }
From source file:com.quancheng.saluki.gateway.zuul.extend.StoreProxyRouteLocator.java
@Override protected LinkedHashMap<String, ZuulRoute> locateRoutes() { LinkedHashMap<String, ZuulRoute> routesMap = new LinkedHashMap<String, ZuulRoute>(); routesMap.putAll(super.locateRoutes()); for (ZuulProperties.ZuulRoute route : findAll()) { routesMap.put(route.getPath(), route); }/* w w w . j a v a 2 s .c o m*/ return routesMap; }
From source file:io.wcm.caravan.io.http.request.Request.java
Request(String method, String url, Map<String, Collection<String>> headers, byte[] body, Charset charset) { this.method = checkNotNull(method, "method of %s", url); this.url = checkNotNull(url, "url"); LinkedHashMap<String, Collection<String>> copyOf = new LinkedHashMap<String, Collection<String>>(); copyOf.putAll(checkNotNull(headers, "headers of %s %s", method, url)); this.headers = Collections.unmodifiableMap(copyOf); this.body = body; // nullable this.charset = charset; // nullable }
From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.SimpleParameterSensitivity.java
/** * Create a copy of the sensitivity and add a given named sensitivity to it. If the name / currency pair is in the map, the two sensitivity matrices are added. * Otherwise, a new entry is put into the map * @param name The name. Not null./*from w w w .j a va 2s . com*/ * @param sensitivity The sensitivity to add, not null * @return The total sensitivity. */ public SimpleParameterSensitivity plus(final String name, final DoubleMatrix1D sensitivity) { ArgumentChecker.notNull(name, "Name"); ArgumentChecker.notNull(sensitivity, "Matrix"); final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA; final LinkedHashMap<String, DoubleMatrix1D> result = new LinkedHashMap<>(); result.putAll(_sensitivity); if (result.containsKey(name)) { result.put(name, (DoubleMatrix1D) algebra.add(result.get(name), sensitivity)); } else { result.put(name, sensitivity); } return new SimpleParameterSensitivity(result); }
From source file:com.espertech.esper.epl.spec.PatternStreamSpecRaw.java
private static void recursiveCompile(EvalFactoryNode evalNode, StatementContext context, ExprEvaluatorContext evaluatorContext, Set<String> eventTypeReferences, boolean isInsertInto, MatchEventSpec tags, Deque<Integer> subexpressionIdStack, Stack<EvalFactoryNode> parentNodeStack, LinkedHashSet<String> allTagNamesOrdered) throws ExprValidationException { int counter = 0; parentNodeStack.push(evalNode);/*from www. ja va 2s . co m*/ for (EvalFactoryNode child : evalNode.getChildNodes()) { subexpressionIdStack.addLast(counter++); recursiveCompile(child, context, evaluatorContext, eventTypeReferences, isInsertInto, tags, subexpressionIdStack, parentNodeStack, allTagNamesOrdered); subexpressionIdStack.removeLast(); } parentNodeStack.pop(); LinkedHashMap<String, Pair<EventType, String>> newTaggedEventTypes = null; LinkedHashMap<String, Pair<EventType, String>> newArrayEventTypes = null; if (evalNode instanceof EvalFilterFactoryNode) { EvalFilterFactoryNode filterNode = (EvalFilterFactoryNode) evalNode; String eventName = filterNode.getRawFilterSpec().getEventTypeName(); EventType resolvedEventType = FilterStreamSpecRaw.resolveType(context.getEngineURI(), eventName, context.getEventAdapterService(), context.getPlugInTypeResolutionURIs()); EventType finalEventType = resolvedEventType; String optionalTag = filterNode.getEventAsName(); boolean isPropertyEvaluation = false; boolean isParentMatchUntil = isParentMatchUntil(evalNode, parentNodeStack); // obtain property event type, if final event type is properties if (filterNode.getRawFilterSpec().getOptionalPropertyEvalSpec() != null) { PropertyEvaluator optionalPropertyEvaluator = PropertyEvaluatorFactory.makeEvaluator( filterNode.getRawFilterSpec().getOptionalPropertyEvalSpec(), resolvedEventType, filterNode.getEventAsName(), context.getEventAdapterService(), context.getMethodResolutionService(), context.getSchedulingService(), context.getVariableService(), context.getEngineURI(), context.getStatementId(), context.getStatementName(), context.getAnnotations(), subexpressionIdStack, context.getConfigSnapshot()); finalEventType = optionalPropertyEvaluator.getFragmentEventType(); isPropertyEvaluation = true; } if (finalEventType instanceof EventTypeSPI) { eventTypeReferences.add(((EventTypeSPI) finalEventType).getMetadata().getPrimaryName()); } // If a tag was supplied for the type, the tags must stay with this type, i.e. a=BeanA -> b=BeanA -> a=BeanB is a no if (optionalTag != null) { Pair<EventType, String> pair = tags.getTaggedEventTypes().get(optionalTag); EventType existingType = null; if (pair != null) { existingType = pair.getFirst(); } if (existingType == null) { pair = tags.getArrayEventTypes().get(optionalTag); if (pair != null) { throw new ExprValidationException("Tag '" + optionalTag + "' for event '" + eventName + "' used in the repeat-until operator cannot also appear in other filter expressions"); } } if ((existingType != null) && (existingType != finalEventType)) { throw new ExprValidationException("Tag '" + optionalTag + "' for event '" + eventName + "' has already been declared for events of type " + existingType.getUnderlyingType().getName()); } pair = new Pair<EventType, String>(finalEventType, eventName); // add tagged type if (isPropertyEvaluation || isParentMatchUntil) { newArrayEventTypes = new LinkedHashMap<String, Pair<EventType, String>>(); newArrayEventTypes.put(optionalTag, pair); } else { newTaggedEventTypes = new LinkedHashMap<String, Pair<EventType, String>>(); newTaggedEventTypes.put(optionalTag, pair); } } // For this filter, filter types are all known tags at this time, // and additionally stream 0 (self) is our event type. // Stream type service allows resolution by property name event if that name appears in other tags. // by defaulting to stream zero. // Stream zero is always the current event type, all others follow the order of the map (stream 1 to N). String selfStreamName = optionalTag; if (selfStreamName == null) { selfStreamName = "s_" + UuidGenerator.generate(); } LinkedHashMap<String, Pair<EventType, String>> filterTypes = new LinkedHashMap<String, Pair<EventType, String>>(); Pair<EventType, String> typePair = new Pair<EventType, String>(finalEventType, eventName); filterTypes.put(selfStreamName, typePair); filterTypes.putAll(tags.getTaggedEventTypes()); // for the filter, specify all tags used LinkedHashMap<String, Pair<EventType, String>> filterTaggedEventTypes = new LinkedHashMap<String, Pair<EventType, String>>( tags.getTaggedEventTypes()); filterTaggedEventTypes.remove(optionalTag); // handle array tags (match-until clause) LinkedHashMap<String, Pair<EventType, String>> arrayCompositeEventTypes = null; if (tags.getArrayEventTypes() != null && !tags.getArrayEventTypes().isEmpty()) { arrayCompositeEventTypes = new LinkedHashMap<String, Pair<EventType, String>>(); String patternSubexEventType = getPatternSubexEventType(context.getStatementId(), "pattern", subexpressionIdStack); for (Map.Entry<String, Pair<EventType, String>> entry : tags.getArrayEventTypes().entrySet()) { LinkedHashMap<String, Pair<EventType, String>> specificArrayType = new LinkedHashMap<String, Pair<EventType, String>>(); specificArrayType.put(entry.getKey(), entry.getValue()); EventType arrayTagCompositeEventType = context.getEventAdapterService() .createSemiAnonymousMapType(patternSubexEventType, Collections.<String, Pair<EventType, String>>emptyMap(), specificArrayType, isInsertInto); String tag = entry.getKey(); if (!filterTypes.containsKey(tag)) { Pair<EventType, String> pair = new Pair<EventType, String>(arrayTagCompositeEventType, tag); filterTypes.put(tag, pair); arrayCompositeEventTypes.put(tag, pair); } } } StreamTypeService streamTypeService = new StreamTypeServiceImpl(filterTypes, context.getEngineURI(), true, false); List<ExprNode> exprNodes = filterNode.getRawFilterSpec().getFilterExpressions(); FilterSpecCompiled spec = FilterSpecCompiler.makeFilterSpec(resolvedEventType, eventName, exprNodes, filterNode.getRawFilterSpec().getOptionalPropertyEvalSpec(), filterTaggedEventTypes, arrayCompositeEventTypes, streamTypeService, null, context, subexpressionIdStack); filterNode.setFilterSpec(spec); } else if (evalNode instanceof EvalObserverFactoryNode) { EvalObserverFactoryNode observerNode = (EvalObserverFactoryNode) evalNode; try { ObserverFactory observerFactory = context.getPatternResolutionService() .create(observerNode.getPatternObserverSpec()); StreamTypeService streamTypeService = getStreamTypeService(context.getEngineURI(), context.getStatementId(), context.getEventAdapterService(), tags.getTaggedEventTypes(), tags.getArrayEventTypes(), subexpressionIdStack, "observer"); ExprValidationContext validationContext = new ExprValidationContext(streamTypeService, context.getMethodResolutionService(), null, context.getSchedulingService(), context.getVariableService(), evaluatorContext, context.getEventAdapterService(), context.getStatementName(), context.getStatementId(), context.getAnnotations(), context.getContextDescriptor()); List<ExprNode> validated = validateExpressions( observerNode.getPatternObserverSpec().getObjectParameters(), validationContext); MatchedEventConvertor convertor = new MatchedEventConvertorImpl(tags.getTaggedEventTypes(), tags.getArrayEventTypes(), allTagNamesOrdered, context.getEventAdapterService()); observerNode.setObserverFactory(observerFactory); observerFactory.setObserverParameters(validated, convertor); } catch (ObserverParameterException e) { throw new ExprValidationException("Invalid parameter for pattern observer: " + e.getMessage(), e); } catch (PatternObjectException e) { throw new ExprValidationException("Failed to resolve pattern observer: " + e.getMessage(), e); } } else if (evalNode instanceof EvalGuardFactoryNode) { EvalGuardFactoryNode guardNode = (EvalGuardFactoryNode) evalNode; try { GuardFactory guardFactory = context.getPatternResolutionService() .create(guardNode.getPatternGuardSpec()); StreamTypeService streamTypeService = getStreamTypeService(context.getEngineURI(), context.getStatementId(), context.getEventAdapterService(), tags.getTaggedEventTypes(), tags.getArrayEventTypes(), subexpressionIdStack, "guard"); ExprValidationContext validationContext = new ExprValidationContext(streamTypeService, context.getMethodResolutionService(), null, context.getSchedulingService(), context.getVariableService(), evaluatorContext, context.getEventAdapterService(), context.getStatementName(), context.getStatementId(), context.getAnnotations(), context.getContextDescriptor()); List<ExprNode> validated = validateExpressions( guardNode.getPatternGuardSpec().getObjectParameters(), validationContext); MatchedEventConvertor convertor = new MatchedEventConvertorImpl(tags.getTaggedEventTypes(), tags.getArrayEventTypes(), allTagNamesOrdered, context.getEventAdapterService()); guardNode.setGuardFactory(guardFactory); guardFactory.setGuardParameters(validated, convertor); } catch (GuardParameterException e) { throw new ExprValidationException("Invalid parameter for pattern guard: " + e.getMessage(), e); } catch (PatternObjectException e) { throw new ExprValidationException("Failed to resolve pattern guard: " + e.getMessage(), e); } } else if (evalNode instanceof EvalEveryDistinctFactoryNode) { EvalEveryDistinctFactoryNode distinctNode = (EvalEveryDistinctFactoryNode) evalNode; MatchEventSpec matchEventFromChildNodes = analyzeMatchEvent(distinctNode); StreamTypeService streamTypeService = getStreamTypeService(context.getEngineURI(), context.getStatementId(), context.getEventAdapterService(), matchEventFromChildNodes.getTaggedEventTypes(), matchEventFromChildNodes.getArrayEventTypes(), subexpressionIdStack, "every-distinct"); ExprValidationContext validationContext = new ExprValidationContext(streamTypeService, context.getMethodResolutionService(), null, context.getSchedulingService(), context.getVariableService(), evaluatorContext, context.getEventAdapterService(), context.getStatementName(), context.getStatementId(), context.getAnnotations(), context.getContextDescriptor()); List<ExprNode> validated; try { validated = validateExpressions(distinctNode.getExpressions(), validationContext); } catch (ExprValidationPropertyException ex) { throw new ExprValidationPropertyException(ex.getMessage() + ", every-distinct requires that all properties resolve from sub-expressions to the every-distinct", ex.getCause()); } MatchedEventConvertor convertor = new MatchedEventConvertorImpl( matchEventFromChildNodes.getTaggedEventTypes(), matchEventFromChildNodes.getArrayEventTypes(), allTagNamesOrdered, context.getEventAdapterService()); distinctNode.setConvertor(convertor); // Determine whether some expressions are constants or time period List<ExprNode> distinctExpressions = new ArrayList<ExprNode>(); Long msecToExpire = null; for (ExprNode expr : validated) { if (expr instanceof ExprTimePeriod) { Double secondsExpire = (Double) ((ExprTimePeriod) expr).evaluate(null, true, evaluatorContext); if ((secondsExpire != null) && (secondsExpire > 0)) { msecToExpire = Math.round(1000d * secondsExpire); } log.debug("Setting every-distinct msec-to-expire to " + msecToExpire); } else if (expr.isConstantResult()) { log.warn( "Every-distinct node utilizes an expression returning a constant value, please check expression '" + expr.toExpressionString() + "', not adding expression to distinct-value expression list"); } else { distinctExpressions.add(expr); } } if (distinctExpressions.isEmpty()) { throw new ExprValidationException( "Every-distinct node requires one or more distinct-value expressions that each return non-constant result values"); } distinctNode.setDistinctExpressions(distinctExpressions, msecToExpire); } else if (evalNode instanceof EvalMatchUntilFactoryNode) { EvalMatchUntilFactoryNode matchUntilNode = (EvalMatchUntilFactoryNode) evalNode; // compile bounds expressions, if any MatchEventSpec untilMatchEventSpec = new MatchEventSpec(tags.getTaggedEventTypes(), tags.getArrayEventTypes()); StreamTypeService streamTypeService = getStreamTypeService(context.getEngineURI(), context.getStatementId(), context.getEventAdapterService(), untilMatchEventSpec.getTaggedEventTypes(), untilMatchEventSpec.getArrayEventTypes(), subexpressionIdStack, "until"); ExprValidationContext validationContext = new ExprValidationContext(streamTypeService, context.getMethodResolutionService(), null, context.getSchedulingService(), context.getVariableService(), evaluatorContext, context.getEventAdapterService(), context.getStatementName(), context.getStatementId(), context.getAnnotations(), context.getContextDescriptor()); String message = "Match-until bounds value expressions must return a numeric value"; if (matchUntilNode.getLowerBounds() != null) { ExprNode validated = ExprNodeUtility.getValidatedSubtree(matchUntilNode.getLowerBounds(), validationContext); matchUntilNode.setLowerBounds(validated); if ((validated.getExprEvaluator().getType() == null) || (!JavaClassHelper.isNumeric(validated.getExprEvaluator().getType()))) { throw new ExprValidationException(message); } } if (matchUntilNode.getUpperBounds() != null) { ExprNode validated = ExprNodeUtility.getValidatedSubtree(matchUntilNode.getUpperBounds(), validationContext); matchUntilNode.setUpperBounds(validated); if ((validated.getExprEvaluator().getType() == null) || (!JavaClassHelper.isNumeric(validated.getExprEvaluator().getType()))) { throw new ExprValidationException(message); } } MatchedEventConvertor convertor = new MatchedEventConvertorImpl( untilMatchEventSpec.getTaggedEventTypes(), untilMatchEventSpec.getArrayEventTypes(), allTagNamesOrdered, context.getEventAdapterService()); matchUntilNode.setConvertor(convertor); // compile new tag lists Set<String> arrayTags = null; EvalNodeAnalysisResult matchUntilAnalysisResult = EvalNodeUtil .recursiveAnalyzeChildNodes(matchUntilNode.getChildNodes().get(0)); for (EvalFilterFactoryNode filterNode : matchUntilAnalysisResult.getFilterNodes()) { String optionalTag = filterNode.getEventAsName(); if (optionalTag != null) { if (arrayTags == null) { arrayTags = new HashSet<String>(); } arrayTags.add(optionalTag); } } if (arrayTags != null) { for (String arrayTag : arrayTags) { if (!tags.getArrayEventTypes().containsKey(arrayTag)) { tags.getArrayEventTypes().put(arrayTag, tags.getTaggedEventTypes().get(arrayTag)); tags.getTaggedEventTypes().remove(arrayTag); } } } matchUntilNode.setTagsArrayedSet(getIndexesForTags(allTagNamesOrdered, arrayTags)); } else if (evalNode instanceof EvalFollowedByFactoryNode) { EvalFollowedByFactoryNode followedByNode = (EvalFollowedByFactoryNode) evalNode; StreamTypeService streamTypeService = new StreamTypeServiceImpl(context.getEngineURI(), false); ExprValidationContext validationContext = new ExprValidationContext(streamTypeService, context.getMethodResolutionService(), null, context.getSchedulingService(), context.getVariableService(), evaluatorContext, context.getEventAdapterService(), context.getStatementName(), context.getStatementId(), context.getAnnotations(), context.getContextDescriptor()); if (followedByNode.getOptionalMaxExpressions() != null) { List<ExprNode> validated = new ArrayList<ExprNode>(); for (ExprNode maxExpr : followedByNode.getOptionalMaxExpressions()) { if (maxExpr == null) { validated.add(null); } else { ExprNodeSummaryVisitor visitor = new ExprNodeSummaryVisitor(); maxExpr.accept(visitor); if (!visitor.isPlain()) { String errorMessage = "Invalid maximum expression in followed-by, " + visitor.getMessage() + " are not allowed within the expression"; log.error(errorMessage); throw new ExprValidationException(errorMessage); } ExprNode validatedExpr = ExprNodeUtility.getValidatedSubtree(maxExpr, validationContext); validated.add(validatedExpr); if ((validatedExpr.getExprEvaluator().getType() == null) || (!JavaClassHelper.isNumeric(validatedExpr.getExprEvaluator().getType()))) { String message = "Invalid maximum expression in followed-by, the expression must return an integer value"; throw new ExprValidationException(message); } } } followedByNode.setOptionalMaxExpressions(validated); } } if (newTaggedEventTypes != null) { tags.getTaggedEventTypes().putAll(newTaggedEventTypes); } if (newArrayEventTypes != null) { tags.getArrayEventTypes().putAll(newArrayEventTypes); } }
From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.SimpleParameterSensitivity.java
/** * Create a copy of the sensitivity and add a given sensitivity to it. * @param other The sensitivity to add.//from w w w . j a v a 2 s.c o m * @return The total sensitivity. */ public SimpleParameterSensitivity plus(final SimpleParameterSensitivity other) { ArgumentChecker.notNull(other, "Sensitivity to add"); final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA; final LinkedHashMap<String, DoubleMatrix1D> result = new LinkedHashMap<>(); result.putAll(_sensitivity); for (final Map.Entry<String, DoubleMatrix1D> entry : other.getSensitivities().entrySet()) { final String name = entry.getKey(); if (result.containsKey(name)) { result.put(name, (DoubleMatrix1D) algebra.add(result.get(name), entry.getValue())); } else { result.put(name, entry.getValue()); } } return new SimpleParameterSensitivity(result); }
From source file:net.sourceforge.jabm.report.CombiSeriesReportVariables.java
@Override public Map<Object, Number> getVariableBindings() { LinkedHashMap<Object, Number> result = new LinkedHashMap<Object, Number>(); for (Timeseries series : seriesList) { result.putAll(series.getVariableBindings()); }//from w w w .j av a 2s.co m return result; }
From source file:org.elasticsearch.storm.EsBolt.java
@Override public void prepare(Map conf, TopologyContext context, OutputCollector collector) { this.collector = collector; LinkedHashMap copy = new LinkedHashMap(conf); copy.putAll(boltConfig); StormSettings settings = new StormSettings(copy); flushOnTickTuple = settings.getStormTickTupleFlush(); ackWrites = settings.getStormBoltAck(); // trigger manual flush if (ackWrites) { settings.setProperty(ES_BATCH_FLUSH_MANUAL, Boolean.TRUE.toString()); // align Bolt / es-hadoop batch settings numberOfEntries = settings.getStormBulkSize(); settings.setProperty(ES_BATCH_SIZE_ENTRIES, String.valueOf(numberOfEntries)); inflightTuples = new ArrayList<Tuple>(numberOfEntries + 1); }/* www .jav a 2 s. c om*/ int totalTasks = context.getComponentTasks(context.getThisComponentId()).size(); InitializationUtils.setValueWriterIfNotSet(settings, StormValueWriter.class, log); InitializationUtils.setBytesConverterIfNeeded(settings, StormTupleBytesConverter.class, log); InitializationUtils.setFieldExtractorIfNotSet(settings, StormTupleFieldExtractor.class, log); writer = RestService.createWriter(settings, context.getThisTaskIndex(), totalTasks, log); }
From source file:com.kixeye.chassis.support.eureka.MetadataCollector.java
/*** * Get combined static and dynamic metadata * * @return Map of all metadata/*from w w w.j a va2 s . co m*/ */ public Map<String, String> getMetadataMap() { Map<String, String> dynamic = getDynamicMetadataMap(); if (dynamic == null) { return getStaticMetadataMap(); } LinkedHashMap<String, String> metadata = new LinkedHashMap<>(getStaticMetadataMap()); metadata.putAll(dynamic); return metadata; }
From source file:com.zenesis.qx.remote.SimpleQueue.java
@Override public synchronized void queueCommand(CommandType type, Object object, String propertyName, Object data) { if (type == CommandType.BOOTSTRAP && !values.isEmpty()) { LinkedHashMap<CommandId, Object> tmp = new LinkedHashMap<CommandId, Object>(); tmp.put(new CommandId(type, object, propertyName), data); tmp.putAll(values); values = tmp;//from ww w.j a va2 s .c o m } else values.put(new CommandId(type, object, propertyName), data); }