Java Code Examples for java.util.EnumMap#putAll()
The following examples show how to use
java.util.EnumMap#putAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FeatureDiscovery.java From desktopclient-java with GNU General Public License v3.0 | 5 votes |
private EnumMap<Feature, JID> discover(JID entity, boolean withItems) { // NOTE: smack automatically creates instances of SDM and CapsM and connects them ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(mConn); // 1. get features from server EnumMap<Feature, JID> features = discover(discoManager, entity); if (features == null) return new EnumMap<>(FeatureDiscovery.Feature.class); if (!withItems) return features; // 2. get server items DiscoverItems items; try { items = discoManager.discoverItems(entity.toBareSmack()); } catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException ex) { LOGGER.log(Level.WARNING, "can't get service discovery items", ex); return features; } // 3. get features from server items for (DiscoverItems.Item item: items.getItems()) { EnumMap<Feature, JID> itemFeatures = discover(discoManager, JID.fromSmack(item.getEntityID())); if (itemFeatures != null) features.putAll(itemFeatures); } LOGGER.info("supported server features: "+features); return features; }
Example 2
Source File: AggregatedSpawnMetrics.java From bazel with Apache License 2.0 | 5 votes |
/** * Returns a new {@link AggregatedSpawnMetrics} that incorporates the provided metrics by summing * them with the existing ones (if any). */ public AggregatedSpawnMetrics sumAllMetrics(SpawnMetrics other) { SpawnMetrics existing = getMetrics(other.execKind()); SpawnMetrics.Builder builder = SpawnMetrics.Builder.forExec(other.execKind()) .addDurations(existing) .addDurations(other) .addNonDurations(existing) .addNonDurations(other); EnumMap<SpawnMetrics.ExecKind, SpawnMetrics> map = new EnumMap<>(SpawnMetrics.ExecKind.class); map.putAll(metricsMap); map.put(other.execKind(), builder.build()); return new AggregatedSpawnMetrics(Maps.immutableEnumMap(map)); }
Example 3
Source File: AggregatedSpawnMetrics.java From bazel with Apache License 2.0 | 5 votes |
/** * Returns a new {@link AggregatedSpawnMetrics} that incorporates the provided metrics by summing * the duration ones and taking the maximum for the non-duration ones. */ public AggregatedSpawnMetrics sumDurationsMaxOther(SpawnMetrics other) { SpawnMetrics existing = getMetrics(other.execKind()); SpawnMetrics.Builder builder = SpawnMetrics.Builder.forExec(other.execKind()) .addDurations(existing) .addDurations(other) .maxNonDurations(existing) .maxNonDurations(other); EnumMap<SpawnMetrics.ExecKind, SpawnMetrics> map = new EnumMap<>(SpawnMetrics.ExecKind.class); map.putAll(metricsMap); map.put(other.execKind(), builder.build()); return new AggregatedSpawnMetrics(Maps.immutableEnumMap(map)); }
Example 4
Source File: HandlerListInjector.java From Bukkit-Connect with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") public static void prioritize(Plugin plugin, Class<? extends Event> event) throws Exception { HandlerList handlerList = ReflectionUtils.getPrivateField(event, null, HandlerList.class, "handlers"); HandlerListInjector injector = new HandlerListInjector(plugin); // move the handlerslots EnumMap<EventPriority, ArrayList<RegisteredListener>> handlerListHandlerSlots = ReflectionUtils.getPrivateField(HandlerList.class, handlerList, EnumMap.class, "handlerslots"); EnumMap<EventPriority, ArrayList<RegisteredListener>> injectorHandlerSlots = ReflectionUtils.getPrivateField(HandlerList.class, injector, EnumMap.class, "handlerslots"); injectorHandlerSlots.putAll(handlerListHandlerSlots); // remove old from allLists ArrayList<HandlerList> allLists = ReflectionUtils.getPrivateField(HandlerList.class, null, ArrayList.class, "allLists"); allLists.remove(handlerList); // replace event handlers ReflectionUtils.setFinalField(event, null, "handlers", injector); }
Example 5
Source File: FetchVector.java From vespa with Apache License 2.0 | 4 votes |
private FetchVector makeFetchVector(Consumer<EnumMap<Dimension, String>> mapModifier) { EnumMap<Dimension, String> mergedMap = new EnumMap<>(Dimension.class); mergedMap.putAll(map); mapModifier.accept(mergedMap); return new FetchVector(mergedMap); }
Example 6
Source File: SerializerH3EnumMap.java From baratine with GNU General Public License v2.0 | 3 votes |
@Override public T readObject(InRawH3 is, InH3Amp in) { Class type = in.readObject(Class.class); Map map = (Map) in.readObject(); EnumMap enumMap = new EnumMap(type); enumMap.putAll(map); return (T) enumMap; }