/** * Adds a new pair to this list with the given key and value * * @param key the key to add; can be <code>null</code> * @param value the value to add; can be <code>null</code> * @return true (as specified by Collection.add(E)) */ public boolean add(final K key, final V value) { return add(new MutablePair<K, V>(key, value)); }
/** * Returns the given array of pairs as a modifiable list. * * @param <K> the type of key * @param <V> the type of value * @param pairs the pairs to put in a list * @return a non-<code>null</code> list */ public PairList(final MutablePair<K, V>... pairs) { addAll(Arrays.asList(pairs)); }
@SuppressWarnings("unchecked") @Override public MutablePair<K, V>[] toArray() { return super.toArray(new MutablePair[size()]); } }
public MemberTypeAdditions getMemberTypeAdditions(final String callerMID, final String methodIdentifier, final JavaType targetEntity, final JavaType idType, boolean autowire, final MethodParameter... callerParameters) { Validate.isTrue(StringUtils.isNotBlank(callerMID), "Caller's metadata ID required"); Validate.notBlank(methodIdentifier, "Method identifier required"); Validate.notNull(targetEntity, "Target enitity type required"); Validate.notNull(idType, "Enitity Id type required"); // Look for a repository layer method with this ID and parameter types final List<JavaType> parameterTypes = new PairList<JavaType, JavaSymbolName>(callerParameters).getKeys(); final RepositoryJpaLayerMethod method = RepositoryJpaLayerMethod.valueOf(methodIdentifier, parameterTypes, targetEntity, idType); if (method == null) { return null; } // Look for repositories that support this domain type final Collection<ClassOrInterfaceTypeDetails> repositories = repositoryLocator.getRepositories(targetEntity); if (CollectionUtils.isEmpty(repositories)) { return null; } // Use the first such repository (could refine this later) final ClassOrInterfaceTypeDetails repository = repositories.iterator().next(); // Return the additions the caller needs to make return getMethodAdditions(callerMID, method, repository.getName(), Arrays.asList(callerParameters)); }
public MemberTypeAdditions getMemberTypeAdditions(final String callerMID, final String methodIdentifier, final JavaType targetEntity, final JavaType idType, boolean autowire, final MethodParameter... callerParameters) { Validate.isTrue(StringUtils.isNotBlank(callerMID), "Caller's metadata ID required"); Validate.notBlank(methodIdentifier, "Method identifier required"); Validate.notNull(targetEntity, "Target enitity type required"); Validate.notNull(idType, "Enitity Id type required"); // Look for a repository layer method with this ID and parameter types final List<JavaType> parameterTypes = new PairList<JavaType, JavaSymbolName>(callerParameters).getKeys(); final RepositoryJpaLayerMethod method = RepositoryJpaLayerMethod.valueOf(methodIdentifier, parameterTypes, targetEntity, idType); if (method == null) { return null; } // Look for repositories that support this domain type final Collection<ClassOrInterfaceTypeDetails> repositories = repositoryLocator.getRepositories(targetEntity); if (CollectionUtils.isEmpty(repositories)) { return null; } // Use the first such repository (could refine this later) final ClassOrInterfaceTypeDetails repository = repositories.iterator().next(); // Return the additions the caller needs to make return getMethodAdditions(callerMID, method, repository.getName(), Arrays.asList(callerParameters)); }
/** * Constructor for building a list of the given key-value pairs * * @param keys the keys (can be null) * @param values the values (must be null if the keys are null, otherwise * must be non-null and of the same size as the keys) */ public PairList(final List<? extends K> keys, final List<? extends V> values) { Validate.isTrue(!(keys == null ^ values == null), "Parameter types and names must either both be null or both be not null"); if (keys == null) { Validate.isTrue(values == null, "Parameter names must be null if types are null"); } else { Validate.isTrue(values != null, "Parameter names are required if types are provided"); Validate.isTrue(keys.size() == values.size(), "Expected %d values but found %d", keys.size(), values.size()); for (int i = 0; i < keys.size(); i++) { add(keys.get(i), values.get(i)); } } }