当前位置: 首页>>代码示例>>Java>>正文


Java MultiValuedMap类代码示例

本文整理汇总了Java中org.apache.commons.collections4.MultiValuedMap的典型用法代码示例。如果您正苦于以下问题:Java MultiValuedMap类的具体用法?Java MultiValuedMap怎么用?Java MultiValuedMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MultiValuedMap类属于org.apache.commons.collections4包,在下文中一共展示了MultiValuedMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
public static void main(String[] args)
{
   MultiValuedMap<String, String> map = new ArrayListValuedHashMap<>();

   map.put("one", "A");
   System.out.println(map);

   map.putAll("one", Arrays.asList("B", "C"));
   System.out.println(map);

   map.put("one", "D");
   System.out.println(map);

   map.putAll("two", Arrays.asList("1", "2", "3"));
   System.out.println(map);

   System.out.printf("The value of the one key: %s\n", map.get("one"));
}
 
开发者ID:developerSid,项目名称:AwesomeJavaLibraryExamples,代码行数:19,代码来源:ExampleMultiValueMap.java

示例2: getInstance

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
public static BodyActivityProvider getInstance(BodyActivityType type, MultiValuedMap<Integer, Integer> bodyToLiterals, Map<Integer, Double> activityCounters,
		double defaultActivity) {
	switch (type) {
	case DEFAULT:
		return new DefaultBodyActivityProvider(bodyToLiterals, activityCounters, defaultActivity);
	case SUM:
		return new SumBodyActivityProvider(bodyToLiterals, activityCounters, defaultActivity);
	case AVG:
		return new AvgBodyActivityProvider(bodyToLiterals, activityCounters, defaultActivity);
	case MAX:
		return new MaxBodyActivityProvider(bodyToLiterals, activityCounters, defaultActivity);
	case MIN:
		return new MinBodyActivityProvider(bodyToLiterals, activityCounters, defaultActivity);
	default:
		throw new IllegalArgumentException("Unknown body activity type requested.");
	}
}
 
开发者ID:alpha-asp,项目名称:Alpha,代码行数:18,代码来源:BodyActivityProviderFactory.java

示例3: instantiateInstantiators

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
private static List<AbstractObjectInstantiator> instantiateInstantiators(final Class<?> clazz,
                                                                         final MultiValuedMap<Class<?>, ConstructorParameters> constructorParameters) {
    final List<AbstractObjectInstantiator> instantiators = new ArrayList<>();
    try {
        for (final Class<? extends AbstractObjectInstantiator> instantiator : INSTANTIATORS) {
            final Constructor<? extends AbstractObjectInstantiator> constructor =
                    instantiator.getDeclaredConstructor(Class.class, MultiValuedMap.class);
            constructor.setAccessible(true);
            final AbstractObjectInstantiator abstractObjectInstantiator = constructor.newInstance(clazz,
                                                                                                  constructorParameters);
            instantiators.add(abstractObjectInstantiator);
        }
    } catch (final Exception e) {
        throw new RuntimeException("Cannot load instantiators form pl.pojo.tester.internal.instantiator package.",
                                   e);
    }
    return instantiators;
}
 
开发者ID:sta-szek,项目名称:pojo-tester,代码行数:19,代码来源:Instantiable.java

示例4: Should_Use_User_Constructor_Parameters

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
@Test
void Should_Use_User_Constructor_Parameters() {
    // given
    final Class[] classesToTest = { ClassWithSyntheticConstructor.class };

    final ConstructorParameters parameters = new ConstructorParameters(new Object[]{ "string" },
                                                                       new Class[]{ String.class });
    final MultiValuedMap<Class<?>, ConstructorParameters> constructorParameters = spy(new ArrayListValuedHashMap<>());
    constructorParameters.put(ClassWithSyntheticConstructor.class, parameters);

    final ConstructorTester constructorTester = new ConstructorTester();
    constructorTester.setUserDefinedConstructors(constructorParameters);

    // when
    final Throwable result = catchThrowable(() -> constructorTester.testAll(classesToTest));

    // then
    assertThat(result).isNull();
    verify(constructorParameters).get(ClassWithSyntheticConstructor.class);
}
 
开发者ID:sta-szek,项目名称:pojo-tester,代码行数:21,代码来源:ConstructorTesterTest.java

