Example usage for org.apache.commons.lang ArrayUtils isEmpty

List of usage examples for org.apache.commons.lang ArrayUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils isEmpty.

Prototype

public static boolean isEmpty(boolean[] array) 

Source Link

Document

Checks if an array of primitive booleans is empty or null.

Usage

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public boolean getOpenNttaTollInvExists() {
    if (!ArrayUtils.isEmpty(nttaTollInvs)) {
        for (int i = 0; i < nttaTollInvs.length; i++) {
            if ("N".equals(nttaTollInvs[i].getPaidIndicator())) {
                return true;
            }//w  w  w .  j  ava 2s  .c  o m
        }
    }
    return false;
}

From source file:com.baidu.rigel.biplatform.tesseract.isservice.index.service.impl.IndexServiceImpl.java

@Override
public void updateIndexByDataSourceKey(String dataSourceKey, String[] factTableNames,
        Map<String, Map<String, BigDecimal>> dataSetMap) throws IndexAndSearchException {

    LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_BEGIN, "updateIndexByDataSourceKey",
            dataSourceKey));//from   www.j a v  a2s  .c  o  m
    if (StringUtils.isEmpty(dataSourceKey)) {
        LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION,
                "updateIndexByDataSourceKey", dataSourceKey));
        throw new IllegalArgumentException();
    }

    List<IndexMeta> metaList = new ArrayList<IndexMeta>();
    IndexAction idxAction = IndexAction.INDEX_UPDATE;

    if (MapUtils.isEmpty(dataSetMap)) {
        if (!ArrayUtils.isEmpty(factTableNames)) {
            for (String factTableName : factTableNames) {
                List<IndexMeta> fTableMetaList = this.indexMetaService
                        .getIndexMetasByFactTableName(factTableName, dataSourceKey);
                if (!CollectionUtils.isEmpty(fTableMetaList)) {
                    metaList.addAll(fTableMetaList);
                } else {
                    LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_PROCESS,
                            "updateIndexByDataSourceKey", dataSourceKey,
                            "can not find IndexMeta for Facttable:[" + factTableNames + "]"));
                }
            }
        } else {
            metaList = this.indexMetaService.getIndexMetasByDataSourceKey(dataSourceKey);
        }
    } else {
        idxAction = IndexAction.INDEX_MOD;
        for (String factTableName : dataSetMap.keySet()) {
            List<IndexMeta> fTableMetaList = this.indexMetaService.getIndexMetasByFactTableName(factTableName,
                    dataSourceKey);
            if (!CollectionUtils.isEmpty(fTableMetaList)) {
                metaList.addAll(fTableMetaList);
            }
        }

    }

    for (IndexMeta meta : metaList) {
        Map<String, BigDecimal> tableDataSetMap = null;
        if (!MapUtils.isEmpty(dataSetMap)) {
            tableDataSetMap = dataSetMap.get(meta.getFacttableName());
        }
        try {
            doIndexByIndexAction(meta, idxAction, tableDataSetMap);
        } catch (Exception e) {
            LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION,
                    "updateIndexByDataSourceKey", "DataSourceKey:[" + dataSourceKey + "] FactTable:["
                            + meta.getFacttableName() + "] IndexMetaId:[" + meta.getIndexMetaId() + "]"));
            String message = TesseractExceptionUtils.getExceptionMessage(
                    IndexAndSearchException.INDEXEXCEPTION_MESSAGE,
                    IndexAndSearchExceptionType.INDEX_EXCEPTION);
            throw new IndexAndSearchException(message, e.getCause(),
                    IndexAndSearchExceptionType.INDEX_EXCEPTION);
        }
    }
    try {
        publishIndexUpdateEvent(metaList);
    } catch (Exception e) {
        LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION,
                "updateIndexByDataSourceKey", dataSourceKey));
        String message = TesseractExceptionUtils.getExceptionMessage(
                IndexAndSearchException.INDEXEXCEPTION_MESSAGE,
                IndexAndSearchExceptionType.INDEX_UPDATE_EXCEPTION);
        throw new IndexAndSearchException(message, e.getCause(), IndexAndSearchExceptionType.INDEX_EXCEPTION);
    }

    LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_END, "updateIndexByDataSourceKey",
            dataSourceKey));
}

