微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

com.google.common.collect.SetMultimap的实例源码

项目:raml-java-tools    文件PluginManager.java   
public static PluginManager createPluginManager(String pluginFileName) {

    try {
      SetMultimap<String,Class<?>> info = LinkedHashMultimap.create();
      Enumeration<URL> resourcesFiles = PluginManager.class.getClassLoader().getResources(pluginFileName);

      while (resourcesFiles.hasMoreElements()) {
        URL url = resourcesFiles.nextElement();
        Properties properties = new Properties();
        loadProperties(url,properties);
        buildpluginNames(info,properties);
      }

      return new PluginManager(info);

    } catch (IOException e) {

      throw new GenerationException(e);
    }

  }
项目:guava-mock    文件SetMultimapEqualsTester.java   
@CollectionSize.Require(SEVERAL)
public void testOrderingDoesntAffectEqualsComparisons() {
  SetMultimap<K,V> multimap1 =
      getSubjectGenerator()
          .create(
              Helpers.mapEntry(k0(),v0()),Helpers.mapEntry(k0(),v1()),v4()));
  SetMultimap<K,V> multimap2 =
      getSubjectGenerator()
          .create(
              Helpers.mapEntry(k0(),v4()));
  new EqualsTester().addEqualityGroup(multimap1,multimap2).testEquals();
}
项目:guava-mock    文件SetMultimapTestSuiteBuilder.java   
@Override
TestSuite computeMultimapAsMapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?,? extends OnesizeTestContainerGenerator<SetMultimap<K,V>,Entry<K,V>>>
        parentBuilder) {
  Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures());
  if (Collections.@R_502_6422@joint(features,EnumSet.allOf(CollectionSize.class))) {
    return new TestSuite();
  } else {
    return SetTestSuiteBuilder.using(
            new MultimapAsMapGetGenerator<K,V>(parentBuilder.getSubjectGenerator()))
        .withFeatures(features)
        .named(parentBuilder.getName() + ".asMap[].get[key]")
        .suppressing(parentBuilder.getSuppressedTests())
        .createTestSuite();
  }
}
项目:guava-mock    文件SortedSetMultimapTestSuiteBuilder.java   
@Override
TestSuite computeMultimapAsMapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?,EnumSet.allOf(CollectionSize.class))) {
    return new TestSuite();
  } else {
    return SortedSetTestSuiteBuilder.using(
            new SetMultimapTestSuiteBuilder.MultimapAsMapGetGenerator<K,V>(
                parentBuilder.getSubjectGenerator()))
        .withFeatures(features)
        .named(parentBuilder.getName() + ".asMap[].get[key]")
        .suppressing(parentBuilder.getSuppressedTests())
        .createTestSuite();
  }
}
项目:ProjectAres    文件@R_502_6422@abledamageModule.java   
public static @R_502_6422@abledamageModule parse(MapModuleContext context,Logger logger,Document doc) throws InvalidXMLException {
    SetMultimap<damageCause,PlayerRelation> causes = HashMultimap.create();
    for(Element damageCauseElement : doc.getRootElement().getChildren("@R_502_6422@abledamage")) {
        for(Element damageEl : damageCauseElement.getChildren("damage")) {
            damageCause cause = XMLUtils.parseEnum(damageEl,damageCause.class,"damage type");
            for(PlayerRelation damagerType : PlayerRelation.values()) {
                // Legacy Syntax used "other" instead of "neutral"
                String attrName = damagerType.name().toLowerCase();
                Node attr = damagerType == PlayerRelation.NEUTRAL ? Node.fromAttr(damageEl,attrName,"other")
                                                                  : Node.fromAttr(damageEl,attrName);
                if(XMLUtils.parseBoolean(attr,true)) {
                    causes.put(cause,damagerType);

                    // Bukkit 1.7.10 changed TNT from BLOCK_EXPLOSION to ENTITY_EXPLOSION,// so we include them both to keep old maps working.
                    if(cause == damageCause.BLOCK_EXPLOSION) {
                        causes.put(damageCause.ENTITY_EXPLOSION,damagerType);
                    }
                }
            }
        }
    }
    return new @R_502_6422@abledamageModule(causes);
}
项目:ProjectAres    文件TargetedEventBusImpl.java   
@Inject TargetedEventBusImpl(ExceptionHandler exceptionHandler,EventRegistry eventRegistry,TargetedEventHandlerScanner eventHandlerScanner,TypeMap<Object,TargetedEventRouter<?>> routers) {
    this.exceptionHandler = exceptionHandler;
    this.eventRegistry = eventRegistry;
    this.routers = routers;

    // Cache of handler methods per listener type
    this.listenerCache = CacheUtils.newCache(listener -> {
        final SetMultimap<EventKey<? extends Event>,EventHandlerInfo<? extends Event>> handlers = eventHandlerScanner.findEventHandlers(listener);
        for(EventHandlerInfo<? extends Event> info : handlers.values()) {
            if(this.routers.allAssignableFrom(info.event()).isEmpty()) {
                throw new InvalidMemberException(
                    info.method(),"No router registered for targeted event type " + info.event().getName()
                );
            }
        }
        return handlers;
    });
}
项目:flume-release-1.7.0    文件TestFlumeEventQueue.java   
@Test
public void testInflightPuts() throws Exception {
  queue = new FlumeEventQueue(backingStore,backingStoresupplier.getInflightTakes(),backingStoresupplier.getInflightPuts(),backingStoresupplier.getQueueSetDir());
  long txnID1 = new Random().nextInt(Integer.MAX_VALUE - 1);
  long txnID2 = txnID1 + 1;
  queue.addWithoutCommit(new FlumeEventPointer(1,1),txnID1);
  queue.addWithoutCommit(new FlumeEventPointer(2,2),txnID2);
  queue.checkpoint(true);
  TimeUnit.SECONDS.sleep(3L);
  queue = new FlumeEventQueue(backingStore,backingStoresupplier.getQueueSetDir());
  SetMultimap<Long,Long> deserializedMap = queue.deserializeInflightPuts();
  Assert.assertTrue(deserializedMap.get(txnID1).contains(new FlumeEventPointer(1,1).toLong()));
  Assert.assertTrue(deserializedMap.get(txnID1).contains(new FlumeEventPointer(2,1).toLong()));
  Assert.assertTrue(deserializedMap.get(txnID2).contains(new FlumeEventPointer(2,2).toLong()));
}
项目:Equella    文件AbstractIntegrationService.java   
private SetMultimap<String,IntegrationSessionExtension> getExtensionMap()
{
    if( extensionMap == null )
    {
        synchronized( this )
        {
            if( extensionMap == null )
            {
                final SetMultimap<String,IntegrationSessionExtension> map = HashMultimap
                    .<String,IntegrationSessionExtension>create();
                for( Extension ext : resultsTracker.getExtensions() )
                {
                    final IntegrationSessionExtension integExtension = resultsTracker.getBeanByExtension(ext);
                    for( Parameter parameter : ext.getParameters("type") )
                    {
                        map.put(parameter.valueAsstring(),integExtension);
                    }
                }
                extensionMap = Multimaps.unmodifiableSetMultimap(map);
            }
        }
    }
    return extensionMap;
}
项目:OperatieBRP    文件LeveringsAutorisatieCacheHelperImpl.java   
private void toevoegenAttributenAanDienstbundelGroepen(final List<DienstbundelGroep> alleDienstBundelgroepen,final Map<Integer,Dienstbundel> dienstbundelIdMap,final SetMultimap<Integer,DienstbundelGroepAttribuut> dbGrAttrBijDbGroep) {
    for (final DienstbundelGroep dienstbundelGroep : alleDienstBundelgroepen) {
        final Dienstbundel dienstbundel = dienstbundelIdMap.get(dienstbundelGroep.getDienstbundel().getId());
        if (dienstbundel != null) {
            dienstbundelGroep.setDienstbundel(dienstbundel);
        }
        final Set<DienstbundelGroepAttribuut> dienstbundelGroepAttribuutSet = dbGrAttrBijDbGroep.get(dienstbundelGroep.getId());
        if (dienstbundelGroepAttribuutSet != null) {
            dienstbundelGroep.setDienstbundelGroepAttribuutSet(dienstbundelGroepAttribuutSet);
        } else {
            dienstbundelGroep.setDienstbundelGroepAttribuutSet(Collections.emptySet());
        }
    }
}
项目:OperatieBRP    文件LeveringsAutorisatieCacheHelperImpl.java   
private void toevoegenSetsAanDienstbundels(final List<Dienstbundel> alleDienstBundels,DienstbundelGroep> dienstbundelGroepenBijdienstbundelMap,DienstbundelLo3Rubriek> dienstbundelLo3RubriekenBijdienstbundelMap,Dienst> dienstenBijdienstbundelMap) {
    for (final Dienstbundel dienstbundel : alleDienstBundels) {
        final Set<DienstbundelGroep> dienstbundelGroepSet = dienstbundelGroepenBijdienstbundelMap.get(dienstbundel.getId());
        final Set<DienstbundelLo3Rubriek> dienstbundelLo3RubriekSet = dienstbundelLo3RubriekenBijdienstbundelMap.get(dienstbundel.getId());
        if (dienstbundelGroepSet != null) {
            dienstbundel.setDienstbundelGroepSet(dienstbundelGroepSet);
            dienstbundel.setDienstbundelLo3RubriekSet(dienstbundelLo3RubriekSet);
            dienstbundel.setDienstSet(dienstenBijdienstbundelMap.get(dienstbundel.getId()));
        } else {
            dienstbundel.setDienstbundelGroepSet(Collections.emptySet());
            dienstbundel.setDienstSet(Collections.emptySet());
        }
    }
}
项目:clearwsd    文件SemevalReader.java   
/**
 * Read Semeval keys file.
 *
 * @param path path to keys file
 * @return map from sense IDs onto senses
 */
