Java Code Examples for com.google.common.collect.Multimap.put()

The following are Jave code examples for showing how to use put() of the com.google.common.collect.Multimap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: n4js   File: ProjectLocationAwareWorkingSetManager.java   Source Code and License Vote up 6 votes
private Multimap<String, IProject> initProjectLocation() {
	final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	final IProject[] projects = root.getProjects();
	final Multimap<String, IProject> locations = HashMultimap.create();

	// initialize the repository paths
	repositoryPaths = repositoriesProvider.getWorkspaceRepositories().stream()
			.map(r -> r.getDirectory().getParentFile().toPath()).collect(Collectors.toSet());

	for (final IProject project : projects) {
		if (isRemoteEditNature(project)) {
			continue;
		}
		final String pair = getWorkingSetId(project);
		locations.put(pair, project);
	}

	return locations;
}
 
Example 2
Project: ObfuscationMapper   File: MergeEngine.java   Source Code and License Vote up 6 votes
private void generateSubtypes(SourceSet src, Multimap<TypeEntry, TypeEntry> subtypes) {
    for (TypeEntry type : src.getAllClasses()) {
        if (type instanceof ClassEntry) {
            ClassEntry cls = (ClassEntry) type;
            TypeEntry spr = src.get(cls.getSuperclassName());
            if (spr != null) {
                subtypes.put(spr, type);
            }
        }
        for (String intr : type.getInterfaces()) {
            TypeEntry inter = src.get(intr);
            if (inter != null) {
                subtypes.put(inter, type);
            }
        }
    }
}
 
Example 3
Project: atlas   File: NativeSoUtils.java   Source Code and License Vote up 6 votes
/**
 * Verify the directory of the so file under the abi
 *
 * @param supportAbis
 * @param removeSoFiles
 * @param dirs
 * @return
 */
public static Map<String, Multimap<String, File>> getAbiSoFiles(Set<String> supportAbis, Set<String> removeSoFiles,
                                                                List<File> dirs) {
    Map<String, Multimap<String, File>> result = new HashMap<String, Multimap<String, File>>();
    IOFileFilter filter = new NativeSoFilter(supportAbis, removeSoFiles);
    for (File dir : dirs) {
        Collection<File> files = FileUtils.listFiles(dir, filter, TrueFileFilter.TRUE);
        for (File file : files) {
            File parentFolder = file.getParentFile();
            String parentName = parentFolder.getName();
            String shortName = getSoShortName(file);
            Multimap<String, File> maps = result.get(parentName);
            if (null == maps) {
                maps = HashMultimap.create(10, 3);
            }
            maps.put(shortName, file);
            result.put(parentName, maps);
        }

    }
    return result;
}
 
Example 4
Project: MicroServiceProject   File: SparseTensor.java   Source Code and License Vote up 6 votes
/**
 * retrieve a rating matrix from the tensor. Warning: it assumes there is at most one entry for each (user, item)
 * pair.
 *
 * @return a sparse rating matrix
 */
public SparseMatrix rateMatrix() {

	Table<Integer, Integer, Double> dataTable = HashBasedTable.create();
	Multimap<Integer, Integer> colMap = HashMultimap.create();

	for (TensorEntry te : this) {
		int u = te.key(userDimension);
		int i = te.key(itemDimension);

		dataTable.put(u, i, te.get());
		colMap.put(i, u);
	}

	return new SparseMatrix(dimensions[userDimension], dimensions[itemDimension], dataTable, colMap);
}
 
Example 5
Project: Equella   File: LegacyMigrationInstitutionInfoInitialiser.java   Source Code and License Vote up 5 votes
private void add31PostReadMigrators(Multimap<String, String> postReadMigs)
{
	postReadMigs.put("3.1", "com.tle.ims.migration.IMSNavigationCreation");
	postReadMigs.put("3.1", "com.tle.core.institution.migration.EnsureAttachmentUUID");
	postReadMigs.put("3.1", "com.tle.core.institution.migration.SearchDetailsUpdate");
	postReadMigs.put("3.1", "com.tle.core.institution.migration.ConfigPropertyChange");
	postReadMigs.put("3.1", "com.tle.core.institution.migration.AclPriorityChange");
}
 