From source file:com.dianping.wed.cache.redis.biz.WeddingRedisServiceImpl.java

@Override
public long sRem(WeddingRedisKeyDTO redisKey, final String... members) {
    if (ArrayUtils.isEmpty(members)) {
        return -1;
    }//from w w w  .jav  a 2s. com
    final String finalKey = wcsWeddingRedisKeyCfgService.generateKey(redisKey);
    return JedisHelper.doJedisOperation(new JedisCallback<Long>() {
        @Override
        public Long doWithJedis(Jedis jedis) {
            return jedis.srem(finalKey, members);
        }
    }, finalKey, RedisActionType.WRITE);
}

From source file:com.photon.phresco.framework.impl.ProjectManagerImpl.java

public List<ProjectInfo> discoverFromRootModule(String rootModule) throws PhrescoException {
    if (isDebugEnabled) {
        S_LOGGER.debug("Entering Method ProjectManagerImpl.discover()");
    }/*from   w  ww. j av  a  2 s .  c o  m*/

    File projectsHome = new File(Utility.getProjectHome());
    if (isDebugEnabled) {
        S_LOGGER.debug("discover( )  projectHome = " + projectsHome);
    }
    File rootModuleFolder = new File(projectsHome + File.separator + rootModule);
    if (!projectsHome.exists() || !rootModuleFolder.exists()) {
        return null;
    }
    List<ProjectInfo> projectInfos = new ArrayList<ProjectInfo>();
    File[] appDirs = rootModuleFolder.listFiles();
    for (File appDir : appDirs) {
        if (appDir.isDirectory()) {
            File[] split_phresco = null;
            File[] split_src = null;
            File[] dotPhrescoFolders = null;
            dotPhrescoFolders = appDir.listFiles(new PhrescoFileNameFilter(FOLDER_DOT_PHRESCO));
            if (ArrayUtils.isEmpty(dotPhrescoFolders)) {
                File dotAppDir = new File(appDir + File.separator + appDir.getName() + SUFFIX_PHRESCO);
                split_phresco = dotAppDir.listFiles(new PhrescoFileNameFilter(FOLDER_DOT_PHRESCO));
                if (ArrayUtils.isEmpty(split_phresco)) {
                    File srcAppDir = new File(appDir + File.separator + appDir.getName());
                    split_src = srcAppDir.listFiles(new PhrescoFileNameFilter(FOLDER_DOT_PHRESCO));
                    if (ArrayUtils.isEmpty(split_src)) {
                        continue;
                    }
                }
            }

            if (!ArrayUtils.isEmpty(dotPhrescoFolders)) {
                File[] dotProjectFiles = dotPhrescoFolders[0]
                        .listFiles(new PhrescoFileNameFilter(PROJECT_INFO_FILE));
                if (!ArrayUtils.isEmpty(dotProjectFiles)) {
                    fillProjects(dotProjectFiles[0], projectInfos);
                }
            }
            if (!ArrayUtils.isEmpty(split_phresco)) {
                File[] splitDotProjectFiles = split_phresco[0]
                        .listFiles(new PhrescoFileNameFilter(PROJECT_INFO_FILE));
                if (!ArrayUtils.isEmpty(splitDotProjectFiles)) {
                    fillProjects(splitDotProjectFiles[0], projectInfos);
                }
            }
            if (!ArrayUtils.isEmpty(split_src)) {
                File[] splitSrcDotProjectFiles = split_src[0]
                        .listFiles(new PhrescoFileNameFilter(PROJECT_INFO_FILE));
                if (!ArrayUtils.isEmpty(splitSrcDotProjectFiles)) {
                    fillProjects(splitSrcDotProjectFiles[0], projectInfos);
                }
            }
        }
    }

    return projectInfos;
}

