/**
* Create permissions, note that permissionType + targetId should be unique
*/
@Transactional
public Set<Permission> createPermissions(Set<Permission> permissions) {
Multimap<String, String> targetIdPermissionTypes = HashMultimap.create();
for (Permission permission : permissions) {
targetIdPermissionTypes.put(permission.getTargetId(), permission.getPermissionType());
}
for (String targetId : targetIdPermissionTypes.keySet()) {
Collection<String> permissionTypes = targetIdPermissionTypes.get(targetId);
List<Permission> current =
permissionRepository.findByPermissionTypeInAndTargetId(permissionTypes, targetId);
Preconditions.checkState(CollectionUtils.isEmpty(current),
"Permission with permissionType %s targetId %s already exists!", permissionTypes,
targetId);
}
Iterable<Permission> results = permissionRepository.save(permissions);
return FluentIterable.from(results).toSet();
}
java类com.google.common.collect.HashMultimap的实例源码
DefaultRolePermissionService.java 文件源码
项目:apollo-custom
阅读 27
收藏 0
点赞 0
评论 0
EmbeddingIoUtils.java 文件源码
项目:clearwsd
阅读 33
收藏 0
点赞 0
评论 0
/**
* Binarize embeddings as described in "Revisiting Embedding Features for Simple Semi-supervised Learning" (Guo et al. 2014).
* Output is a map of indices, where negative-valued indices are negative, and positive-valued indices are positive. Indices
* start at 1, so as to avoid loss of information on 0.
*
* @param embeddings map from identifiers onto corresponding vectors
* @return map from identifiers onto indices
*/
public static Multimap<String, Integer> binarize(Map<String, float[]> embeddings) {
float[] posMean = filteredMean(embeddings.values(), v -> v >= 0);
float[] negMean = filteredMean(embeddings.values(), v -> v < 0);
Multimap<String, Integer> binarizedEmbeddings = HashMultimap.create();
for (Map.Entry<String, float[]> embedding : embeddings.entrySet()) {
int index = 0;
for (float val : embedding.getValue()) {
if (val > posMean[index]) {
binarizedEmbeddings.put(embedding.getKey(), -(index + 1));
} else if (val < negMean[index]) {
binarizedEmbeddings.put(embedding.getKey(), index + 1);
}
++index;
}
}
return binarizedEmbeddings;
}
N4HeadlessCompiler.java 文件源码
项目:n4js
阅读 34
收藏 0
点赞 0
评论 0
private void configureResourceSetContainerState(final List<N4JSProject> allProjects) {
// a container is a project.
List<String> containers = new LinkedList<>();
BiMap<String, N4JSProject> container2project = HashBiMap.create();
// the URIs of all resources directly contained in a project/container.
Multimap<String, URI> container2Uris = HashMultimap.create();
for (N4JSProject project : allProjects) {
String container = FileBasedWorkspace.N4FBPRJ + project.getLocation();
container2project.put(container, project);
containers.add(container);
for (IN4JSSourceContainer sourceContainer : project.getSourceContainers()) {
Iterables.addAll(container2Uris.get(container), sourceContainer);
}
}
// Define the Mapping of Resources (URIs to Container === Projects),
rsbAcs.configure(containers, container2Uris);
}
ProjectLocationAwareWorkingSetManager.java 文件源码
项目:n4js
阅读 29
收藏 0
点赞 0
评论 0
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;
}
PathCalculator.java 文件源码
项目:hygene
阅读 24
收藏 0
点赞 0
评论 0
/**
* Builds a map of {@link Segment}s and their edges in the {@link Subgraph} for either the incoming or
* outgoing {@link Edge}s.
* <p>
* {@link DummyEdge}s will not be added but their original edge, for which they are a diversion, will be added.
*
* @param subgraph the {@link Subgraph}
* @param sequenceDirection the {@link SequenceDirection}
* @return map of {@link Edge}s for each {@link Segment}
*/
private Multimap<GfaNode, Edge> buildEdgeMap(final Subgraph subgraph,
final SequenceDirection sequenceDirection) {
final Multimap<GfaNode, Edge> edgeMap = HashMultimap.create();
subgraph.getGfaNodes().forEach(segment -> {
final Set<Edge> edges = sequenceDirection.ternary(segment.getIncomingEdges(), segment.getOutgoingEdges());
edges.forEach(edge -> {
if (edge instanceof DummyEdge) {
edgeMap.put(segment, ((DummyEdge) edge).getOriginalEdge());
} else {
edgeMap.put(segment, edge);
}
});
});
return edgeMap;
}
DefaultRouter.java 文件源码
项目:athena
阅读 34
收藏 0
点赞 0
评论 0
@Activate
public void activate() {
ribTable4 = new ConcurrentInvertedRadixTree<>(
new DefaultByteArrayNodeFactory());
ribTable6 = new ConcurrentInvertedRadixTree<>(
new DefaultByteArrayNodeFactory());
routesWaitingOnArp = Multimaps.synchronizedSetMultimap(
HashMultimap.create());
coreService.registerApplication(ROUTER_APP_ID);
bgpUpdatesExecutor = Executors.newSingleThreadExecutor(
new ThreadFactoryBuilder()
.setNameFormat("rib-updates-%d").build());
}
DisableDamageModule.java 文件源码
项目:ProjectAres
阅读 34
收藏 0
点赞 0
评论 0
public static DisableDamageModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
SetMultimap<DamageCause, PlayerRelation> causes = HashMultimap.create();
for(Element damageCauseElement : doc.getRootElement().getChildren("disabledamage")) {
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 DisableDamageModule(causes);
}
SoundManager.java 文件源码
项目:Backmemed
阅读 36
收藏 0
点赞 0
评论 0
public SoundManager(SoundHandler p_i45119_1_, GameSettings p_i45119_2_)
{
this.invPlayingSounds = ((BiMap)this.playingSounds).inverse();
this.categorySounds = HashMultimap.<SoundCategory, String>create();
this.tickableSounds = Lists.<ITickableSound>newArrayList();
this.delayedSounds = Maps.<ISound, Integer>newHashMap();
this.playingSoundsStopTime = Maps.<String, Integer>newHashMap();
this.listeners = Lists.<ISoundEventListener>newArrayList();
this.pausedChannels = Lists.<String>newArrayList();
this.sndHandler = p_i45119_1_;
this.options = p_i45119_2_;
try
{
SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class);
SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
}
catch (SoundSystemException soundsystemexception)
{
LOGGER.error(LOG_MARKER, (String)"Error linking with the LibraryJavaSound plug-in", (Throwable)soundsystemexception);
}
}
ScanResult.java 文件源码
项目:dremio-oss
阅读 36
收藏 0
点赞 0
评论 0
/**
* merges this and other together into a new result object
* @param other
* @return the resulting merge
*/
public ScanResult merge(ScanResult other) {
final Multimap<String, ChildClassDescriptor> newImpls = HashMultimap.create();
for (Collection<ParentClassDescriptor> impls : asList(implementations, other.implementations)) {
for (ParentClassDescriptor c : impls) {
newImpls.putAll(c.getName(), c.getChildren());
}
}
List<ParentClassDescriptor> newImplementations = new ArrayList<>();
for (Entry<String, Collection<ChildClassDescriptor>> entry : newImpls.asMap().entrySet()) {
newImplementations.add(new ParentClassDescriptor(entry.getKey(), new ArrayList<>(entry.getValue())));
}
return new ScanResult(
merge(scannedPackages, other.scannedPackages),
merge(scannedClasses, other.scannedClasses),
merge(scannedAnnotations, other.scannedAnnotations),
merge(annotatedClasses, other.annotatedClasses),
newImplementations);
}
NativeSoUtils.java 文件源码
项目:atlas
阅读 39
收藏 0
点赞 0
评论 0
/**
* 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;
}
SoundManager.java 文件源码
项目:BaseClient
阅读 36
收藏 0
点赞 0
评论 0
public SoundManager(SoundHandler p_i45119_1_, GameSettings p_i45119_2_)
{
this.invPlayingSounds = ((BiMap)this.playingSounds).inverse();
this.playingSoundPoolEntries = Maps.<ISound, SoundPoolEntry>newHashMap();
this.categorySounds = HashMultimap.<SoundCategory, String>create();
this.tickableSounds = Lists.<ITickableSound>newArrayList();
this.delayedSounds = Maps.<ISound, Integer>newHashMap();
this.playingSoundsStopTime = Maps.<String, Integer>newHashMap();
this.sndHandler = p_i45119_1_;
this.options = p_i45119_2_;
try
{
SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class);
SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
}
catch (SoundSystemException soundsystemexception)
{
logger.error(LOG_MARKER, (String)"Error linking with the LibraryJavaSound plug-in", (Throwable)soundsystemexception);
}
}
AnnotationUtils.java 文件源码
项目:spring2ts
阅读 41
收藏 0
点赞 0
评论 0
public static Multimap<String, String> getAnnotationAsMap(org.jboss.forge.roaster.model.Annotation<?> annotation,
Class<? extends Annotation> type) {
if(annotation == null) return null;
List<Method> methods = getAnnotationAttributes(type);
Multimap<String, String> result = HashMultimap.create();
for (Method method : methods) {
String name = method.getName();
boolean array = method.getReturnType().isArray();
String value = annotation.getLiteralValue(name);
if(StringUtils.isBlank(value)) continue;
String [] values = array
? annotation.getStringArrayValue(name) : new String[]{annotation.getStringValue(name)};
if(allElementsNull(values)) continue;
result.putAll(name, Arrays.asList(values));
}
return result;
}
SetMultimapDeserializer.java 文件源码
项目:abhot
阅读 30
收藏 0
点赞 0
评论 0
@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;
}
SparseTensor.java 文件源码
项目:MicroServiceProject
阅读 37
收藏 0
点赞 0
评论 0
/**
* Construct a sparse tensor with indices and values
*
* @param dims
* dimensions of a tensor
* @param nds
* n-dimensional keys
* @param vals
* entry values
*/
@SuppressWarnings("unchecked")
public SparseTensor(int[] dims, List<Integer>[] nds, List<Double> vals) {
if (dims.length < 3)
throw new Error("The dimension of a tensor cannot be smaller than 3!");
numDimensions = dims.length;
dimensions = new int[numDimensions];
ndKeys = (List<Integer>[]) new List<?>[numDimensions];
keyIndices = (Multimap<Integer, Integer>[]) new Multimap<?, ?>[numDimensions];
for (int d = 0; d < numDimensions; d++) {
dimensions[d] = dims[d];
ndKeys[d] = nds == null ? new ArrayList<Integer>() : new ArrayList<Integer>(nds[d]);
keyIndices[d] = HashMultimap.create();
}
values = vals == null ? new ArrayList<Double>() : new ArrayList<>(vals);
indexedDimensions = new ArrayList<>(numDimensions);
}
SparseTensor.java 文件源码
项目:MicroServiceProject
阅读 38
收藏 0
点赞 0
评论 0
/**
* 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);
}
RemoteConfigLongPollService.java 文件源码
项目:apollo-custom
阅读 26
收藏 0
点赞 0
评论 0
/**
* Constructor.
*/
public RemoteConfigLongPollService() {
m_longPollFailSchedulePolicyInSecond = new ExponentialSchedulePolicy(1, 120); //in second
m_longPollingStopped = new AtomicBoolean(false);
m_longPollingService = Executors.newSingleThreadExecutor(
ApolloThreadFactory.create("RemoteConfigLongPollService", true));
m_longPollStarted = new AtomicBoolean(false);
m_longPollNamespaces =
Multimaps.synchronizedSetMultimap(HashMultimap.<String, RemoteConfigRepository>create());
m_notifications = Maps.newConcurrentMap();
m_remoteNotificationMessages = Maps.newConcurrentMap();
m_responseType = new TypeToken<List<ApolloConfigNotification>>() {
}.getType();
gson = new Gson();
m_configUtil = ApolloInjector.getInstance(ConfigUtil.class);
m_httpUtil = ApolloInjector.getInstance(HttpUtil.class);
m_serviceLocator = ApolloInjector.getInstance(ConfigServiceLocator.class);
m_longPollRateLimiter = RateLimiter.create(m_configUtil.getLongPollQPS());
}
HashMultimapStorage.java 文件源码
项目:Leveled-Storage
阅读 26
收藏 0
点赞 0
评论 0
@Override
public void readGeneric(DataInputStream input, StorageObject... generic) throws IOException {
int size = input.readInt();
setValue(HashMultimap.create());
for(int i = 0; i < size; i++) {
int len = input.readInt();
K key = (K) generic[0].delegate();
key.read(input);
for(int j = 0; j < len; j++) {
V value = (V) generic[1].delegate();
value.read(input);
getValue().put(key, value);
}
}
}
DeviceAccessFacadeImpl.java 文件源码
项目:wayf-cloud
阅读 28
收藏 0
点赞 0
评论 0
private Completable inflatePublishers(Iterable<DeviceAccess> deviceAccesss, DeviceAccessQuery query) {
// Return as complete if publisher is not a requested field
if (query.getInflationPolicy() == null || !query.getInflationPolicy().hasChildField(DeviceAccessQuery.PUBLISHER_FIELD)) {
return Completable.complete();
}
Multimap<Long, DeviceAccess> deviceAccesssByPublisherId = HashMultimap.create();
return Observable.fromIterable(deviceAccesss)
// Filter out publisher sessions with no publisher
.filter((deviceAccess) -> deviceAccess.getPublisher() != null && deviceAccess.getPublisher().getId() != null)
// Collect all of the publisher sessions and their publisher IDs into a map
.collectInto(deviceAccesssByPublisherId, (map, deviceAccess) -> map.put(deviceAccess.getPublisher().getId(), deviceAccess))
// Fetch all of the publishers for those publisher IDs
.flatMapObservable((map) -> map.keySet().isEmpty()? Observable.empty() : publisherFacade.filter(new PublisherQuery().ids(map.keySet())))
// For each publisher returned, map it to each publisher session that had its ID
.flatMapCompletable((publisher) ->
Observable.fromIterable(deviceAccesssByPublisherId.get(publisher.getId()))
.flatMapCompletable((deviceAccess) ->
Completable.fromAction(() -> deviceAccess.setPublisher(publisher))
)
);
}
DeviceAccessFacadeImpl.java 文件源码
项目:wayf-cloud
阅读 30
收藏 0
点赞 0
评论 0
private Completable inflateIdentityProviders(Iterable<DeviceAccess> deviceAccesss, DeviceAccessQuery query) {
// Return as complete if authenticatedBy is not a requested field
if (query.getInflationPolicy() == null || !query.getInflationPolicy().hasChildField(DeviceAccessQuery.IDENTITY_PROVIDER)) {
return Completable.complete();
}
Multimap<Long, DeviceAccess> deviceAccesssByIdpId = HashMultimap.create();
return Observable.fromIterable(deviceAccesss)
// Filter out publisher sessions with no publisher
.filter((deviceAccess) -> deviceAccess.getIdentityProvider() != null && deviceAccess.getIdentityProvider().getId() != null)
// Collect all of the publisher sessions and their identity provider IDs into a map
.collectInto(deviceAccesssByIdpId, (map, deviceAccess) -> map.put(deviceAccess.getIdentityProvider().getId(), deviceAccess))
// Fetch all of the publishers for those publisher IDs
.flatMapObservable((map) -> map.keySet().isEmpty()? Observable.empty() : identityProviderFacade.filter(new IdentityProviderQuery().ids(map.keySet())))
// For each identity provider returned, map it to each publisher session that had its ID
.flatMapCompletable((identityProvider) ->
Observable.fromIterable(deviceAccesssByIdpId.get(identityProvider.getId()))
.flatMapCompletable((deviceAccess) ->
Completable.fromAction(() -> deviceAccess.setIdentityProvider(identityProvider))
)
);
}
WatchKeysUtil.java 文件源码
项目:apollo-custom
阅读 25
收藏 0
点赞 0
评论 0
private Multimap<String, String> findPublicConfigWatchKeys(String applicationId,
String clusterName,
Set<String> namespaces,
String dataCenter) {
Multimap<String, String> watchedKeysMap = HashMultimap.create();
List<AppNamespace> appNamespaces = appNamespaceService.findPublicNamespacesByNames(namespaces);
for (AppNamespace appNamespace : appNamespaces) {
//check whether the namespace's appId equals to current one
if (Objects.equals(applicationId, appNamespace.getAppId())) {
continue;
}
String publicConfigAppId = appNamespace.getAppId();
watchedKeysMap.putAll(appNamespace.getName(),
assembleWatchKeys(publicConfigAppId, clusterName, appNamespace.getName(), dataCenter));
}
return watchedKeysMap;
}
ActueelBepaling.java 文件源码
项目:OperatieBRP
阅读 33
收藏 0
点赞 0
评论 0
private Multimap<MetaObject, MetaRecord> bepaalActueleRecords(final MetaObject persoonObject) {
final Multimap<MetaObject, MetaRecord> records = HashMultimap.create();
persoonObject.accept(new ParentFirstModelVisitor() {
@Override
protected void doVisit(final MetaRecord record) {
final VerantwoordingCategorie verantwoordingCategorie = record.getParentGroep().getGroepElement().getVerantwoordingCategorie();
final BooleanSupplier actueelActieRecord = () -> verantwoordingCategorie == VerantwoordingCategorie.A
&& record.getActieVerval() == null && record.getDatumEindeGeldigheid() == null;
final BooleanSupplier actueelDienstRecord = () -> verantwoordingCategorie == VerantwoordingCategorie.D
&& record.getDatumTijdVerval() == null;
if (verantwoordingCategorie == VerantwoordingCategorie.G || actueelActieRecord.getAsBoolean() || actueelDienstRecord.getAsBoolean()) {
records.put(record.getParentGroep().getParentObject(), record);
}
}
});
return records;
}
MetaObject.java 文件源码
项目:OperatieBRP
阅读 38
收藏 0
点赞 0
评论 0
/**
* Bouwt het MetaObject.
* @param parentObject het parent meta object
* @return het MetaObject
*/
MetaObject build(final MetaObject parentObject) {
final MetaObject gebouwdObject = new MetaObject();
gebouwdObject.parentObject = parentObject;
gebouwdObject.objectsleutel = objectsleutel;
gebouwdObject.objectElement = objectElement;
final Multimap<ObjectElement, MetaObject> tempObjectenMap = HashMultimap.create();
for (final Builder builder : objectBuilderList) {
final MetaObject object = builder.build(gebouwdObject);
tempObjectenMap.put(object.getObjectElement(), object);
}
gebouwdObject.elementObjectMap = ImmutableMultimap.copyOf(tempObjectenMap);
gebouwdObject.objecten = ImmutableSet.copyOf(tempObjectenMap.values());
final Map<GroepElement, MetaGroep> tempGroepenMap = Maps.newHashMap();
for (final MetaGroep.Builder groepBuilder : groepBuilderList) {
final MetaGroep groep = groepBuilder.build(gebouwdObject);
tempGroepenMap.put(groep.getGroepElement(), groep);
}
gebouwdObject.elementGroepMap = ImmutableMap.copyOf(tempGroepenMap);
gebouwdObject.groepen = ImmutableSet.copyOf(tempGroepenMap.values());
return gebouwdObject;
}
HashMultimapTest.java 文件源码
项目:GitHub
阅读 38
收藏 0
点赞 0
评论 0
public void test_for_multimap() throws Exception {
HashMultimap map = HashMultimap.create();
map.put("name", "a");
map.put("name", "b");
String json = JSON.toJSONString(map);
assertEquals("{\"name\":[\"a\",\"b\"]}", json);
}
Gsons.java 文件源码
项目:GitHub
阅读 32
收藏 0
点赞 0
评论 0
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();
}
VerbNetExperiment.java 文件源码
项目:clearwsd
阅读 26
收藏 0
点赞 0
评论 0
private static List<NlpFocus<DepNode, DepTree>> filterPolysemous(
List<NlpFocus<DepNode, DepTree>> data) {
Multimap<String, String> labelMap = HashMultimap.create();
for (NlpFocus<DepNode, DepTree> instance : data) {
String predicate = instance.focus().feature(FeatureType.Predicate);
labelMap.put(predicate, instance.feature(FeatureType.Gold));
}
return data.stream()
.filter(instance -> labelMap.get(instance.focus().feature(FeatureType.Predicate)).size() > 1)
.collect(Collectors.toList());
}
TestTreeTransformerTest.java 文件源码
项目:n4js
阅读 35
收藏 0
点赞 0
评论 0
/***/
@Test
public void testMultipleSuitesWithMultipleTestCases() {
final Multimap<String, String> map = HashMultimap.create();
map.put("suite.name.b", "test.case.g");
map.put("suite.name.b", "test.case.h");
map.put("suite.name.a", "test.case.b");
map.put("suite.name.a", "test.case.a");
map.put("suite.name.a", "test.case.c");
map.put("suite.name.c", "test.case.z");
map.put("suite.name.c", "test.case.x");
map.put("suite.name.c", "test.case.y");
final String actual = asString(transformer.apply(createTestTree(map)));
assertContains(actual, "\"endpoint\":\"http://localhost:9415\"");
assertContains(actual, "\"testMethods\":[\"test.case.g\",\"test.case.h\"]");
assertContains(actual, "\"testMethods\":[\"test.case.a\",\"test.case.b\",\"test.case.c\"]");
assertContains(actual, "\"testMethods\":[\"test.case.x\",\"test.case.y\",\"test.case.z\"]");
assertTrue(actual.indexOf("suite.name.a") > 0);
assertTrue(actual.indexOf("suite.name.b") > 0);
assertTrue(actual.indexOf("suite.name.c") > 0);
assertTrue(actual.indexOf("suite.name.a") < actual.indexOf("suite.name.b"));
assertTrue(actual.indexOf("suite.name.b") < actual.indexOf("suite.name.c"));
assertTrue(actual.indexOf("suite.name.a") < actual.indexOf("suite.name.c"));
}
SelectAllProjectExplorer_PluginUITest.java 文件源码
项目:n4js
阅读 39
收藏 0
点赞 0
评论 0
@Override
@Before
public void setUp() throws Exception {
super.setUp();
waitForIdleState();
projectExplorer = (ProjectExplorer) showView(ProjectExplorer.VIEW_ID);
waitForUiThread();
assertNotNull("Cannot show Project Explorer.", projectExplorer);
commonViewer = projectExplorer.getCommonViewer();
assertFalse("Expected projects as top level elements in navigator.", broker.isWorkingSetTopLevel());
assertNull(
"Select working set drop down contribution was visible when projects are configured as top level elements.",
getWorkingSetDropDownContribution());
final Multimap<ProjectType, String> typeNamesMapping = HashMultimap.create();
typeNamesMapping.putAll(LIBRARY, LIBRARY_PROJECTS);
typeNamesMapping.putAll(TEST, TEST_PROJECTS);
for (final Entry<ProjectType, Collection<String>> entry : typeNamesMapping.asMap().entrySet()) {
for (final String projectName : entry.getValue()) {
createN4JSProject(projectName, entry.getKey());
}
}
// Actually close "Closed*" projects
closeProject("ClosedL2");
closeProject("ClosedT2");
// Wait for workbench to reflect project changes
waitForIdleState();
commonViewer.refresh();
// Disable auto-building, as there is no real code to build involved
ResourcesPlugin.getWorkspace().getDescription().setAutoBuilding(false);
}
TestDiscoveryHelper.java 文件源码
项目:n4js
阅读 31
收藏 0
点赞 0
评论 0
/**
* Creates a mapping between the container module URI and the actual URIs. Consider cases when the list contains two
* locations URIs from two methods in the same class Then this method will return with multimap where the single key
* is the location to the container module and the value is the two method URIs.
*/
private HashMultimap<URI, URI> createTestLocationMapping(List<URI> testLocations) {
HashMultimap<URI, URI> moduleUris2testUris = HashMultimap.create();
for (final URI testLocation : testLocations) {
moduleUris2testUris.put(testLocation.trimFragment(), testLocation);
}
return moduleUris2testUris;
}
SubscriberRegistry.java 文件源码
项目:guava-mock
阅读 47
收藏 0
点赞 0
评论 0
/**
* Returns all subscribers for the given listener grouped by the type of event they subscribe to.
*/
private Multimap<Class<?>, Subscriber> findAllSubscribers(Object listener) {
Multimap<Class<?>, Subscriber> methodsInListener = HashMultimap.create();
Class<?> clazz = listener.getClass();
for (Method method : getAnnotatedMethods(clazz)) {
Class<?>[] parameterTypes = method.getParameterTypes();
Class<?> eventType = parameterTypes[0];
methodsInListener.put(eventType, Subscriber.create(bus, listener, method));
}
return methodsInListener;
}
ItemStack.java 文件源码
项目:DecompiledMinecraft
阅读 56
收藏 0
点赞 0
评论 0
public Multimap<String, AttributeModifier> getAttributeModifiers()
{
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 && attributemodifier.getID().getLeastSignificantBits() != 0L && attributemodifier.getID().getMostSignificantBits() != 0L)
{
multimap.put(nbttagcompound.getString("AttributeName"), attributemodifier);
}
}
}
else
{
multimap = this.getItem().getItemAttributeModifiers();
}
return multimap;
}