本文整理汇总了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"));
}
示例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.");
}
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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_;
}
示例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);
}
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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)));
}
示例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)));
}
示例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;
}
示例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;
}
示例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;
}