From source file:com.ning.maven.plugins.dependencyversionscheck.AbstractDependencyVersionsMojo.java

/**
 * Loads all resolver definitions and turns them into either direct resolved strategies or patterns to check against.
 *//*from   w w  w.  j  a  va 2 s.  c om*/
private void loadResolvers(final ResolverDefinition[] resolvers) {
    if (!ArrayUtils.isEmpty(resolvers)) {
        for (int i = 0; i < resolvers.length; i++) {
            ResolverDefinition r = resolvers[i];

            final Strategy strategy = strategyProvider.forName(r.getStrategyName());
            if (strategy == null) {
                LOG.warn("Could not locate Strategy {}! Check for typos!", r.getStrategyName());
            } else {
                final String[] includes = r.getIncludes();
                if (!ArrayUtils.isEmpty(includes)) {
                    for (int j = 0; j < includes.length; j++) {
                        final Strategy oldStrategy = (Strategy) resolverMap.get(includes[j]);
                        if (oldStrategy != null) {
                            LOG.warn("A strategy for {} was already defined: {}", includes[j],
                                    oldStrategy.getName());
                        }
                        if (includes[j].contains("*")) {
                            // Poor mans regexp escape. Escapes all "." and turns "*" into ".*". Should be good enough
                            // for most use cases. Pattern.quote() only adds \\Q and \\E to the string and does not metachar
                            // escaping, so it is useless.
                            final String pattern = includes[j].replace(".", "\\.").replace("*", ".*");
                            resolverPatternMap.put(pattern, strategy);
                        } else {
                            resolverMap.put(includes[j], strategy);
                        }
                    }
                }
            }
        }
    }
}

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public BigDecimal getNttaTollTotalUnPaidInvAmount() {
    BigDecimal amount = new BigDecimal(0.0);
    if (!ArrayUtils.isEmpty(nttaTollInvs)) {
        for (int i = 0; i < nttaTollInvs.length; i++) {
            if ("N".equals(nttaTollInvs[i].getPaidIndicator())) {
                amount = amount.add(nttaTollInvs[i].getAmount());

            }//from  w  w w.  j av  a2s . c  o m
        }
    }
    return amount;
}

From source file:com.hs.mail.mailet.RemoteDelivery.java

/**
 * We arranged that the recipients are all going to the same mail server. We
 * will now rely on the DNS server to do DNS MX record lookup and try to
 * deliver to the multiple mail servers. If it fails, we should decide that
 * the failure is permanent or temporary.
 * //  w w  w.j a va 2s . com
 * @param host
 *            the same host of recipients
 * @param recipients
 *            recipients who are all going to the same mail server
 * @param message
 *            Mail object to be delivered
 * @param mimemsg
 *            MIME message representation of the message
 * @return true if the delivery was successful or permanent failure so the
 *         message should be deleted, otherwise false and the message will
 *         be tried to send again later
 */