Example 6
Project: CustomWorldGen   File: ItemStack.java   Source Code and License Vote up 5 votes
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot)
{
    Multimap<String, AttributeModifier> multimap;

    if (this.hasTagCompound() && this.stackTagCompound.hasKey("AttributeModifiers", 9))
    {
        multimap = HashMultimap.<String, AttributeModifier>create();
        NBTTagList nbttaglist = this.stackTagCompound.getTagList("AttributeModifiers", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
            AttributeModifier attributemodifier = SharedMonsterAttributes.readAttributeModifierFromNBT(nbttagcompound);

            if (attributemodifier != null && (!nbttagcompound.hasKey("Slot", 8) || nbttagcompound.getString("Slot").equals(equipmentSlot.getName())) && attributemodifier.getID().getLeastSignificantBits() != 0L && attributemodifier.getID().getMostSignificantBits() != 0L)
            {
                multimap.put(nbttagcompound.getString("AttributeName"), attributemodifier);
            }
        }
    }
    else
    {
        multimap = this.getItem().getAttributeModifiers(equipmentSlot, this);
    }

    return multimap;
}
 
Example 7
Project: TFCPrimitiveTech   File: ItemWoodenClub.java   Source Code and License Vote up 5 votes
@Override
public Multimap getAttributeModifiers(ItemStack stack)
{
	Multimap multimap = HashMultimap.create();
	multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", weaponBaseDamage, 0));
	return multimap;
}
 
Example 8
Project: GitHub   File: Gsons.java   Source Code and License Vote up 5 votes
public Iterable<TypeAdapterTypes> typeAdapters() {
  Map<AbstractDeclaring, GsonMirrors.TypeAdapters> mirrors = Maps.newHashMap();

  Multimap<AbstractDeclaring, ValueType> byDeclaring = HashMultimap.create();
  for (ValueType value : values().values()) {
    Protoclass protoclass = value.constitution.protoclass();
    if (protoclass.kind().isValue()) {
      Optional<AbstractDeclaring> typeAdaptersProvider = protoclass.typeAdaptersProvider();
      if (typeAdaptersProvider.isPresent()) {
        AbstractDeclaring key = typeAdaptersProvider.get();
        mirrors.put(key, key.typeAdapters().get());
        byDeclaring.put(key, value);
      } else if (protoclass.gsonTypeAdapters().isPresent()
          && protoclass.declaringType().isPresent()) {
        DeclaringType topLevel = protoclass.declaringType().get().associatedTopLevel();
        mirrors.put(topLevel, protoclass.gsonTypeAdapters().get());
        byDeclaring.put(topLevel, value);
      }
    }
  }

  ImmutableList.Builder<TypeAdapterTypes> builder = ImmutableList.builder();
  for (Entry<AbstractDeclaring, Collection<ValueType>> entry : byDeclaring.asMap().entrySet()) {
    String pack = Iterables.get(entry.getValue(), 0).$$package();
    builder.add(ImmutableTypeAdapterTypes.builder()
        .definedBy(entry.getKey())
        .mirror(mirrors.get(entry.getKey()))
        .packageGenerated(pack)
        .addAllTypes(entry.getValue())
        .build());
  }

  return builder.build();
}
 
Example 9
Project: Adventurers-Toolbox   File: ItemRock.java   Source Code and License Vote up 5 votes
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot,
		ItemStack stack) {
	Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);

	if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
		multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(),
				new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", (double) 3.0F, 0));
		multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(),
				new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", (double) -3F, 0));
	}

	return multimap;
}
 
Example 10
Project: Backmemed   File: ItemHoe.java   Source Code and License Vote up 5 votes
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot)
{
    Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);

    if (equipmentSlot == EntityEquipmentSlot.MAINHAND)
    {
        multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 0.0D, 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", (double)(this.speed - 4.0F), 0));
    }

    return multimap;
}
 
