use of java.util.LinkedList in project jersey by jersey.
the class IntrospectionModeller method doCreateResourceBuilder.
private Resource.Builder doCreateResourceBuilder() {
if (!disableValidation) {
checkForNonPublicMethodIssues();
}
final Class<?> annotatedResourceClass = ModelHelper.getAnnotatedResourceClass(handlerClass);
final Path rPathAnnotation = annotatedResourceClass.getAnnotation(Path.class);
final boolean keepEncodedParams = (null != annotatedResourceClass.getAnnotation(Encoded.class));
final List<MediaType> defaultConsumedTypes = extractMediaTypes(annotatedResourceClass.getAnnotation(Consumes.class));
final List<MediaType> defaultProducedTypes = extractMediaTypes(annotatedResourceClass.getAnnotation(Produces.class));
final Collection<Class<? extends Annotation>> defaultNameBindings = ReflectionHelper.getAnnotationTypes(annotatedResourceClass, NameBinding.class);
final MethodList methodList = new MethodList(handlerClass);
final List<Parameter> resourceClassParameters = new LinkedList<>();
checkResourceClassSetters(methodList, keepEncodedParams, resourceClassParameters);
checkResourceClassFields(keepEncodedParams, InvocableValidator.isSingleton(handlerClass), resourceClassParameters);
Resource.Builder resourceBuilder;
if (null != rPathAnnotation) {
resourceBuilder = Resource.builder(rPathAnnotation.value());
} else {
resourceBuilder = Resource.builder();
}
boolean extended = false;
if (handlerClass.isAnnotationPresent(ExtendedResource.class)) {
resourceBuilder.extended(true);
extended = true;
}
resourceBuilder.name(handlerClass.getName());
addResourceMethods(resourceBuilder, methodList, resourceClassParameters, keepEncodedParams, defaultConsumedTypes, defaultProducedTypes, defaultNameBindings, extended);
addSubResourceMethods(resourceBuilder, methodList, resourceClassParameters, keepEncodedParams, defaultConsumedTypes, defaultProducedTypes, defaultNameBindings, extended);
addSubResourceLocators(resourceBuilder, methodList, resourceClassParameters, keepEncodedParams, extended);
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest(LocalizationMessages.NEW_AR_CREATED_BY_INTROSPECTION_MODELER(resourceBuilder.toString()));
}
return resourceBuilder;
}
use of java.util.LinkedList in project k-9 by k9mail.
the class MessagingController method refreshLocalMessageFlags.
private void refreshLocalMessageFlags(final Account account, final Folder remoteFolder, final LocalFolder localFolder, List<Message> syncFlagMessages, final AtomicInteger progress, final int todo) throws MessagingException {
final String folder = remoteFolder.getName();
if (remoteFolder.supportsFetchingFlags()) {
Timber.d("SYNC: About to sync flags for %d remote messages for folder %s", syncFlagMessages.size(), folder);
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.FLAGS);
List<Message> undeletedMessages = new LinkedList<>();
for (Message message : syncFlagMessages) {
if (!message.isSet(Flag.DELETED)) {
undeletedMessages.add(message);
}
}
remoteFolder.fetch(undeletedMessages, fp, null);
for (Message remoteMessage : syncFlagMessages) {
LocalMessage localMessage = localFolder.getMessage(remoteMessage.getUid());
boolean messageChanged = syncFlags(localMessage, remoteMessage);
if (messageChanged) {
boolean shouldBeNotifiedOf = false;
if (localMessage.isSet(Flag.DELETED) || isMessageSuppressed(localMessage)) {
for (MessagingListener l : getListeners()) {
l.synchronizeMailboxRemovedMessage(account, folder, localMessage);
}
} else {
if (shouldNotifyForMessage(account, localFolder, localMessage)) {
shouldBeNotifiedOf = true;
}
}
// we're only interested in messages that need removing
if (!shouldBeNotifiedOf) {
MessageReference messageReference = localMessage.makeMessageReference();
notificationController.removeNewMailNotification(account, messageReference);
}
}
progress.incrementAndGet();
for (MessagingListener l : getListeners()) {
l.synchronizeMailboxProgress(account, folder, progress.get(), todo);
}
}
}
}
use of java.util.LinkedList in project k-9 by k9mail.
the class MessagingController method refreshRemoteSynchronous.
@VisibleForTesting
void refreshRemoteSynchronous(final Account account, final MessagingListener listener) {
List<LocalFolder> localFolders = null;
try {
Store store = account.getRemoteStore();
List<? extends Folder> remoteFolders = store.getPersonalNamespaces(false);
LocalStore localStore = account.getLocalStore();
Set<String> remoteFolderNames = new HashSet<>();
List<LocalFolder> foldersToCreate = new LinkedList<>();
localFolders = localStore.getPersonalNamespaces(false);
Set<String> localFolderNames = new HashSet<>();
for (Folder localFolder : localFolders) {
localFolderNames.add(localFolder.getName());
}
for (Folder remoteFolder : remoteFolders) {
if (!localFolderNames.contains(remoteFolder.getName())) {
LocalFolder localFolder = localStore.getFolder(remoteFolder.getName());
foldersToCreate.add(localFolder);
}
remoteFolderNames.add(remoteFolder.getName());
}
localStore.createFolders(foldersToCreate, account.getDisplayCount());
localFolders = localStore.getPersonalNamespaces(false);
/*
* Clear out any folders that are no longer on the remote store.
*/
for (Folder localFolder : localFolders) {
String localFolderName = localFolder.getName();
// special placeholder folder "-NONE-".
if (K9.FOLDER_NONE.equals(localFolderName)) {
localFolder.delete(false);
}
if (!account.isSpecialFolder(localFolderName) && !remoteFolderNames.contains(localFolderName)) {
localFolder.delete(false);
}
}
localFolders = localStore.getPersonalNamespaces(false);
for (MessagingListener l : getListeners(listener)) {
l.listFolders(account, localFolders);
}
for (MessagingListener l : getListeners(listener)) {
l.listFoldersFinished(account);
}
} catch (Exception e) {
for (MessagingListener l : getListeners(listener)) {
l.listFoldersFailed(account, "");
}
addErrorMessage(account, null, e);
} finally {
if (localFolders != null) {
for (Folder localFolder : localFolders) {
closeFolder(localFolder);
}
}
}
}
use of java.util.LinkedList in project k-9 by k9mail.
the class MessagingController method groupMessagesByAccountAndFolder.
@NonNull
private Map<String, Map<String, List<MessageReference>>> groupMessagesByAccountAndFolder(List<MessageReference> messages) {
Map<String, Map<String, List<MessageReference>>> accountMap = new HashMap<>();
for (MessageReference message : messages) {
if (message == null) {
continue;
}
String accountUuid = message.getAccountUuid();
String folderName = message.getFolderName();
Map<String, List<MessageReference>> folderMap = accountMap.get(accountUuid);
if (folderMap == null) {
folderMap = new HashMap<>();
accountMap.put(accountUuid, folderMap);
}
List<MessageReference> messageList = folderMap.get(folderName);
if (messageList == null) {
messageList = new LinkedList<>();
folderMap.put(folderName, messageList);
}
messageList.add(message);
}
return accountMap;
}
use of java.util.LinkedList in project killbill by killbill.
the class UsageInvoiceItemGenerator method extractPerSubscriptionExistingInArrearUsageItems.
private Map<UUID, List<InvoiceItem>> extractPerSubscriptionExistingInArrearUsageItems(final Map<String, Usage> knownUsage, @Nullable final List<Invoice> existingInvoices) {
if (existingInvoices == null || existingInvoices.isEmpty()) {
return ImmutableMap.of();
}
final Map<UUID, List<InvoiceItem>> result = new HashMap<UUID, List<InvoiceItem>>();
final Iterable<InvoiceItem> usageInArrearItems = Iterables.concat(Iterables.transform(existingInvoices, new Function<Invoice, Iterable<InvoiceItem>>() {
@Override
public Iterable<InvoiceItem> apply(final Invoice input) {
return Iterables.filter(input.getInvoiceItems(), new Predicate<InvoiceItem>() {
@Override
public boolean apply(final InvoiceItem input) {
if (input.getInvoiceItemType() == InvoiceItemType.USAGE) {
final Usage usage = knownUsage.get(input.getUsageName());
return usage.getBillingMode() == BillingMode.IN_ARREAR;
}
return false;
}
});
}
}));
for (final InvoiceItem cur : usageInArrearItems) {
List<InvoiceItem> perSubscriptionUsageItems = result.get(cur.getSubscriptionId());
if (perSubscriptionUsageItems == null) {
perSubscriptionUsageItems = new LinkedList<InvoiceItem>();
result.put(cur.getSubscriptionId(), perSubscriptionUsageItems);
}
perSubscriptionUsageItems.add(cur);
}
return result;
}
Aggregations