private boolean deliver(String host, Collection<Recipient> recipients, SmtpMessage message,
        MimeMessage mimemsg) {
    // Prepare javamail recipients
    InternetAddress[] addresses = new InternetAddress[recipients.size()];
    Iterator<Recipient> it = recipients.iterator();
    for (int i = 0; it.hasNext(); i++) {
        Recipient rcpt = it.next();
        addresses[i] = rcpt.toInternetAddress();
    }

    try {
        // Lookup the possible targets
        Iterator<HostAddress> targetServers = null;
        if (null == gateway) {
            targetServers = getSmtpHostAddresses(host);
        } else {
            targetServers = getGatewaySmtpHostAddresses(gateway);
        }
        if (!targetServers.hasNext()) {
            logger.info("No mail server found for: " + host);
            StringBuilder exceptionBuffer = new StringBuilder(128)
                    .append("There are no DNS entries for the hostname ").append(host)
                    .append(".  I cannot determine where to send this message.");
            return failMessage(message, addresses, new MessagingException(exceptionBuffer.toString()), false);
        }

        Properties props = session.getProperties();
        if (message.isNotificationMessage()) {
            props.put("mail.smtp.from", "<>");
        } else {
            props.put("mail.smtp.from", message.getFrom().getMailbox());
        }

        MessagingException lastError = null;
        StringBuilder logBuffer = null;
        HostAddress outgoingMailServer = null;
        while (targetServers.hasNext()) {
            try {
                outgoingMailServer = targetServers.next();
                logBuffer = new StringBuilder(256).append("Attempting to deliver message to host ")
                        .append(outgoingMailServer.getHostName()).append(" at ")
                        .append(outgoingMailServer.getHost()).append(" for addresses ")
                        .append(Arrays.asList(addresses));
                logger.info(logBuffer.toString());
                Transport transport = null;
                try {
                    transport = session.getTransport(outgoingMailServer);
                    try {
                        if (authUser != null) {
                            transport.connect(outgoingMailServer.getHostName(), authUser, authPass);
                        } else {
                            transport.connect();
                        }
                    } catch (MessagingException e) {
                        // Any error on connect should cause the mailet to
                        // attempt to connect to the next SMTP server
                        // associated with this MX record.
                        logger.error(e.getMessage());
                        continue;
                    }
                    transport.sendMessage(mimemsg, addresses);
                } finally {
                    if (transport != null) {
                        try {
                            transport.close();
                        } catch (MessagingException e) {
                        }
                        transport = null;
                    }
                }
                logBuffer = new StringBuilder(256).append("Successfully sent message to host ")
                        .append(outgoingMailServer.getHostName()).append(" at ")
                        .append(outgoingMailServer.getHost()).append(" for addresses ")
                        .append(Arrays.asList(addresses));
                logger.info(logBuffer.toString());
                recipients.clear();
                return true;
            } catch (SendFailedException sfe) {
                if (sfe.getValidSentAddresses() != null) {
                    Address[] validSent = sfe.getValidSentAddresses();
                    if (validSent.length > 0) {
                        logBuffer = new StringBuilder(256).append("Successfully sent message to host ")
                                .append(outgoingMailServer.getHostName()).append(" at ")
                                .append(outgoingMailServer.getHost()).append(" for addresses ")
                                .append(Arrays.asList(validSent));
                        logger.info(logBuffer.toString());
                        // Remove the addresses to which this message was
                        // sent successfully
                        List<InternetAddress> temp = new ArrayList<InternetAddress>();
                        for (int i = 0; i < addresses.length; i++) {
                            if (!ArrayUtils.contains(validSent, addresses[i])) {
                                if (addresses[i] != null) {
                                    temp.add(addresses[i]);
                                }
                            }
                        }
                        addresses = temp.toArray(new InternetAddress[temp.size()]);
                        removeAll(recipients, validSent);
                    }
                }

                if (sfe instanceof SMTPSendFailedException) {
                    SMTPSendFailedException ssfe = (SMTPSendFailedException) sfe;
                    // If permanent error 5xx, terminate this delivery
                    // attempt by re-throwing the exception
                    if (ssfe.getReturnCode() >= 500 && ssfe.getReturnCode() <= 599)
                        throw sfe;
                }

                if (!ArrayUtils.isEmpty(sfe.getValidUnsentAddresses())) {
                    // Valid addresses remained, so continue with any other server.
                    if (logger.isDebugEnabled())
                        logger.debug("Send failed, " + sfe.getValidUnsentAddresses().length
                                + " valid recipients(" + Arrays.asList(sfe.getValidUnsentAddresses())
                                + ") remain, continuing with any other servers");
                    lastError = sfe;
                    continue;
                } else {
                    // There are no valid addresses left to send, so re-throw
                    throw sfe;
                }
            } catch (MessagingException me) {
                Exception ne;
                if ((ne = me.getNextException()) != null && ne instanceof IOException) {
                    // It can be some socket or weird I/O related problem.
                    lastError = me;
                    continue;
                }
                throw me;
            }
        } // end while
        if (lastError != null) {
            throw lastError;
        }
    } catch (SendFailedException sfe) {
        boolean deleteMessage = false;

        if (sfe instanceof SMTPSendFailedException) {
            SMTPSendFailedException ssfe = (SMTPSendFailedException) sfe;
            deleteMessage = (ssfe.getReturnCode() >= 500 && ssfe.getReturnCode() <= 599);
        } else {
            // Sometimes we'll get a normal SendFailedException with nested
            // SMTPAddressFailedException, so use the latter RetCode
            MessagingException me = sfe;
            Exception ne;
            while ((ne = me.getNextException()) != null && ne instanceof MessagingException) {
                me = (MessagingException) ne;
                if (me instanceof SMTPAddressFailedException) {
                    SMTPAddressFailedException ssfe = (SMTPAddressFailedException) me;
                    deleteMessage = (ssfe.getReturnCode() >= 500 && ssfe.getReturnCode() <= 599);
                }
            }
        }
        if (!ArrayUtils.isEmpty(sfe.getInvalidAddresses())) {
            // Invalid addresses should be considered permanent
            Address[] invalid = sfe.getInvalidAddresses();
            removeAll(recipients, invalid);
            deleteMessage = failMessage(message, invalid, sfe, true);
        }
        if (!ArrayUtils.isEmpty(sfe.getValidUnsentAddresses())) {
            // Vaild-unsent addresses should be considered temporary
            deleteMessage = failMessage(message, sfe.getValidUnsentAddresses(), sfe, false);
        }
        return deleteMessage;
    } catch (MessagingException mex) {
        // Check whether this is a permanent error (like account doesn't
        // exist or mailbox is full or domain is setup wrong)
        // We fail permanently if this was 5xx error.
        return failMessage(message, addresses, mex, ('5' == mex.getMessage().charAt(0)));
    }
    // If we get here, we've exhausted the loop of servers without sending
    // the message or throwing an exception.
    // One case where this might happen is if there is no server we can
    // connect. So this should be considered temporary
    return failMessage(message, addresses, new MessagingException("No mail server(s) available at this time."),
            false);
}