Example 11
Project: Thermionics   File: BlockPotStill.java   Source Code and License Vote up 5 votes
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
	Multimap<String, AttributeModifier> modifiers = HashMultimap.create();
	if (slot==EntityEquipmentSlot.HEAD) {
		modifiers.put(
				SharedMonsterAttributes.ARMOR.getName(),
				new AttributeModifier(UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150"), "Armor modifier", 3D, 0)
				);

	}
	
	return modifiers;
}
 
Example 12
Project: pandionj   File: ObjectModel.java   Source Code and License Vote up 5 votes
public Multimap<String, String> getTags() {
	Multimap<String,String> tags = ArrayListMultimap.create();

	for (Entry<String, ReferenceModel> e : references.entrySet()) {
		for(String t : e.getValue().getTags())
			tags.put(e.getKey(), t);
	}
	return tags;
}
 
Example 13
Project: CustomWorldGen   File: ItemTool.java   Source Code and License Vote up 5 votes
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot)
{
    Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);

    if (equipmentSlot == EntityEquipmentSlot.MAINHAND)
    {
        multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Tool modifier", (double)this.damageVsEntity, 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", (double)this.attackSpeed, 0));
    }

    return multimap;
}
 
Example 14
Project: SubgraphIsomorphismIndex   File: SubgraphIsomorphismIndexImpl.java   Source Code and License Vote up 5 votes
/**
     * Lookup only pref keys / this skips results isomorphic to the given keys
     * @param queryGraph
     * @param exactMatch
     * @return
     */
    public Multimap<K, BiMap<V, V>> lookupFlat(G queryGraph, boolean exactMatch) {

        Set<T> queryGraphTags = extractGraphTagsWrapper(queryGraph);


        Collection<InsertPosition<K, G, V, T>> positions = new LinkedList<>();

        findInsertPositions(positions, rootNode, queryGraph, queryGraphTags, HashBiMap.create(), HashBiMap.create(), true, exactMatch); //, writer);

        Multimap<K, BiMap<V, V>> result = HashMultimap.create();

        if(logger.isDebugEnabled()) {
            logger.debug("Lookup result candidates: " + positions.size());
        }

        for(InsertPosition<K, G, V, T> pos : positions) {
            // Match with the children

            result.put(pos.getNode().getKey(), pos.getIso());
            //System.out.println("Node " + pos.node + " with keys " + pos.node.getKeys() + " iso: " + pos.getGraphIso().getInToOut());
//            for(K key : pos.node.getKeys()) {
//                result.put(key, pos.getIso());
//            }
        }
        return result;
    }
 
Example 15
Project: Equella   File: LegacyMigrationInstitutionInfoInitialiser.java   Source Code and License Vote up 4 votes
private void add31ItemMigrators(Multimap<String, String> itemXmlMigs)
{
	itemXmlMigs.put("3.1", "com.tle.core.institution.migration.DisallowOldStyleCalItems");
	itemXmlMigs.put("3.1", "com.tle.core.institution.migration.RemoveDeprecatedItemParts");
	itemXmlMigs.put("3.1", "com.tle.core.institution.migration.LanguageBundleMigration");
}
 