private static SetMultimap<String,String> readKeys(String path) {
    try (BufferedReader reader = new BufferedReader(new FileReader(path))) {
        SetMultimap<String,String> keys = LinkedHashMultimap.create();
        String line;
        while ((line = reader.readLine()) != null) {
            if (line.isEmpty()) {
                continue;
            }
            String[] fields = line.split(" ");
            for (int i = 1; i < fields.length; ++i) {
                keys.put(fields[0],fields[i]);
            }
        }
        return keys;
    } catch (IOException e) {
        throw new RuntimeException("Error reading sense keys file",e);
    }
}
项目:OperatieBRP    文件AdmhndProducerVoorLeveringServiceImpl.java   
private Set<HandelingVoorPublicatie> filterHandelingen(final Set<Long> personenInLevering,final SetMultimap<Long,Long> admhndMap) {
    final Set<HandelingVoorPublicatie> teLeverenHandelingen = new HashSet<>();
    //loop over handelingen zonder status in Levering en bepaal unieke bijgehouden persoon sets
    for (Long admhnId : admhndMap.keySet()) {
        final Set<Long> bijgehoudenPersonen = admhndMap.get(admhnId);
        if (Collections.@R_502_6422@joint(bijgehoudenPersonen,personenInLevering)) {
            final HandelingVoorPublicatie handelingVoorPublicatie = new HandelingVoorPublicatie();
            handelingVoorPublicatie.setAdmhndId(admhnId);
            handelingVoorPublicatie.setBijgehoudenPersonen(bijgehoudenPersonen);
            teLeverenHandelingen.add(handelingVoorPublicatie);
            personenInLevering.addAll(bijgehoudenPersonen);
        } else {
            LOGGER.debug(String.format("admhnd %s voor persoon al in Levering,@R_502_6422@card voor nu. Worden later opgepakt",admhnId));
        }
    }
    return teLeverenHandelingen;
}
项目:CustomWorldGen    文件Loader.java   
private void identifyDuplicates(List<ModContainer> mods)
{
    TreeMultimap<ModContainer,File> dupsearch = TreeMultimap.create(new ModIdComparator(),Ordering.arbitrary());
    for (ModContainer mc : mods)
    {
        if (mc.getSource() != null)
        {
            dupsearch.put(mc,mc.getSource());
        }
    }

    ImmutableMultiset<ModContainer> duplist = Multisets.copyHighestCountFirst(dupsearch.keys());
    SetMultimap<ModContainer,File> dupes = LinkedHashMultimap.create();
    for (Entry<ModContainer> e : duplist.entrySet())
    {
        if (e.getCount() > 1)
        {
            FMLLog.severe("Found a duplicate mod %s at %s",e.getElement().getModId(),dupsearch.get(e.getElement()));
            dupes.putAll(e.getElement(),dupsearch.get(e.getElement()));
        }
    }
    if (!dupes.isEmpty())
    {
        throw new DuplicateModsFoundException(dupes);
    }
}
项目:athena    文件Vpls.java   
protected void setupConnectivity() {
    /*
     * Parse Configuration and get Connect Point by VlanId.
     */
    SetMultimap<VlanId,ConnectPoint> confCPointsByVlan = getConfigCPoints();

    /*
     * Check that configured Connect Points have hosts attached and
     * associate their Mac Address to the Connect Points configured.
     */
    SetMultimap<VlanId,Pair<ConnectPoint,MacAddress>> confHostPresentCPoint =
            pairAvailableHosts(confCPointsByVlan);

    /*
     * Create and submit intents between the Connect Points.
     * Intents for broadcast between all the configured Connect Points.
     * Intents for unicast between all the configured Connect Points with
     * hosts attached.
     */
    intentInstaller.installIntents(confHostPresentCPoint);
}
项目:athena    文件Vpls.java   
private void bindMacAddr(Map.Entry<VlanId,ConnectPoint> e,SetMultimap<VlanId,MacAddress>> confHostPresentCPoint) {
    VlanId vlanId = e.getKey();
    ConnectPoint cp = e.getValue();
    Set<Host> connectedHosts = hostService.getConnectedHosts(cp);
    if (!connectedHosts.isEmpty()) {
        connectedHosts.forEach(host -> {
            if (host.vlan().equals(vlanId)) {
                confHostPresentCPoint.put(vlanId,Pair.of(cp,host.mac()));
            } else {
                confHostPresentCPoint.put(vlanId,null));
            }
        });
    } else {
        confHostPresentCPoint.put(vlanId,null));
    }
}
项目:android-auto-mapper    文件MoreElements.java   
private static void getLocalAndInheritedMethods(
        PackageElement pkg,TypeElement type,SetMultimap<String,ExecutableElement> methods) {

    for (TypeMirror superInterface : type.getInterfaces()) {
        getLocalAndInheritedMethods(pkg,MoreTypes.asTypeElement(superInterface),methods);
    }
    if (type.getSuperclass().getKind() != TypeKind.NONE) {
        // Visit the superclass after superinterfaces so we will always see the implementation of a
        // method after any interfaces that declared it.
        getLocalAndInheritedMethods(pkg,MoreTypes.asTypeElement(type.getSuperclass()),methods);
    }
    for (ExecutableElement method : ElementFilter.methodsIn(type.getEnclosedElements())) {
        if (!method.getModifiers().contains(Modifier.STATIC)
                && methodVisibleFromPackage(method,pkg)) {
            methods.put(method.getSimpleName().toString(),method);
        }
    }
}
项目:abhot    文件SetMultimapDeserializer.java   
@Override
public SetMultimap<String,String> deserialize(JsonElement json,Type typeOfT,JsonDeserializationContext context) throws JsonParseException
{
    SetMultimap<String,String> map = HashMultimap.create();

    JsonObject filters = json.getAsJsonObject();
    for (Map.Entry<String,JsonElement> filter : filters.entrySet())
    {
        String name = filter.getKey();
        JsonArray values = ((JsonArray)filter.getValue());
        for (JsonElement value : values)
        {
            map.put(name,value.getAsstring());
        }
    }

    return map;
}
项目:abhot    文件QueryParser.java   
@Inject
public QueryParser(AggregatorFactory aggregatorFactory,GroupByFactory groupByFactory,QueryPluginFactory pluginFactory)
{
    m_aggregatorFactory = aggregatorFactory;
    m_groupByFactory = groupByFactory;
    m_pluginFactory = pluginFactory;

    m_descriptorMap = new HashMap<>();

    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapterFactory(new LowercaseEnumTypeAdapterFactory());
    builder.registerTypeAdapter(TimeUnit.class,new TimeUnitDeserializer());
    builder.registerTypeAdapter(DateTimeZone.class,new DateTimeZoneDeserializer());
    builder.registerTypeAdapter(Metric.class,new MetricDeserializer());
    builder.registerTypeAdapter(SetMultimap.class,new SetMultimapDeserializer());
    builder.registerTypeAdapter(RelativeTime.class,new RelativeTimeSerializer());
    builder.registerTypeAdapter(SetMultimap.class,new SetMultimapSerializer());
    builder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERscoreS);

    m_gson = builder.create();
}
项目:googles-monorepo-demo    文件SetMultimapEqualsTester.java   
@CollectionSize.Require(SEVERAL)
public void testOrderingDoesntAffectEqualsComparisons() {
  SetMultimap<K,multimap2).testEquals();
}
项目:googles-monorepo-demo    文件SetMultimapTestSuiteBuilder.java   
@Override
TestSuite computeMultimapAsMapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?,V>(parentBuilder.getSubjectGenerator()))
        .withFeatures(features)
        .named(parentBuilder.getName() + ".asMap[].get[key]")
        .suppressing(parentBuilder.getSuppressedTests())
        .createTestSuite();
  }
}
项目:Reer    文件ModuleMetadataSerializer.java   
private void writeDependencyConfigurationMapping(ivydependencyMetadata dep) throws IOException {
    SetMultimap<String,String> confMappings = dep.getConfMappings();
    writeCount(confMappings.keySet().size());
    for (String conf : confMappings.keySet()) {
        writeString(conf);
        writeStringSet(confMappings.get(conf));
    }
}
项目:Reer    文件ModuleMetadataSerializer.java   
private DependencyMetadata readDependency() throws IOException {
    ModuLeversionSelector requested = DefaultModuLeversionSelector.newSelector(readString(),readString(),readString());

    byte type = decoder.readByte();
    switch (type) {
        case TYPE_IVY:
            SetMultimap<String,String> configMappings = readDependencyConfigurationMapping();
            List<Artifact> artifacts = readDependencyArtifactDescriptors();
            List<Exclude> excludes = readExcludeRules();
            String dynamicConstraintVersion = readString();
            boolean force = readBoolean();
            boolean changing = readBoolean();
            boolean transitive = readBoolean();
            return new ivydependencyMetadata(requested,dynamicConstraintVersion,force,changing,transitive,configMappings,artifacts,excludes);
        case TYPE_MAVEN:
            artifacts = readDependencyArtifactDescriptors();
            excludes = readExcludeRules();
            MavenScope scope = MavenScope.values()[decoder.readSmallInt()];
            boolean optional = decoder.readBoolean();
            return new MavendependencyMetadata(scope,optional,requested,excludes);
        default:
            throw new IllegalArgumentException("Unexpected dependency type found.");
    }
}
项目:Reer    文件ModuleMetadataSerializer.java   
private SetMultimap<String,String> readDependencyConfigurationMapping() throws IOException {
    int size = readCount();
    SetMultimap<String,String> result = LinkedHashMultimap.create();
    for (int i = 0; i < size; i++) {
        String from = readString();
        Set<String> to = readStringSet();
        result.putAll(from,to);
    }
    return result;
}
项目:googles-monorepo-demo    文件SortedSetMultimapTestSuiteBuilder.java   
@Override
TestSuite computeMultimapAsMapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?,V>(
                parentBuilder.getSubjectGenerator()))
        .withFeatures(features)
        .named(parentBuilder.getName() + ".asMap[].get[key]")
        .suppressing(parentBuilder.getSuppressedTests())
        .createTestSuite();
  }
}
项目:raml-java-tools    文件PluginManager.java   
private static void buildpluginNames(SetMultimap<String,Class<?>> info,Properties properties) {

    for (String name : properties.stringPropertyNames()) {

      List<Class<?>> classList = classList(name,properties.getProperty(name));
      if (info.containsKey(name)) {

        throw new GenerationException("duplicate name in plugins: " + name);
      }
      info.putAll(name,classList);
    }
  }