From source file:edu.jhuapl.openessence.web.util.ControllerUtils.java

public static List<Dimension> getAccumulationsByIds(final OeDataSource ds, final String[] accumulationIds,
        boolean addAllByDefault) throws OeDataSourceException {
    // if an accumulation is not provided default to all accumulations
    final List<Dimension> accumulations;
    if (ArrayUtils.isEmpty(accumulationIds)) {
        accumulations = new ArrayList<Dimension>();
        if (addAllByDefault) {
            accumulations.addAll(ds.getAccumulations());
        }//from   ww  w.  ja va 2 s.  c  o m
    } else {
        accumulations = new ArrayList<Dimension>(accumulationIds.length);
        for (final String accumulationId : accumulationIds) {
            final Dimension a = ds.getAccumulation(accumulationId);
            if (a != null) {
                accumulations.add(a);
            } else {
                throw new OeDataSourceException("No Such Accumulation " + accumulationId);
            }
        }
    }
    return accumulations;
}

From source file:de.codesourcery.jasm16.compiler.CompilationUnit.java

@SuppressWarnings("rawtypes")
private List internalGetMarkers(String... types) {
    final List<IMarker> result = new ArrayList<IMarker>();

    if (ArrayUtils.isEmpty(types)) {
        for (List<IMarker> l : this.markers.values()) {
            result.addAll(l);/* ww  w.  j  a  v  a  2  s  .c om*/
        }
        return result;
    }

    final Set<String> uniqueTypes = new HashSet<String>(Arrays.asList(types));

    for (String expectedType : uniqueTypes) {
        final List<IMarker> existing = this.markers.get(expectedType);
        if (existing != null) {
            result.addAll(new ArrayList<IMarker>(existing));
        }
    }
    return result;
}