Example 16
Project: QDrill   File: Accountor.java   Source Code and License Vote up 4 votes
public void close() {
  // remove the fragment context and reset fragment limits whenever an allocator closes
  if(parent!=null && parent.parent==null) {
    logger.debug("Fragment " + fragmentStr + "  accountor being closed");
    removeFragmentContext(fragmentContext);
  }
  resetFragmentLimits();

  if (ENABLE_ACCOUNTING && !buffers.isEmpty()) {
    StringBuffer sb = new StringBuffer();
    sb.append("Attempted to close accountor with ");
    sb.append(buffers.size());
    sb.append(" buffer(s) still allocated");
    if (handle != null) {
      sb.append("for QueryId: ");
      sb.append(QueryIdHelper.getQueryId(handle.getQueryId()));
      sb.append(", MajorFragmentId: ");
      sb.append(handle.getMajorFragmentId());
      sb.append(", MinorFragmentId: ");
      sb.append(handle.getMinorFragmentId());
    }
    sb.append(".\n");

    Multimap<DebugStackTrace, DebugStackTrace> multi = LinkedListMultimap.create();
    for (DebugStackTrace t : buffers.values()) {
      multi.put(t, t);
    }

    for (DebugStackTrace entry : multi.keySet()) {
      Collection<DebugStackTrace> allocs = multi.get(entry);

      sb.append("\n\n\tTotal ");
      sb.append(allocs.size());
      sb.append(" allocation(s) of byte size(s): ");
      for (DebugStackTrace alloc : allocs) {
        sb.append(alloc.size);
        sb.append(", ");
      }

      sb.append("at stack location:\n");
      entry.addToString(sb);
    }
    if (!buffers.isEmpty()) {
      IllegalStateException e = new IllegalStateException(sb.toString());
      if (errorOnLeak) {
        throw e;
      } else {
        logger.warn("Memory leaked.", e);
      }
    }
  }

  remainder.close();

}
 
Example 17
Project: Equella   File: LegacyMigrationInstitutionInfoInitialiser.java   Source Code and License Vote up 4 votes
private void add40PostReadMigrators(Multimap<String, String> postReadMigs)
{
	postReadMigs.put("4.0", "com.tle.web.myresource.converter.MyResourceACLMigrator");
	postReadMigs.put("4.0", "com.tle.core.institution.migration.v40.EditHierarchyPrivilegeMigrator");
}
 
Example 18
Project: MicroServiceProject   File: DataSplitter.java   Source Code and License Vote up 4 votes
/**
 * Split ratings into two parts where one rating per user is preserved as the test set and the remaining data as the
 * training set
 */
public SparseMatrix[] getLOOByUser(boolean isByDate, SparseMatrix timestamps) throws Exception {

    SparseMatrix trainMatrix = new SparseMatrix(rateMatrix);

    // for building test matrix
    Table<Integer, Integer, Double> dataTable = HashBasedTable.create();
    Multimap<Integer, Integer> colMap = HashMultimap.create();

    for (int u = 0, um = rateMatrix.numRows(); u < um; u++) {

        List<Integer> items = rateMatrix.getColumns(u);
        int i = -1;

        if (!isByDate) {
            // by random
            int randIdx = (int) (items.size() * Math.random());
            i = items.get(randIdx);
        } else {
            // by date
            List<GenericRatingContext> rcs = new ArrayList<>();
            for (int j : items) {
                rcs.add(new GenericRatingContext(u, j, (long) timestamps.get(u, j)));
            }
            Collections.sort(rcs);

            i = rcs.get(rcs.size() - 1).getItem(); // most recent item
        }

        trainMatrix.set(u, i, 0); // remove from training

        dataTable.put(u, i, rateMatrix.get(u, i));
        colMap.put(i, u);
    }

    // remove zero entries
    SparseMatrix.reshape(trainMatrix);

    // build test matrix
    SparseMatrix testMatrix = new SparseMatrix(rateMatrix.numRows, rateMatrix.numColumns, dataTable, colMap);

    debugInfo(trainMatrix, testMatrix, -1);

    return new SparseMatrix[]{trainMatrix, testMatrix};
}
 
Example 19
Project: Equella   File: LegacyMigrationInstitutionInfoInitialiser.java   Source Code and License Vote up 4 votes
private void add32PostReadMigrators(Multimap<String, String> postReadMigs)
{
	postReadMigs.put("3.2", "com.tle.cal.migration.CalPrivMigrator");
	postReadMigs.put("3.2.22212", "com.tle.core.institution.migration.v32.RemoveEmailTemplatePrivMigrator");
}
 
Example 20
Project: uniquecrops   File: EmblemMelee.java   Source Code and License Vote up 4 votes
@Override
void fillModifiers(Multimap<String, AttributeModifier> attributes, ItemStack stack) {

	attributes.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 1, 0));
}