项目:AdvancedDataProfilingSeminar    文件CoordinatesRepository.java   
public void storeUindCoordinates() throws AlgorithmExecutionException {
    ImmutableMap<ColumnIdentifier,TableInputGenerator> attributes =
            getRelationalInputMap(config.getInputGenerators());
    for (InclusionDependency uind : config.getUnaryInds()) {
        SetMultimap<Integer,Integer> uindCoordinates = generateCoordinates(uind,attributes);
        Path path = getPath();
        try {
            writetoFile(uind,uindCoordinates,path);
            uindToPath.put(uind,path);
        } catch (IOException e) {
            throw new AlgorithmExecutionException(
                    format("Error writing uind coordinates for uind %s to file %s",uind,path),e);
        }
    }
}
项目:googles-monorepo-demo    文件SortedSetMultimapTestSuiteBuilder.java   
@Override
TestSuite computeMultimapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?,V>>>
        parentBuilder) {
  return SortedSetTestSuiteBuilder.using(
          new SetMultimapTestSuiteBuilder.MultimapGetGenerator<K,V>(
              parentBuilder.getSubjectGenerator()))
      .withFeatures(computeMultimapGetFeatures(parentBuilder.getFeatures()))
      .named(parentBuilder.getName() + ".get[key]")
      .suppressing(parentBuilder.getSuppressedTests())
      .createTestSuite();
}
项目:guava-mock    文件SetMultimapTestSuiteBuilder.java   
@Override
TestSuite computeMultimapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?,V>>>
        parentBuilder) {
  return SetTestSuiteBuilder.using(
          new MultimapGetGenerator<K,V>(parentBuilder.getSubjectGenerator()))
      .withFeatures(computeMultimapGetFeatures(parentBuilder.getFeatures()))
      .named(parentBuilder.getName() + ".get[key]")
      .suppressing(parentBuilder.getSuppressedTests())
      .createTestSuite();
}
项目:guava-mock    文件SetMultimapTestSuiteBuilder.java   
@Override
TestSuite computeEntriesTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?,Map.Entry<K,V>>>
        parentBuilder) {
  return SetTestSuiteBuilder.using(
          new EntriesGenerator<K,V>(parentBuilder.getSubjectGenerator()))
      .withFeatures(computeEntriesFeatures(parentBuilder.getFeatures()))
      .named(parentBuilder.getName() + ".entries")
      .suppressing(parentBuilder.getSuppressedTests())
      .createTestSuite();
}
项目:guava-mock    文件SortedSetMultimapTestSuiteBuilder.java   
@Override
TestSuite computeMultimapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?,V>(
              parentBuilder.getSubjectGenerator()))
      .withFeatures(computeMultimapGetFeatures(parentBuilder.getFeatures()))
      .named(parentBuilder.getName() + ".get[key]")
      .suppressing(parentBuilder.getSuppressedTests())
      .createTestSuite();
}
项目:guava-mock    文件TestStringSetMultimapGenerator.java   
@Override
public final SetMultimap<String,String> create(Object... entries) {
  @SuppressWarnings("unchecked")
  Entry<String,String>[] array = new Entry[entries.length];
  int i = 0;
  for (Object o : entries) {
    @SuppressWarnings("unchecked")
    Entry<String,String> e = (Entry<String,String>) o;
    array[i++] = e;
  }
  return create(array);
}
项目:CustomWorldGen    文件ASMDataTable.java   
public SetMultimap<String,ASMData> getAnnotationsFor(ModContainer container)
{
    if (containerAnnotationData == null)
    {
        ImmutableMap.Builder<ModContainer,ASMData>> mapBuilder = ImmutableMap.builder();
        for (ModContainer cont : containers)
        {
            Multimap<String,ASMData> values = Multimaps.filterValues(globalAnnotationData,new ModContainerPredicate(cont));
            mapBuilder.put(cont,ImmutableSetMultimap.copyOf(values));
        }
        containerAnnotationData = mapBuilder.build();
    }
    return containerAnnotationData.get(container);
}
项目:ProjectAres    文件ImmutableTypeMap.java   
public static <K,V> ImmutableTypeMap<K,V> copyOf(TypeMap<? extends K,? extends V> that) {
    if(that instanceof ImmutableTypeMap) {
        return (ImmutableTypeMap<K,V>) that;
    } else {
        return copyOf((SetMultimap) that);
    }
}
项目:flume-release-1.7.0    文件FlumeEventQueue.java   
/**
 * Read the inflights file and return a
 * {@link com.google.common.collect.SetMultimap}
 * of transactionIDs to events that were inflight.
 *
 * @return - map of inflight events per txnID.
 */