From source file:de.codesourcery.eve.skills.market.impl.EveCentralMarketDataProvider.java

@Override
public Map<InventoryType, PriceInfoQueryResult> getPriceInfos(final MarketFilter filter,
        final IPriceQueryCallback callback, final InventoryType... items) throws PriceInfoUnavailableException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("getPriceInfos(): filter = " + filter + ", items = " + items);
    }/*from w  ww  . j  av a2 s . co m*/

    if (ArrayUtils.isEmpty(items)) {
        return Collections.emptyMap();
    }

    final AtomicReference<Map<InventoryType, PriceInfoQueryResult>> resultHolder = new AtomicReference<Map<InventoryType, PriceInfoQueryResult>>(
            new ConcurrentHashMap<InventoryType, PriceInfoQueryResult>());

    final IUpdateStrategy updateStrategy = createUpdateStrategy(filter.getUpdateMode(), filter.getOrderType());

    final Vector<NameValuePair> params = new Vector<NameValuePair>();

    /*
     * NEEDS to be run on the EDT since Hibernate
     * lazy-fetching might kick in and
     * the Hibernate session is confined to the EDT.
     */
    runOnEDT(new Runnable() {

        @Override
        public void run() {
            if (LOG.isDebugEnabled()) {
                LOG.debug("getPriceInfos(): update_strategy = " + updateStrategy);
            }

            for (InventoryType t : items) {

                // make sure we don't query over and over
                // for prices that are unavailable anyway
                if (isPriceMissingOnEveCentral(filter, t)) {
                    if (!mayQueryAgainForMissingPrice(filter, t)) {
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("getPriceInfos(): " + "Price for " + t + " "
                                    + "unavailable on eve-central , filter " + filter);
                        }
                        continue;
                    }

                    if (LOG.isDebugEnabled()) {
                        LOG.debug("getPriceInfos(): [ retrying ] " + "Price for " + t + " "
                                + "unavailable on eve-central , filter " + filter);
                    }
                }

                final PriceInfoQueryResult cached = getCachedEntry(filter, t);

                resultHolder.get().put(t, cached);

                if (LOG.isDebugEnabled()) {

                    if (cached.isEmpty()) {
                        LOG.debug("getPriceInfos(): [ NOT CACHED ] type = " + t.getId() + " , name = "
                                + t.getName());
                    } else {
                        LOG.debug("getPriceInfos(): [ CACHE HIT ] " + cached);
                    }
                }

                final boolean requiresUpdate;
                switch (filter.getOrderType()) {
                case BUY:
                    requiresUpdate = updateStrategy.requiresUpdate(t,
                            cached.hasBuyPrice() ? cached.buyPrice() : null);
                    break;
                case SELL:
                    requiresUpdate = updateStrategy.requiresUpdate(t,
                            cached.hasSellPrice() ? cached.sellPrice() : null);
                    break;
                case ANY:
                    requiresUpdate = (updateStrategy.requiresUpdate(t,
                            cached.hasBuyPrice() ? cached.buyPrice() : null)
                            || updateStrategy.requiresUpdate(t,
                                    cached.hasSellPrice() ? cached.sellPrice() : null));
                    break;
                default:
                    throw new RuntimeException("Unhandled switch/case: " + filter.getOrderType());
                }

                if (LOG.isDebugEnabled()) {
                    LOG.debug("getPriceInfos(): [ " + updateStrategy + "] requires_update => " + requiresUpdate
                            + " , type=" + t.getName());
                }

                if (requiresUpdate) {
                    params.add(new BasicNameValuePair("typeid", t.getId().toString()));
                }
            }
        }
    });

    if (params.isEmpty() || isOfflineMode()) { // all entries served from cache
        return resultHolder.get();
    }

    addFilterToRequest(params, filter);

    /*
     * Query data from eve central
     */
    final String responseXmlFromServer = eveCentralClient.sendRequestToServer(params);
    final AtomicReference<String> xml = new AtomicReference<String>(responseXmlFromServer);

    /*
     * NEEDS to be run on the EDT since Hibernate
     * lazy-fetching might kick in and
     * the Hibernate session is confined to the EDT.
     */
    return runOnEventThread(new PriceCallable() {

        public Map<InventoryType, PriceInfoQueryResult> call() throws PriceInfoUnavailableException {
            final Map<InventoryType, PriceInfoQueryResult> realResult = resultHolder.get();

            final Map<Long, List<PriceInfo>> result = parsePriceInfo(filter, xml.get());

            // group prices by item types

            List<PriceInfo> updated = new ArrayList<>();
            try {
                for (InventoryType type : items) {
                    List<PriceInfo> info = result.get(type.getId());

                    if (info == null || info.isEmpty()) {
                        // failed to fetch data, query user 
                        rememberPriceMissingOnEveCentral(filter, type);
                        info = queryPriceFromUser(filter, callback, type);
                    }

                    forgetPriceMissingOnEveCentral(filter, type);

                    for (PriceInfo dataFromServer : info) {
                        dataFromServer.setRegion(filter.getRegion());
                        dataFromServer.setTimestamp(new EveDate(systemClock));
                        dataFromServer.setInventoryType(type);

                        final PriceInfoQueryResult cachedResult = realResult.get(type);

                        if (LOG.isDebugEnabled()) {
                            LOG.debug("getPriceInfos(): from server: " + dataFromServer + " , cached="
                                    + cachedResult);
                        }

                        PriceInfo existing;
                        switch (filter.getOrderType()) {
                        case BUY:
                            existing = cachedResult.hasBuyPrice() ? cachedResult.buyPrice() : null;
                            if (updateStrategy.requiresUpdate(type, existing)) {
                                LOG.debug("getPriceInfos(): merging buy price.");
                                realResult.put(type, cachedResult.merge(filter.getOrderType(), dataFromServer));
                                storeCacheEntry(dataFromServer);
                                updated.add(dataFromServer);
                            }
                            break;
                        case SELL:
                            existing = cachedResult.hasSellPrice() ? cachedResult.sellPrice() : null;
                            if (updateStrategy.requiresUpdate(type, existing)) {
                                LOG.debug("getPriceInfos(): merging sell price.");
                                realResult.put(type, cachedResult.merge(filter.getOrderType(), dataFromServer));
                                storeCacheEntry(dataFromServer);
                                updated.add(dataFromServer);
                            }
                            break;
                        case ANY:
                            existing = cachedResult.hasBuyPrice() ? cachedResult.buyPrice() : null;
                            if (updateStrategy.requiresUpdate(type, existing)) {
                                LOG.debug("getPriceInfos(): merging buy price.");
                                realResult.put(type, cachedResult.merge(PriceInfo.Type.BUY, dataFromServer));
                                storeCacheEntry(dataFromServer);
                                updated.add(dataFromServer);
                            }
                            existing = cachedResult.hasSellPrice() ? cachedResult.sellPrice() : null;
                            if (updateStrategy.requiresUpdate(type, existing)) {
                                LOG.debug("getPriceInfos(): merging sell price.");
                                realResult.put(type, cachedResult.merge(PriceInfo.Type.SELL, dataFromServer));
                                storeCacheEntry(dataFromServer);
                                updated.add(dataFromServer);
                            }
                            break;
                        default:
                            throw new RuntimeException("Unhandled switch/case: " + filter.getOrderType());
                        }
                    }
                }
            } finally {
                fireItemPriceChanged(updated);
            }
            return realResult;
        }
    });
}