示例5: Should_Create_Constructor_Parameters_When_Parameters_Are_Not_Provided

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
@Test
void Should_Create_Constructor_Parameters_When_Parameters_Are_Not_Provided() {
    // given
    final Class[] classesToTest = { ClassWithSyntheticConstructor.class };

    final MultiValuedMap<Class<?>, ConstructorParameters> constructorParameters = spy(new ArrayListValuedHashMap<>());

    final ConstructorTester constructorTester = new ConstructorTester();
    constructorTester.setUserDefinedConstructors(constructorParameters);

    // when
    final Throwable result = catchThrowable(() -> constructorTester.testAll(classesToTest));

    // then
    assertThat(result).isNull();
    verify(constructorParameters, never()).get(ClassWithSyntheticConstructor.class);
}
 
开发者ID:sta-szek,项目名称:pojo-tester,代码行数:18,代码来源:ConstructorTesterTest.java

示例6: Should_Create_Constructor_Parameters_When_Could_Not_Find_Matching_Constructor_Parameters_Types

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
@Test
void Should_Create_Constructor_Parameters_When_Could_Not_Find_Matching_Constructor_Parameters_Types() {
    // given
    final Class[] classesToTest = { ClassWithSyntheticConstructor.class };

    final ConstructorParameters parameters = spy(new ConstructorParameters(new Object[]{ "to",
            "many",
            "parameters" },
                                                                           new Class[]{ String.class,
                                                                                   String.class,
                                                                                   String.class }));
    final MultiValuedMap<Class<?>, ConstructorParameters> constructorParameters = spy(new ArrayListValuedHashMap<>());
    constructorParameters.put(ClassWithSyntheticConstructor.class, parameters);

    final ConstructorTester constructorTester = new ConstructorTester();
    constructorTester.setUserDefinedConstructors(constructorParameters);

    // when
    final Throwable result = catchThrowable(() -> constructorTester.testAll(classesToTest));

    // then
    assertThat(result).isNull();
    verify(parameters, never()).getParameters();
}
 
开发者ID:sta-szek,项目名称:pojo-tester,代码行数:25,代码来源:ConstructorTesterTest.java

示例7: createPropertyProviders

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
/**
 * Return a map that associates each value property with the set of bindings that provide it.
 */
private MultiValuedMap<String,VarBindingDef> createPropertyProviders( FunctionInputDef inputDef)
  {
  propertyProviders_ = MultiMapUtils.newListValuedHashMap();
  for( VarDefIterator varDefs = new VarDefIterator( inputDef.getVarDefs()); varDefs.hasNext(); )
    {
    VarDef varDef = varDefs.next();
    for( Iterator<VarValueDef> values = varDef.getValidValues(); values.hasNext(); )
      {
      VarValueDef value = values.next();
      if( !value.getProperties().isEmpty())
        {
        VarBindingDef binding = new VarBindingDef( varDef, value);
        for( Iterator<String> properties = value.getProperties().getProperties(); properties.hasNext(); )
          {
          propertyProviders_.put( properties.next(), binding);
          }
        }
      }
    }

  return propertyProviders_;
  }
 
开发者ID:Cornutum,项目名称:tcases,代码行数:26,代码来源:TupleGenerator.java

示例8: processMqscFiles

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
private void processMqscFiles(XMLConfiguration config, List<File> mqscFiles, String releaseFolder) {
	
	if(CollectionUtils.isNotEmpty(mqscFiles)){
		List<ConfigurationNode> allMQSCEnvironments = config.getRootNode().getChildren();
		if(CollectionUtils.isNotEmpty(allMQSCEnvironments)){
			MultiValuedMap<String,String> allMQSCForEnvironment = new ArrayListValuedHashMap<>();
			
			processMQSCForAllEnvironments(config, mqscFiles,
					allMQSCEnvironments, allMQSCForEnvironment);
			
			for(String key: allMQSCForEnvironment.keySet()){
				List<String> mqscContentList = (List<String>)allMQSCForEnvironment.get(key);
				generateMQSCContent(config, mqscContentList, key, releaseFolder);
			}
		}
	}
}
 
开发者ID:anair-it,项目名称:wmq-mqsc-mojo,代码行数:18,代码来源:MqscMojo.java

