public Option getChild() { return this.options.second(); }
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="UG_SYNC_SET_UNSYNC_GET", justification="This is a valid unsynchronized getter") public CurrentApplication getCurrentApplication() { return cache.get().second(); }
@Override public boolean isSnapshot() { return parseVersion(getVersion()).second().toUpperCase().startsWith("-SNAPSHOT"); }
@Override public void doWith(final Method method) throws IllegalArgumentException, IllegalAccessException { Option<Pair<String, Object>> pair = invoke(targetObject, method); for (Pair<String, Object> tuple : pair) { Object value = tuple.second(); if (value instanceof Map) { //noinspection unchecked data.putAll((Map<String, Object>) value); } else { data.put(tuple.first(), value); } } } },
@Override public boolean isMilestone() { return parseVersion(getVersion()).second().toLowerCase().startsWith("-m"); }
@Override public boolean isRc() { return parseVersion(getVersion()).second().toLowerCase().startsWith("-rc"); }
@Override public boolean isBeta() { return parseVersion(getVersion()).second().toLowerCase().startsWith("-beta"); }
/** * Converts the usernames into User objects using the given function. * * @param watchers a Pair of watcher count and watcher usernames * @param function a Function used for conversion * @return a Pair of watcher count and User object */ protected <T extends ApplicationUser> Pair<Integer, List<T>> convertUsers(final Pair<Integer, List<String>> watchers, final Function<String, T> function) { return Pair.<Integer, List<T>>of( watchers.first(), copyOf(Iterables.transform(watchers.second(), function)) ); }
private Iterable<NotificationRecipient> getWatchersRecipients(ApplicationUser remoteUser, Issue issue) { return transform(watcherService.getWatchers(issue, remoteUser).getReturnedValue().second(), new UserToNotificationRecipientFunction()); }
public void registerWith(final ComponentContainer.Scope defaultScope, final ComponentContainer container) { Assertions.stateTrue("must implement some interfaces", !implementing.isEmpty()); //at first register under concrete implementation key with default adapter factory if(parameters.isEmpty()) container.implementation(ComponentContainer.Scope.INTERNAL, concrete, concrete); else container.implementation(ComponentContainer.Scope.INTERNAL, concrete, concrete, parameters.toArray(new Parameter[parameters.size()])); final ComponentAdapter adapter = container.getComponentAdapter(concrete); for (Pair<Class<? super T>, ComponentContainer.Scope> pair : implementing) { ComponentAdapter delegatingAdapter = new KeyedDelegateComponentAdapter<T>(pair.first(), adapter); container.component(pair.second() != null ? pair.second() : defaultScope, delegatingAdapter); } } }
@Override public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException { Pair<ServletRequest, ServletResponse> debugWrapped = wrap(servletRequest, servletResponse); super.doFilter(debugWrapped.first(), debugWrapped.second(), filterChain); }
@Override public void apply(final Pair<String, ErrorCollection.Reason> error) { errors.addError(nameFieldName, authenticationContext.getI18nHelper().getText(error.first()), error.second()); } });
@Override MigrationState migrate(MigrationState state, final boolean licenseSuppliedByUser) { final Set<Group> sdAgentGroups = globalPermissionDao.groupsWithSdAgentPermission(); final List<String> notMigratedGroups = new ArrayList<>(); for (Group sdAgentGroup : sdAgentGroups) { Pair<MigrationState, Boolean> result = checkGroupAndMigrate(sdAgentGroup, state); if (!result.second()) { notMigratedGroups.add(sdAgentGroup.getName()); } state = result.first(); } return state.withAfterSaveTask(() -> saveNotMigratedGroups(notMigratedGroups)); }
@Override public void apply(final Pair<String, ErrorCollection.Reason> error) { errors.addError(nameFieldName, authenticationContext.getI18nHelper().getText(error.first()), error.second()); } });
@Override public ServiceOutcome<List<ApplicationUser>> addWatcher(final Issue issue, final ApplicationUser remoteUser, final ApplicationUser watcher) throws WatchingDisabledException { Pair<Boolean, String> canWatchIssue = canWatchIssue(issue, remoteUser, watcher); if (canWatchIssue.first().booleanValue()) { watcherManager.startWatching(watcher, issue); return ServiceOutcomeImpl.ok(getCurrentWatchersFor(issue)); } return ServiceOutcomeImpl.error(canWatchIssue.second()); }
@Override public ServiceOutcome<List<ApplicationUser>> removeWatcher(final Issue issue, final ApplicationUser remoteUser, final ApplicationUser watcher) throws WatchingDisabledException { Pair<Boolean, String> canUnwatchIssue = canUnwatchIssue(issue, remoteUser, watcher); if (canUnwatchIssue.first().booleanValue()) { watcherManager.stopWatching(watcher, issue); return ServiceOutcomeImpl.ok(getCurrentWatchersFor(issue)); } return ServiceOutcomeImpl.error(canUnwatchIssue.second()); }
private WatchersBean buildBean(final Issue issue, final ApplicationUser callingUser) { try { Pair<Integer, List<ApplicationUser>> watcherCountList = watcherService.getWatchers(issue, callingUser).get(); List<UserJsonBean> watcherUserBeans = transform(watcherCountList.second(), toJson(callingUser)); log.trace("Visible watchers on issue '{}': {}", issue.getKey(), watcherUserBeans); return WatchersBean.Builder.create() .self(selfLink(issue)) .isWatching(watcherCountList.second().contains(callingUser)) .watchers(watcherUserBeans) .watchCount(watcherCountList.first()) .build(); } catch (WatchingDisabledException e) { return null; // don't report any watcher info } }
private Option<ErrorCollection> validateName(final String name, final Option<IssueType> issueTypeToUpdate) { final Option<Pair<String, ErrorCollection.Reason>> nameValidation = constantsManager.validateName(name, issueTypeToUpdate); if (nameValidation.isDefined()) { return errorCollection("name", nameValidation.get().first(), nameValidation.get().second()); } return none(); }
@Override public Unit get(final AttachmentGetData attachmentGetData) { final Pair<InputStream, Effect<Object>> streamWithCloseHandler = resendingAttachmentStreamCreator .getInputStreamWithCloseHandler(attachmentGetData); final Effect<Object> cleanup = streamWithCloseHandler.second(); try { final StoreAttachmentBean storeAttachmentBean = new StoreAttachmentBean.Builder(streamWithCloseHandler.first()) .withSize(attachmentGetData.getSize()) .withKey(attachmentKey) .build(); store.putAttachment(storeAttachmentBean) .then(getFutureCallbackFromEffect(cleanup)); return Unit.VALUE; } catch (final RuntimeException e) { cleanup.apply(Unit.VALUE); throw e; } }
public ApplicationPropertiesServiceImpl(ApplicationPropertiesStore applicationPropertiesStore, EventPublisher eventPublisher, PermissionManager permissionManager, JiraAuthenticationContext authenticationContext, FeatureManager featureManager) { this.applicationPropertiesStore = applicationPropertiesStore; this.eventPublisher = eventPublisher; this.permissionManager = permissionManager; this.authenticationContext = authenticationContext; this.featureManager = featureManager; this.featurePredicate = input -> { if (input.getMetadata().getRequiredFeatureKey() == null) { return true; } if (input.getMetadata().getRequiredFeatureKey().second()) { return ApplicationPropertiesServiceImpl.this.featureManager.isEnabled(input.getMetadata().getRequiredFeatureKey().first()); } else { return !ApplicationPropertiesServiceImpl.this.featureManager.isEnabled(input.getMetadata().getRequiredFeatureKey().first()); } }; }