private Iterable<JqlAlias> createAliases(final Iterable<KeyConfigurationWrapper> indexConfigurations) { final Iterable<Iterable<Option<JqlAlias>>> aliases = transform(indexConfigurations, new Function<KeyConfigurationWrapper, Iterable<Option<JqlAlias>>>() { @Override public Iterable<Option<JqlAlias>> apply(final KeyConfigurationWrapper keyConfigurationWrapper) { return transform(keyConfigurationWrapper.getKeyConfiguration().getExtractorConfigurations(), new Function<ExtractConfiguration, Option<JqlAlias>>() { @Override public Option<JqlAlias> apply(final ExtractConfiguration extractConfiguration) { return extractConfiguration.getAlias().map(new Function<String, JqlAlias>() { @Override public JqlAlias apply(final String alias) { return jqlAliasFactory.createAlias(keyConfigurationWrapper.pluginKey, keyConfigurationWrapper.getKeyConfiguration().getPropertyKey(), extractConfiguration, alias); } }); } }); } }); return flatten(concat(aliases)); }
@Nonnull @Override public Iterable<E> getAll() { final Function<K, Option<E>> getAllAsOptionsF = new Function<K, Option<E>>() { @Override public Option<E> apply(K key) { return get(key); } }; final Function<Option<E>, E> getAllF = new Function<Option<E>, E>() { @Override public E apply(Option<E> input) { return input.get(); } }; return ImmutableList.copyOf(transform(Options.filterNone(transform(getKeys(), getAllAsOptionsF)), getAllF)); }
final Function<Either<Failure, Option<A>>, Promise<A>> fold = fold(failure, result); return getBlobStore() .get(attachmentId, FOREVER_CACHE, Options.lift(compose(toGoogleFunction(attachmentGetDataProcessor), dataFromResult))) .flatMap(fold);
private Iterable<ContextParametersValidator<T>> getValidatorsFromPlugins() { final Collection<ConnectContextParameterResolverModuleDescriptor.ConnectContextParametersResolver> modules = pluginAccessor.getModules(new ModuleDescriptorOfClassPredicate<>(ConnectContextParameterResolverModuleDescriptor.class)); Iterable<ContextParametersValidator> validators = concat(transform(modules, ConnectContextParameterResolverModuleDescriptor.ConnectContextParametersResolver::getValidators)); return Options.flatten(transform(validators, AbstractModuleContextFilter.this::tryCast)); }
private String renderCommentFields(final DescriptorToHtmlFunction descriptorToHtmlFunction, final CommentHelper commentHelper) { Iterable<CommentFieldRendererModuleDescriptor> descriptors = pluginAccessor.getEnabledModuleDescriptorsByClass(CommentFieldRendererModuleDescriptor.class); List<CommentFieldRendererModuleDescriptor> descriptorsOrderedByWeight = commentFieldRendererModuleDescriptorOrdering.sortedCopy(descriptors); // Complicated? Not really. We get all renders for which want to be displayed (according to the condition). // Then, transform all this to optional html (there might be no definition of field-view-resource, when we would get none). // Finally, pick the first non empty html. final Option<String> commentFieldToRender = getFirst(Options.filterNone(transform(filter(descriptorsOrderedByWeight, SafePluginPointAccess.safe(new Predicate<CommentFieldRendererModuleDescriptor>() { @Override public boolean apply(final CommentFieldRendererModuleDescriptor moduleDescriptor) { return moduleDescriptor.getCondition() == null || moduleDescriptor.getCondition().shouldDisplay(commentHelper.getContextParams()); } })), SafePluginPointAccess.safe(descriptorToHtmlFunction))), Option.<String>none()); return commentFieldToRender.getOrError(new Supplier<String>() { @Override public String get() { throw new IllegalStateException("There should be at least one comment field renderer, which can render the comments"); } }); }
private Iterable<ContextParametersValidator<T>> getValidatorsFromPlugins() { Iterable<ContextParametersValidator> validators = Iterables.concat(Iterables.transform(pluginAccessor.getModules( new ModuleDescriptorOfClassPredicate<>(ConnectContextParameterResolverModuleDescriptor.class)), new Function<ConnectContextParameterResolverModuleDescriptor.ConnectContextParametersResolver, List<ContextParametersValidator>>() { @Override public List<ContextParametersValidator> apply(final ConnectContextParameterResolverModuleDescriptor.ConnectContextParametersResolver input) { return input.getValidators(); } })); return Options.flatten(Iterables.transform(validators, new Function<ContextParametersValidator, Option<ContextParametersValidator<T>>>() { @Override public Option<ContextParametersValidator<T>> apply(final ContextParametersValidator contextParametersValidator) { return tryCast(contextParametersValidator); } })); }
public List<EntityProperty> getCommentProperties() { // This is calculated in the getter for the reason. There is not a lot usages of comment properties, so it is better // to calculate this once this is needed. final ApplicationUser applicationUser = jiraAuthenticationContext.getUser(); Iterable<Option<EntityProperty>> propOptions = transform(commentPropertyService.getPropertiesKeys(applicationUser, comment.getId()).getKeys(), new Function<String, Option<EntityProperty>>() { @Override public Option<EntityProperty> apply(final String propertyKey) { return commentPropertyService.getProperty(applicationUser, comment.getId(), propertyKey).getEntityProperty(); } }); return Lists.newArrayList(Options.flatten(propOptions)); }
private ErrorCollection validateCreate(@Nonnull final IssueTypeCreateInput issueTypeCreateInput) { // noinspection unchecked final Iterable<ErrorCollection> errorCollections = Options.flatten(Lists.newArrayList( validateType(issueTypeCreateInput), validateName(issueTypeCreateInput.getName(), Option.<IssueType>none()) )); return buildAllErrors(errorCollections); }
public PermissionScheme permissionScheme(final Scheme scheme) { return new PermissionSchemeImpl( scheme.getId(), scheme.getName(), scheme.getDescription(), flatten(transform(scheme.getEntities(), new Function<SchemeEntity, Option<PermissionGrant>>() { @Override public Option<PermissionGrant> apply(final SchemeEntity input) { return permissionGrant(input); } }))); }
return Lists.newArrayList(Options.flatten(propertyBeans));