示例9: processMQSCForAllEnvironments

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
private void processMQSCForAllEnvironments(XMLConfiguration config,
		List<File> allMqscFiles,
		List<ConfigurationNode> allMQSCEnvironments,
		MultiValuedMap<String,String> allMQSCForEnvironment) {
	for(ConfigurationNode rootConfigNode: allMQSCEnvironments){
		String environment = rootConfigNode.getName();
		
		for(File mqscFile: allMqscFiles){
			try {
				String originalfileContent = FileUtils.readFileToString(mqscFile, Charset.defaultCharset());
				allMQSCForEnvironment.put(environment, originalfileContent);
			} catch (IOException e) {
				LOG.error(e.getMessage(), e);
			}
		}
	}
}
 
开发者ID:anair-it,项目名称:wmq-mqsc-mojo,代码行数:18,代码来源:MqscMojo.java

示例10: parseBody

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
public static RequestBody parseBody(byte[] body, RequestHeader header) {
    if (body.length == 0) {
        return new RequestBody();
    }
    String contentType = header.getContentType();
    Map<String, MimeData> mimeMap = Collections.emptyMap();
    MultiValuedMap<String, String> formMap = new ArrayListValuedHashMap<>();
    if (contentType.contains("application/x-www-form-urlencoded")) {
        try {
            String bodyMsg = new String(body, "utf-8");
            RequestParser.parseParameters(bodyMsg, formMap);
        } catch (UnsupportedEncodingException ignored) {
        }
    } else if (contentType.contains("multipart/form-data")) {
        int boundaryValueIndex = contentType.indexOf("boundary=");
        String bouStr = contentType.substring(boundaryValueIndex + 9); // 9是 `boundary=` 长度
        mimeMap = parseFormData(body, bouStr);
    }
    RequestBody requestBody = new RequestBody();
    requestBody.setFormMap(formMap);
    requestBody.setMimeMap(mimeMap);
    return requestBody;
}
 
开发者ID:csdbianhua,项目名称:Telemarketer,代码行数:24,代码来源:RequestParser.java

示例11: cardsBySuit

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
@Test
public void cardsBySuit()
{
    Map<Suit, SortedSet<Card>> jdkCardsBySuit = this.jdkDeck.getCardsBySuit();
    MultiValuedMap<Suit, Card> acCardsBySuit = this.acDeck.getCardsBySuit();
    Assert.assertEquals(jdkCardsBySuit.get(Suit.CLUBS), new TreeSet<>(acCardsBySuit.get(Suit.CLUBS)));
}
 
开发者ID:BNYMellon,项目名称:CodeKatas,代码行数:8,代码来源:ApacheCommonsDeckOfCardsAsSortedSetTest.java

示例12: cardsBySuit

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
@Test
public void cardsBySuit()
{
    Map<Suit, List<Card>> jdkCardsBySuit = this.jdkDeck.getCardsBySuit();
    MultiValuedMap<Suit, Card> acCardsBySuit = this.acDeck.getCardsBySuit();
    Assert.assertEquals(jdkCardsBySuit.get(Suit.CLUBS), new ArrayList<>(acCardsBySuit.get(Suit.CLUBS)));
}
 
开发者ID:BNYMellon,项目名称:CodeKatas,代码行数:8,代码来源:ApacheCommonsDeckOfCardsAsListTest.java

示例13: equals

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj instanceof MultiValuedMap) {
        return asMap().equals(((MultiValuedMap<?, ?>) obj).asMap());
    }
    return false;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:11,代码来源:AbstractMultiValuedMap.java

示例14: putAll

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
@Override
public boolean putAll(final MultiValuedMap<? extends K, ? extends V> map) {
    if (map == null) {
        throw new NullPointerException("Map must not be null.");
    }
    boolean changed = false;
    for (Map.Entry<? extends K, ? extends V> entry : map.entries()) {
        changed |= put(entry.getKey(), entry.getValue());
    }
    return changed;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:12,代码来源:TransformedMultiValuedMap.java

示例15: AbstractMultiValuedMapDecorator

import org.apache.commons.collections4.MultiValuedMap; //导入依赖的package包/类
/**
 * Constructor that wraps (not copies).
 *
 * @param map  the map to decorate, must not be null
 * @throws NullPointerException if the map is null
 */
protected AbstractMultiValuedMapDecorator(final MultiValuedMap<K, V> map) {
    if (map == null) {
        throw new NullPointerException("MultiValuedMap must not be null.");
    }
    this.map = map;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:13,代码来源:AbstractMultiValuedMapDecorator.java


注:本文中的org.apache.commons.collections4.MultiValuedMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。