public SetMultimap<Long,Long> deserialize()
    throws IOException,BadCheckpointException {
  SetMultimap<Long,Long> inflights = HashMultimap.create();
  if (!fileChannel.isopen()) {
    file = new RandomAccessFile(inflightEventsFile,"rw");
    fileChannel = file.getChannel();
  }
  if (file.length() == 0) {
    return inflights;
  }
  file.seek(0);
  byte[] checksum = new byte[16];
  file.read(checksum);
  ByteBuffer buffer = ByteBuffer.allocate(
      (int) (file.length() - file.getFilePointer()));
  fileChannel.read(buffer);
  byte[] fileChecksum = digest.digest(buffer.array());
  if (!Arrays.equals(checksum,fileChecksum)) {
    throw new BadCheckpointException("Checksum of inflights file differs"
        + " from the checksum expected.");
  }
  buffer.position(0);
  LongBuffer longBuffer = buffer.asLongBuffer();
  try {
    while (true) {
      long txnID = longBuffer.get();
      int numEvents = (int) (longBuffer.get());
      for (int i = 0; i < numEvents; i++) {
        long val = longBuffer.get();
        inflights.put(txnID,val);
      }
    }
  } catch (BufferUnderflowException ex) {
    LOG.debug("Reached end of inflights buffer. Long buffer position ="
        + String.valueOf(longBuffer.position()));
  }
  return inflights;
}
项目:flume-release-1.7.0    文件TestFlumeEventQueue.java   
@Test
public void testInflightTakes() throws Exception {
  queue = new FlumeEventQueue(backingStore,backingStoresupplier.getQueueSetDir());
  long txnID1 = new Random().nextInt(Integer.MAX_VALUE - 1);
  long txnID2 = txnID1 + 1;
  queue.addTail(new FlumeEventPointer(1,1));
  queue.addTail(new FlumeEventPointer(2,2));
  queue.removeHead(txnID1);
  queue.removeHead(txnID2);
  queue.removeHead(txnID2);
  queue.checkpoint(true);
  TimeUnit.SECONDS.sleep(3L);
  queue = new FlumeEventQueue(backingStore,Long> deserializedMap = queue.deserializeInflightTakes();
  Assert.assertTrue(deserializedMap.get(
          txnID1).contains(new FlumeEventPointer(1,1).toLong()));
  Assert.assertTrue(deserializedMap.get(
          txnID2).contains(new FlumeEventPointer(2,2).toLong()));

}
项目:Equella    文件AbstractIntegrationService.java   
protected Set<IntegrationSessionExtension> getExtensions()
{
    final SetMultimap<String,IntegrationSessionExtension> map = getExtensionMap();
    final Set<IntegrationSessionExtension> typeExtensions = Sets.newHashSet(map.get(getIntegrationType()));
    typeExtensions.addAll(map.get(ALL_TYPES_KEY));
    return typeExtensions;
}
项目:OperatieBRP    文件LeveringsAutorisatieCacheHelperImpl.java   
private void toevoegenDienstbundelsAanLevAutorisaties(final Map<Integer,Leveringsautorisatie> LeveringsAutorisatieMap,Dienstbundel> dienstbundelMap) {
    for (Leveringsautorisatie Leveringsautorisatie : LeveringsAutorisatieMap.values()) {
        final Set<Dienstbundel> dienstbundelSet = dienstbundelMap.get(Leveringsautorisatie.getId());
        if (dienstbundelSet != null) {
            Leveringsautorisatie.setDienstbundelSet(dienstbundelSet);
        } else {
            Leveringsautorisatie.setDienstbundelSet(Collections.emptySet());
        }
    }
}
项目:OperatieBRP    文件LeveringsAutorisatieCacheHelperImpl.java   
private SetMultimap<Integer,Dienstbundel> maakLeveringautorisatieDienstbundelMapping(final List<Dienstbundel> alleDienstBundels) {
    final SetMultimap<Integer,Dienstbundel> map = HashMultimap.create();
    for (final Dienstbundel dienstbundel : alleDienstBundels) {
        map.put(dienstbundel.getLeveringsautorisatie().getId(),dienstbundel);
    }
    return map;
}
项目:OperatieBRP    文件LeveringsAutorisatieCacheHelperImpl.java   
private SetMultimap<Integer,Dienst> maakDienstMapping(final List<Dienst> alleDiensten) {
    final SetMultimap<Integer,Dienst> map = HashMultimap.create();
    for (final Dienst dienst : alleDiensten) {
        map.put(dienst.getDienstbundel().getId(),dienst);
    }
    return map;

}
项目:OperatieBRP    文件LeveringsAutorisatieCacheHelperImpl.java   
private SetMultimap<Integer,DienstbundelGroep> maakDienstbundelgroepDienstbundelMapping(final List<DienstbundelGroep> alleDienstBundelgroepen) {
    final SetMultimap<Integer,DienstbundelGroep> map = HashMultimap.create();
    for (final DienstbundelGroep dienstbundelGroep : alleDienstBundelgroepen) {
        map.put(dienstbundelGroep.getDienstbundel().getId(),dienstbundelGroep);
    }
    return map;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。