List of usage examples for org.apache.commons.collections4.keyvalue DefaultKeyValue DefaultKeyValue
public DefaultKeyValue(final K key, final V value)
From source file:be.bittich.dynaorm.core.StringQueryBuilder.java
/** * Return the request to get a row value mapped with the parameters * * @param <T>// ww w. j ava2s.com * @param t * @param fieldPrimary * @param dialect * @return * @throws RequestInvalidException */ public static <T> KeyValue<String, List<String>> conditionPrimaryKeysBuilder(T t, Map<Field, PrimaryKey> fieldPrimary, Dialect dialect) throws RequestInvalidException { boolean firstIteration = true; String req = ""; List<String> parameters = new LinkedList(); for (Field field : fieldPrimary.keySet()) { String label = "".equals(fieldPrimary.get(field).label()) ? field.getName() : fieldPrimary.get(field).label(); String value = AnnotationProcessor.getFieldValue(field.getName(), t); if (firstIteration) { req = dialect.where(req); firstIteration = false; } else { req = dialect.andWhere(req); } req = dialect.equalTo(req, label); parameters.add(value); } return new DefaultKeyValue(req, parameters); }
From source file:net.ctalkobt.syllogism.Context.java
/************************************************************************ * Defines a syllogism for a given equivalence type. * * @param memeKey/*w w w . ja v a 2 s .com*/ * @param equivalence * @param memeValue ***********************************************************************/ public void addSyllogism(Term memeKey, Copula equivalence, Term memeValue) { memeAssociations.put(memeKey, new DefaultKeyValue<>(equivalence, memeValue)); }
From source file:io.wcm.testing.mock.sling.servlet.MockSlingHttpServletResponse.java
@Override public void addHeader(final String name, final String value) { headers.add(new DefaultKeyValue<String, String>(name, value)); }
From source file:be.bittich.dynaorm.maping.BasicColumnMapping.java
/** * do the mapping/*from w ww.j a va 2 s. c o m*/ * * @throws java.lang.IllegalAccessException */ @Override public <T> KeyValue<List<String>, List<String>> getColumnsValuesMap(T t, TableColumn tableColumn) throws IllegalAccessException { Map<String, Field> mapFields = this.mapToSQLColumns(t, tableColumn); List<String> columnNames = new LinkedList(); List<String> values = new LinkedList(); for (String columnName : mapFields.keySet()) { try { Field field = mapFields.get(columnName); field.setAccessible(true); PrimaryKey annotationPK = field.getAnnotation(PrimaryKey.class); //we don't add generated values to the request if (annotationPK == null || !annotationPK.autoGenerated()) { MetaColumn metaColumn = field.getAnnotation(MetaColumn.class); if (metaColumn != null) { if (metaColumn.notNull() && field.get(t) == null) { throw new NullPointerException( String.format("Column %s should not be null!", columnName)); } } Object fieldVal = field.get(t); String valString = doFilterBeforeApplyToString(fieldVal); values.add(valString); columnNames.add(columnName); } } catch (IllegalArgumentException ex) { Logger.getLogger(BasicColumnMapping.class.getName()).log(Level.SEVERE, null, ex); } } return new DefaultKeyValue<List<String>, List<String>>(columnNames, values); }
From source file:io.wcm.testing.mock.sling.servlet.MockSlingHttpServletResponse.java
@Override public void addIntHeader(final String name, final int value) { headers.add(new DefaultKeyValue<String, String>(name, Integer.toString(value))); }
From source file:io.wcm.testing.mock.sling.servlet.MockSlingHttpServletResponse.java
@Override public void addDateHeader(final String name, final long date) { headers.add(new DefaultKeyValue<String, String>(name, formatDate(new Date(date)))); }
From source file:com.hubrick.vertx.s3.signature.AWS4SignatureBuilder.java
public AWS4SignatureBuilder canonicalQueryString(final String canonicalQueryString) { final String defaultString = StringUtils.defaultString(canonicalQueryString); // this way of parsing the query string is the only way to satisfy the // test-suite, therefore we do it with a matcher: final Matcher matcher = QUERY_STRING_MATCHING_PATTERN.matcher(defaultString); final List<KeyValue<String, String>> parameters = Lists.newLinkedList(); while (matcher.find()) { final String key = StringUtils.trim(matcher.group(1)); final String value = StringUtils.trim(matcher.group(2)); parameters.add(new DefaultKeyValue<>(key, value)); }/*from w ww .j a va 2s. com*/ this.canonicalQueryString = parameters.stream().sorted(Comparator.comparing(KeyValue::getKey)) .map(kv -> queryParameterEscape(kv.getKey()) + "=" + queryParameterEscape(kv.getValue())) .collect(Collectors.joining("&")); return this; }
From source file:com.thoughtworks.go.plugin.infra.FelixGoPluginOSGiFramework.java
@Override public <T extends GoPlugin> Map<String, List<String>> getExtensionsInfoFromThePlugin(String pluginId) { if (framework == null) { LOGGER.warn(//w ww . ja va 2 s. c om "[Plugin Framework] Plugins are not enabled, so cannot do an action on all implementations of {}", GoPlugin.class); return null; } final BundleContext bundleContext = framework.getBundleContext(); final Collection<ServiceReference<T>> serviceReferences = new HashSet<>( findServiceReferenceByPluginId((Class<T>) GoPlugin.class, pluginId, bundleContext)); ActionWithReturn<T, DefaultKeyValue<String, List<String>>> action = (goPlugin, descriptor) -> new DefaultKeyValue<>(goPlugin.pluginIdentifier().getExtension(), goPlugin.pluginIdentifier().getSupportedExtensionVersions()); return convertToMap(pluginId, serviceReferences.stream().map(serviceReference -> { T service = bundleContext.getService(serviceReference); return executeActionOnTheService(action, service, getDescriptorFor(serviceReference)); }).collect(toList())); }
From source file:org.kuali.coeus.sys.impl.service.SpringBeanConfigurationTest.java
/** * Apply a void function to each spring bean available in each spring context available from each spring resource loader. * * @param function the function to apply * @param ignoreCreationException whether to ignore exception that occurs when creating a bean *///from w ww .j a va 2 s. co m private void toEachSpringBean(VoidFunction function, boolean ignoreCreationException) { Map<QName, List<KeyValue<String, Exception>>> failedBeans = new HashMap<>(); for (SpringResourceLoader r : springResourceLoaders) { ApplicationContext context = r.getContext(); for (String name : context.getBeanDefinitionNames()) { if (process(name)) { try { function.r(context, name); } catch (BeanIsAbstractException e) { //ignore since the bean can't be created } catch (BeanCreationException e) { //if there is no way to ignore creation errors all tests will fail even if one bean is bad regardless of the type //we do want this type of failure to be tested by at least one test method but not all tests if (!ignoreCreationException) { LOG.error( "unable to create bean " + name + (context instanceof ConfigurableWebApplicationContext ? " for locations " + Arrays .asList(((ConfigurableWebApplicationContext) context) .getConfigLocations()) : ""), e); throw e; } } catch (RuntimeException e) { LOG.error("failed to execute function for bean " + name + (context instanceof ConfigurableWebApplicationContext ? " for locations " + Arrays.asList( ((ConfigurableWebApplicationContext) context).getConfigLocations()) : ""), e); List<KeyValue<String, Exception>> rlFailures = failedBeans.get(r.getName()); if (rlFailures == null) { rlFailures = new ArrayList<>(); } rlFailures.add(new DefaultKeyValue<String, Exception>(name, e)); failedBeans.put(r.getName(), rlFailures); } } } } Assert.assertTrue("the following beans failed to retrieve " + failedBeans, failedBeans.isEmpty()); }