/** * @return all the chunks in a single list */ public List<DiffChunk> getUnifiedChunks() { return CollectionUtil.copyAsImmutableList(chunks); }
/** * Does the supplied {@link Iterable} contain anything that matches the predicate? * * @param <T> the element type * @param iterable containing elements * @param predicate the matcher * @return true if the predicate returns true for any elements. */ public static <T> boolean contains(@Nonnull final Iterable<? extends T> iterable, @Nonnull final Predicate<T> predicate) { return contains(iterable.iterator(), predicate); }
/** * Return a List that is transformed from elements of the input type to elements of the output type by a transformer function. * * @param <T> the input type * @param <R> the out type * @param iterator to iterate over the contents * @param transformer the function that performs the transformation * @return an unmodifiable List of the transformed type */ public static <T, R> List<R> transform(@Nonnull final Iterator<? extends T> iterator, @Nonnull final Function<T, R> transformer) { return toList(transformIterator(iterator, transformer)); }
void setProjectsWithBrowsePermission(final ApplicationUser user, final Collection<GenericValue> projectsWithBrowsePermission) { //JRA-16757: Make an immutable copy of the returned list and return it. This will give a runtime exception anyone that is trying //to modify the list inline. final CacheKey cacheKey = new CacheKey(user); projectsWithBrowsePermissionForUser.put(cacheKey, CollectionUtil.copyAsImmutableList(projectsWithBrowsePermission)); projectObjectsWithBrowsePermissionForUser.put(cacheKey, CollectionUtil.transform(projectsWithBrowsePermission, gvToProjectTransformer)); }
public static List<ProjectOption> transform(final Iterable<? extends Project> projects) { return CollectionUtil.transform(projects, new Function<Project, ProjectOption>() { @Override public ProjectOption get(final Project input) { return new ProjectOption(input); } }); }
private List<KeyboardShortcut> getShortcuts(final KeyboardShortcutManager.Context context, final List<KeyboardShortcut> shortcuts) { return new ArrayList<KeyboardShortcut>(CollectionUtil.filter(shortcuts, new Predicate<KeyboardShortcut>() { public boolean evaluate(final KeyboardShortcut input) { return context.equals(input.getContext()); } })); }
public void foreach(final Consumer<Issue> sink) { CollectionUtil.foreach(new AbstractTransformIssueIterator<Long>(ids) { @Override protected Issue transform(final Long o) { return issueManager.getIssueObject(o); } }, sink); }
@Override @Nonnull public Collection<IssueSearcher<?>> getSearchersByClauseName(final ApplicationUser user, final String jqlClauseName) { notBlank("jqlClauseName", jqlClauseName); return toList(filter(transform(getHelper().getIssueSearcherRegistrationsByClauseName(jqlClauseName), new Function<SearcherRegistration, IssueSearcher<?>>() { @Override public IssueSearcher<?> get(final SearcherRegistration searcherRegistration) { return searcherRegistration.getIssueSearcher(); } }), Predicates.<IssueSearcher<?>>notNull())); }
/** * Turn the iterable into a list. * * @param <T> the element type * @param iterable to iterate over the elements * @return an unmodifiable {@link List} of the elements in the iterator */ public static <T> List<T> toList(@Nonnull final Iterable<? extends T> iterable) { return toList(iterable.iterator()); }
/** * This will try to find an acceptable setter method for given parameter name * * @param paramName the parameter name * @param setterDescriptors the setters for this action * @return a valid setter method or null if one can be found */ private Method getSetterForParameter(final String paramName, final PropertyDescriptor[] setterDescriptors) { // These have been sorted into a preferred order. We pick the first one matches and // only the first one only. There is no retry if their happens to be more than one! final PropertyDescriptor descriptor = findFirstMatch(asList(setterDescriptors), new Predicate<PropertyDescriptor>() { public boolean evaluate(final PropertyDescriptor input) { return paramName.equals(input.getName()); } }); return (descriptor == null) ? null : descriptor.getWriteMethod(); }
public FieldConfigSchemeImpl(final Long id, final String fieldId, final String name, final String description, final Map<String, FieldConfig> configs, final FieldConfigContextPersister configContextPersister) { this.id = id; this.fieldId = fieldId; this.name = StringUtils.abbreviate(name, FieldConfigPersister.ENTITY_LONG_TEXT_LENGTH); this.description = description; this.configs = (configs != null) ? CollectionUtil.copyAsImmutableMap(configs) : Collections.<String, FieldConfig> emptyMap(); this.configContextPersister = configContextPersister; }
int index = CollectionUtil.indexOf(issuesInPage, new Predicate<Issue>()
SelectedValues(Collection<String> selectedValues) { this.selectedValuesInLowerCase = CollectionUtil.transform(selectedValues, new Function<String, String>() { @Override public String get(String value) { return value.toLowerCase(); } }); }
/** * Does the supplied {@link Iterator} contain anything that matches the predicate? * * @param <T> the element type * @param iterator containing elements * @param predicate the matcher * @return true if the predicate returns true for any elements. */ public static <T> boolean contains(@Nonnull final Iterator<? extends T> iterator, @Nonnull final Predicate<T> predicate) { return filter(iterator, predicate).hasNext(); }
void setProjectObjectsWithBrowsePermission(final ApplicationUser user, final Collection<Project> projectsWithBrowsePermission) { //JRA-16757: Make an immutable copy of the returned list and return it. This will give a runtime exception anyone that is trying //to modify the list inline. final CacheKey cacheKey = new CacheKey(user); projectObjectsWithBrowsePermissionForUser.put(cacheKey, CollectionUtil.copyAsImmutableList(projectsWithBrowsePermission)); projectsWithBrowsePermissionForUser.put(cacheKey, CollectionUtil.transform(projectsWithBrowsePermission, projectToGVTransformer)); }
public final void foreach(final Consumer<Issue> sink) { CollectionUtil.foreach(new AbstractTransformIssueIterator<GenericValue>(issueGVs) { @Override protected Issue transform(final GenericValue o) { return issueFactory.getIssue(o); } }, sink); }
/** * Turn the enumeration into a list. * * @param <T> the element type * @param enumeration to enumerate over the elements * @return an unmodifiable {@link List} of the elements in the iterator */ public static <T> List<T> toList(@Nonnull final Enumeration<? extends T> enumeration) { return toList(fromEnumeration(enumeration)); }
public TaskDescriptor<?> findFirstTask(@Nonnull final TaskMatcher matcher) { return findFirstMatch(getTasks(taskMap), new TaskMatcherPredicate(matcher)); }