List of usage examples for com.google.common.collect Maps newLinkedHashMap
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap()
From source file:com.google.gerrit.server.edit.ChangeEditJson.java
private Map<String, FetchInfo> fillFetchMap(ChangeEdit edit) { Map<String, FetchInfo> r = Maps.newLinkedHashMap(); for (DynamicMap.Entry<DownloadScheme> e : downloadSchemes) { String schemeName = e.getExportName(); DownloadScheme scheme = e.getProvider().get(); if (!scheme.isEnabled() || (scheme.isAuthRequired() && !userProvider.get().isIdentifiedUser())) { continue; }/*from w w w . j av a 2s . co m*/ // No fluff, just stuff if (!scheme.isAuthSupported()) { continue; } String projectName = edit.getChange().getProject().get(); String refName = edit.getRefName(); FetchInfo fetchInfo = new FetchInfo(scheme.getUrl(projectName), refName); r.put(schemeName, fetchInfo); ChangeJson.populateFetchMap(scheme, downloadCommands, projectName, refName, fetchInfo); } return r; }
From source file:org.smartdeveloperhub.harvesters.it.notification.CollectorAggregator.java
private CollectorAggregator(final String name, final NotificationListener listener) { this.name = name; this.listener = listener; this.brokerCollectors = LinkedListMultimap.create(); this.brokerInstances = LinkedListMultimap.create(); this.instanceBroker = Maps.newLinkedHashMap(); this.brokerController = Maps.newLinkedHashMap(); this.notificationQueue = new LinkedBlockingQueue<>(); this.connectedControllers = Lists.newLinkedList(); }
From source file:brooklyn.policy.basic.AdjunctType.java
/** * Finds the config keys defined on the entity's class, statics and optionally any non-static (discouraged). *///from w ww .jav a 2 s . co m // TODO Remove duplication from EntityDynamicType protected static Map<String, ConfigKey<?>> findConfigKeys(Class<? extends EntityAdjunct> clazz, EntityAdjunct optionalInstance) { try { Map<String, ConfigKey<?>> result = Maps.newLinkedHashMap(); Map<String, Field> configFields = Maps.newLinkedHashMap(); for (Field f : clazz.getFields()) { boolean isConfigKey = ConfigKey.class.isAssignableFrom(f.getType()); if (!isConfigKey) { if (!HasConfigKey.class.isAssignableFrom(f.getType())) { // neither ConfigKey nor HasConfigKey continue; } } if (!Modifier.isStatic(f.getModifiers())) { // require it to be static or we have an instance LOG.warn("Discouraged use of non-static config key " + f + " defined in " + (optionalInstance != null ? optionalInstance : clazz)); if (optionalInstance == null) continue; } ConfigKey<?> k = isConfigKey ? (ConfigKey<?>) f.get(optionalInstance) : ((HasConfigKey<?>) f.get(optionalInstance)).getConfigKey(); Field alternativeField = configFields.get(k.getName()); // Allow overriding config keys (e.g. to set default values) when there is an assignable-from relationship between classes Field definitiveField = alternativeField != null ? inferSubbestField(alternativeField, f) : f; boolean skip = false; if (definitiveField != f) { // If they refer to the _same_ instance, just keep the one we already have if (alternativeField.get(optionalInstance) == f.get(optionalInstance)) skip = true; } if (skip) { //nothing } else if (definitiveField == f) { result.put(k.getName(), k); configFields.put(k.getName(), f); } else if (definitiveField != null) { if (LOG.isDebugEnabled()) LOG.debug( "multiple definitions for config key {} on {}; preferring that in sub-class: {} to {}", new Object[] { k.getName(), optionalInstance != null ? optionalInstance : clazz, alternativeField, f }); } else if (definitiveField == null) { LOG.warn("multiple definitions for config key {} on {}; preferring {} to {}", new Object[] { k.getName(), optionalInstance != null ? optionalInstance : clazz, alternativeField, f }); } } return result; } catch (IllegalAccessException e) { throw Throwables.propagate(e); } }
From source file:com.google.api.tools.framework.processors.resolver.SymbolTableBuilder.java
@VisitsBefore void visit(Interface endpointInterface) { // Add the interface to the map of known interfaces. Interface old = interfaces.put(endpointInterface.getFullName(), endpointInterface); if (old != null) { model.getDiagCollector()//from ww w.j ava 2 s. co m .addDiag(Diag.error(endpointInterface.getLocation(), "Duplicate declaration of interface '%s'. Previous location: %s", endpointInterface.getFullName(), old.getLocation().getDisplayString())); } // Build the method-by-name map for this interface, and register the method simple name in the // method name map. Map<String, Method> methodByName = Maps.newLinkedHashMap(); for (Method method : endpointInterface.getMethods()) { Method oldMethod = methodByName.put(method.getSimpleName(), method); if (oldMethod != null) { model.getDiagCollector() .addDiag(Diag.error(method.getLocation(), "Duplicate declaration of method '%s'. Previous location: %s", method.getSimpleName(), oldMethod.getLocation().getDisplayString())); } List<Method> allMethodsOfName = methods.get(method.getSimpleName()); if (allMethodsOfName == null) { methods.put(method.getSimpleName(), Lists.newArrayList(method)); } else { allMethodsOfName.add(method); } } endpointInterface.setMethodByNameMap(ImmutableMap.copyOf(methodByName)); }
From source file:org.datavyu.controllers.component.TracksEditorController.java
/** * Create a new tracks editor controller. *//*from w w w . j av a 2 s .c om*/ public TracksEditorController(final MixerController mixerController, final MixerModel mixerModel) { tracks = Maps.newLinkedHashMap(); this.mixerController = mixerController; this.mixerModel = mixerModel; snapMarkerController = new SnapMarkerController(mixerModel); selectionHandler = new CarriageSelection(); initView(); }
From source file:io.atomix.core.tree.impl.DefaultAtomicDocumentTree.java
@Override public Map<String, Versioned<V>> getChildren(DocumentPath path) { DocumentTreeNode<V> node = getNode(path); if (node != null) { Map<String, Versioned<V>> childrenValues = Maps.newLinkedHashMap(); node.children().forEachRemaining(n -> childrenValues.put(simpleName(n.path()), n.value())); return childrenValues; }// w w w. j a v a2 s. c o m throw new NoSuchDocumentPathException(); }
From source file:com.threewks.thundr.elasticsearch.gae.repository.ElasticSearchRepository.java
public void save(List<E> entities) { Map<String, Object> documents = Maps.newLinkedHashMap(); for (E entity : entities) { documents.put(entity.getId(), entity); }//from ww w . java 2 s . c o m Action action = new BulkIndex.Builder().index(index).type(typeName).documents(documents).build(); client.execute(action); }
From source file:org.apache.brooklyn.policy.loadbalancing.MockContainerEntityImpl.java
@Override public Map<Entity, Double> getItemUsage() { Map<Entity, Double> result = Maps.newLinkedHashMap(); for (Entity member : getMembers()) { Map<Entity, Double> memberItemUsage = member.getAttribute(MockItemEntity.ITEM_USAGE_METRIC); if (memberItemUsage != null) { for (Map.Entry<Entity, Double> entry : memberItemUsage.entrySet()) { double val = (result.containsKey(entry.getKey()) ? result.get(entry.getKey()) : 0d); val += ((entry.getValue() != null) ? entry.getValue() : 0); result.put(entry.getKey(), val); }//from ww w . j a v a 2 s . c om } } return result; }
From source file:com.isotrol.impe3.core.engine.PageInstance.java
public <R extends ComponentRenderer> Map<UUID, R> getRenderers(final Class<R> rendererType, final Function<CIP, RenderContext> contextFactory) { final Map<UUID, R> map = Maps.newLinkedHashMap(); for (CIP cip : getPage().getOrder()) { final UUID cipId = cip.getId(); final Component c = components.get(cipId); final RenderContext context = contextFactory.apply(cip); final R renderer = cip.getRenderer(rendererType, c, context); if (renderer != null) { map.put(cipId, renderer);/*from ww w .j a v a 2s . co m*/ } } return map; }
From source file:brooklyn.location.waratek.WaratekLocation.java
public WaratekLocation() { this(Maps.newLinkedHashMap()); }