List of usage examples for com.google.common.collect ArrayListMultimap create
public static <K, V> ArrayListMultimap<K, V> create()
From source file:org.sonar.server.db.migrations.v45.AddMissingCustomRuleParametersMigration.java
@Override public void execute() { DbSession session = db.openSession(false); try {/* w ww . j a v a 2 s. co m*/ Migration45Mapper mapper = session.getMapper(Migration45Mapper.class); List<RuleParameter> templateRuleParams = mapper.selectAllTemplateRuleParameters(); Multimap<Integer, RuleParameter> templateRuleParamsByRuleId = ArrayListMultimap.create(); for (RuleParameter templateRuleParam : templateRuleParams) { templateRuleParamsByRuleId.put(templateRuleParam.getRuleId(), templateRuleParam); } List<Rule> customRules = mapper.selectAllCustomRules(); Multimap<Integer, Integer> customRuleIdsByTemplateRuleId = HashMultimap.create(); for (Rule customRule : customRules) { customRuleIdsByTemplateRuleId.put(customRule.getTemplateId(), customRule.getId()); } List<RuleParameter> customRuleParams = mapper.selectAllCustomRuleParameters(); Multimap<Integer, RuleParameter> customRuleParamsByRuleId = ArrayListMultimap.create(); for (RuleParameter customRuleParam : customRuleParams) { customRuleParamsByRuleId.put(customRuleParam.getRuleId(), customRuleParam); } // For each parameters of template rules, verify that each custom rules has the parameter for (Integer templateRuleId : templateRuleParamsByRuleId.keySet()) { for (RuleParameter templateRuleParam : templateRuleParamsByRuleId.get(templateRuleId)) { // Each custom rule should have this parameter for (Integer customRuleId : customRuleIdsByTemplateRuleId.get(templateRuleId)) { if (!hasParameter(templateRuleParam.getName(), customRuleParamsByRuleId.get(customRuleId))) { // Insert new custom rule parameter mapper.insertRuleParameter(new RuleParameter().setRuleId(customRuleId) .setRuleTemplateId(templateRuleId).setName(templateRuleParam.getName()) .setDescription(templateRuleParam.getDescription()) .setType(templateRuleParam.getType())); // Update updated at date of custom rule in order to allow E/S indexation mapper.updateRuleUpdateAt(customRuleId, new Date(system.now())); } } } } session.commit(); } finally { session.close(); } }
From source file:org.terasology.logic.health.BlockDamageRenderer.java
@Override public void renderOverlay() { if (blockSelectionRenderer == null) { Texture texture = Assets.getTextureRegion("core:blockdamageeffects#1").get().getTexture(); blockSelectionRenderer = new BlockSelectionRenderer(texture); }/*ww w.j a v a2 s .c o m*/ // group the entities into what texture they will use so that there is less recreating meshes (changing a texture region on the BlockSelectionRenderer // will recreate the mesh to use the different UV coordinates). Also this allows Multimap<Integer, Vector3i> groupedEntitiesByEffect = ArrayListMultimap.create(); for (EntityRef entity : entityManager.getEntitiesWith(HealthComponent.class, BlockComponent.class)) { HealthComponent health = entity.getComponent(HealthComponent.class); if (health.currentHealth == health.maxHealth) { continue; } BlockComponent blockComponent = entity.getComponent(BlockComponent.class); groupedEntitiesByEffect.put(getEffectsNumber(health), blockComponent.getPosition()); } for (EntityRef entity : entityManager.getEntitiesWith(BlockRegionComponent.class, HealthComponent.class)) { HealthComponent health = entity.getComponent(HealthComponent.class); if (health.currentHealth == health.maxHealth) { continue; } BlockRegionComponent blockRegion = entity.getComponent(BlockRegionComponent.class); for (Vector3i blockPos : blockRegion.region) { groupedEntitiesByEffect.put(getEffectsNumber(health), blockPos); } } // we know that the texture will be the same for each block effect, just differnt UV coordinates. Bind the texture already blockSelectionRenderer.beginRenderOverlay(); for (Integer effectsNumber : groupedEntitiesByEffect.keySet()) { Optional<TextureRegionAsset> texture = Assets .getTextureRegion("core:blockdamageeffects#" + effectsNumber); if (texture.isPresent()) { blockSelectionRenderer.setEffectsTexture(texture.get()); for (Vector3i position : groupedEntitiesByEffect.get(effectsNumber)) { blockSelectionRenderer.renderMark(position); } } } blockSelectionRenderer.endRenderOverlay(); }
From source file:eu.esdihumboldt.hale.common.headless.transform.filter.InstanceFilterDefinition.java
/** * Default constructor//from w w w.j a v a 2 s . co m */ public InstanceFilterDefinition() { this.typeFilters = ArrayListMultimap.create(); this.unconditionalFilters = new ArrayList<>(); this.excludedTypes = new HashSet<String>(); }
From source file:org.lenskit.data.dao.file.StaticFileDAOProvider.java
/** * Construct a new data layout object. */ public StaticFileDAOProvider() { sources = new ArrayList<>(); indexedAttributes = ArrayListMultimap.create(); }
From source file:edu.odu.cs.cs350.yellow1.jar.ExecutionResults.java
/** * Construct a new instance of ExecutionResults that signifies the mutant has been killed * @param numOfSucesses the number of times the mutant was ran and exited no failure * @param numOfFailurs the number of times the mutant was ran and exited with failure * @param numOfTestTillKill the test number that killed the mutant * @param jarName the name of the executable jar the mutant was run in * @param killed true the mutant was killed * @param killedFile the object representing the file that killed the mutant * @param outFiles List of file object representing the standard out produced by the mutant exec * @param errFiles List of file object representing the standard err produced by the mutant exec *//* ww w. jav a 2 s . c o m*/ public ExecutionResults(int numOfSucesses, int numOfFailurs, int numOfTestTillKill, String jarName, boolean killed, File killedFile, List<File> outFiles, List<File> errFiles) { this.numOfSucesses = numOfSucesses; this.numOfFailurs = numOfFailurs; this.numOfTestTillKill = numOfTestTillKill; this.jarName = jarName; this.killed = killed; this.jarOutPuts = ArrayListMultimap.create(); this.jarOutPuts.putAll(true, outFiles); this.jarOutPuts.putAll(false, errFiles); this.killedFile = killedFile; }
From source file:org.obeonetwork.m2doc.genconf.TemplateConfigurationServices.java
/** * return generation eObject with definitions template information. * /*from ww w .j a v a2 s . c o m*/ * @param generation * Generation * @param templateInfo * TemplateInfo * @return generation eObject with definitions template information. */ public Generation addProperties(Generation generation, TemplateInfo templateInfo) { Multimap<String, EPackage> packagesByName = ArrayListMultimap.create(); for (String uri : templateInfo.getPackagesURIs()) { if (EPackage.Registry.INSTANCE.containsKey(uri)) { EPackage p = EPackage.Registry.INSTANCE.getEPackage(uri); if (p != null && p.getName() != null) { packagesByName.put(p.getName(), p); } } } for (String key : templateInfo.getVariables().keySet()) { String typeName = templateInfo.getVariables().get(key); Definition definition = null; // The only currently supported scalar type is 'string' if (M2DocCustomProperties.STRING_TYPE.equals(typeName)) { StringDefinition sdefinition = getConfigurationServices().createStringDefinition(generation); sdefinition.setValue(typeName); definition = sdefinition; } else if (TemplateConfigUtil.isValidClassifierTypeName(typeName)) { int index = typeName.indexOf(TemplateConfigUtil.METAMODEL_TYPE_SEPARATOR); String packageName = typeName.substring(0, index); String classifierName = typeName.substring(index + 2); ModelDefinition mdefinition = getConfigurationServices().createModelDefinition(generation); if (packagesByName.containsKey(packageName)) { Collection<EPackage> packages = packagesByName.get(packageName); // We'll use the first matching classifier we find with that name among the packages with this name for (EPackage pack : packages) { EClassifier eClassifier = pack.getEClassifier(classifierName); if (eClassifier != null) { mdefinition.setType(eClassifier); break; } } } definition = mdefinition; } else { // Create untyped definition definition = getConfigurationServices().createModelDefinition(generation); } if (definition != null) { definition.setKey(key); } } return generation; }
From source file:com.android.build.gradle.internal.ProductFlavorCombo.java
/** * Creates a list containing all combinations of ProductFlavors of the given dimensions. * @param flavorDimensions The dimensions each product flavor can belong to. * @param productFlavors An iterable of all ProductFlavors in the project.. * @return A list of ProductFlavorCombo representing all combinations of ProductFlavors. *//*from w w w.j a va2 s . co m*/ @NonNull public static <S extends DimensionAware & Named> List<ProductFlavorCombo<S>> createCombinations( @Nullable List<String> flavorDimensions, @NonNull Iterable<S> productFlavors) { List<ProductFlavorCombo<S>> result = Lists.newArrayList(); if (flavorDimensions == null || flavorDimensions.isEmpty()) { for (S flavor : productFlavors) { result.add(new ProductFlavorCombo<S>(ImmutableList.of(flavor))); } } else { // need to group the flavor per dimension. // First a map of dimension -> list(ProductFlavor) ArrayListMultimap<String, S> map = ArrayListMultimap.create(); for (S flavor : productFlavors) { String flavorDimension = flavor.getDimension(); if (flavorDimension == null) { throw new RuntimeException( String.format("Flavor '%1$s' has no flavor dimension.", flavor.getName())); } if (!flavorDimensions.contains(flavorDimension)) { throw new RuntimeException(String.format("Flavor '%1$s' has unknown dimension '%2$s'.", flavor.getName(), flavor.getDimension())); } map.put(flavorDimension, flavor); } createProductFlavorCombinations(result, Lists.<S>newArrayListWithCapacity(flavorDimensions.size()), 0, flavorDimensions, map); } return result; }
From source file:ph.devcon.android.sponsor.SponsorFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_sponsor, container, false); DevConApplication.injectMembers(this); ButterKnife.inject(this, rootView); if (!eventBus.isRegistered(this)) { eventBus.register(this); }//from w w w . j av a2 s .com initSwipeLayout(); ArrayListMultimap<String, Sponsor> sponsorMultimap = ArrayListMultimap.create(); sponsorSectionAdapter = new SponsorSectionAdapter(getActivity(), sponsorMultimap); lvwSponsors.setAdapter(sponsorSectionAdapter); if (sponsorService.isCacheValid()) { sponsorService.populateFromCache(getLoaderManager(), savedInstanceState); } else { sponsorService.populateFromAPI(); } return rootView; }
From source file:org.glowroot.ui.MultiErrorIntervalMerger.java
private static GroupedMultiErrorInterval mergeWithOverlapping(String syntheticMonitorId, MultiErrorInterval multiErrorInterval, List<GroupedMultiErrorInterval> overlapping) { long minFrom = multiErrorInterval.from(); long maxTo = multiErrorInterval.to(); ListMultimap<String, ErrorInterval> errorIntervals = ArrayListMultimap.create(); errorIntervals.putAll(syntheticMonitorId, multiErrorInterval.errorIntervals()); for (GroupedMultiErrorInterval groupedMultiErrorInterval : overlapping) { minFrom = Math.min(minFrom, groupedMultiErrorInterval.from()); maxTo = Math.max(maxTo, groupedMultiErrorInterval.to()); for (Map.Entry<String, List<ErrorInterval>> entry : groupedMultiErrorInterval.errorIntervals() .entrySet()) {/*from w ww . j a v a2 s . c o m*/ errorIntervals.putAll(entry.getKey(), entry.getValue()); } } return ImmutableGroupedMultiErrorInterval.builder().from(minFrom).to(maxTo) .putAllErrorIntervals(Multimaps.asMap(errorIntervals)).build(); }
From source file:com.palantir.atlasdb.schema.stream.StreamStoreDefinition.java
public Multimap<String, Supplier<OnCleanupTask>> getCleanupTasks(String packageName, String name, StreamStoreRenderer renderer) {// w w w . j av a 2s. co m Multimap<String, Supplier<OnCleanupTask>> cleanupTasks = ArrayListMultimap.create(); // We use reflection and wrap these in suppliers because these classes are generated classes that might not always exist. cleanupTasks.put(StreamTableType.METADATA.getTableName(shortName), new Supplier<OnCleanupTask>() { @Override public OnCleanupTask get() { try { Class<?> clazz = Class.forName(packageName + "." + renderer.getMetadataCleanupTaskClassName()); return (OnCleanupTask) clazz.getConstructor().newInstance(); } catch (Exception e) { throw Throwables.rewrapAndThrowUncheckedException(e); } } }); cleanupTasks.put(StreamTableType.INDEX.getTableName(shortName), new Supplier<OnCleanupTask>() { @Override public OnCleanupTask get() { try { Class<?> clazz = Class.forName(packageName + "." + renderer.getIndexCleanupTaskClassName()); return (OnCleanupTask) clazz.getConstructor().newInstance(); } catch (Exception e) { throw Throwables.rewrapAndThrowUncheckedException(e); } } }); return cleanupTasks; }