Example usage for com.google.common.collect LinkedListMultimap create

List of usage examples for com.google.common.collect LinkedListMultimap create

Introduction

In this page you can find the example usage for com.google.common.collect LinkedListMultimap create.

Prototype

public static <K, V> LinkedListMultimap<K, V> create() 

Source Link

Document

Creates a new, empty LinkedListMultimap with the default initial capacity.

Usage

From source file:com.rackspacecloud.blueflood.io.astyanax.AstyanaxWriter.java

private static Multimap<Locator, IMetric> asMultimap(Collection<IMetric> metrics) {
    Multimap<Locator, IMetric> map = LinkedListMultimap.create();
    for (IMetric metric : metrics)
        map.put(metric.getLocator(), metric);
    return map;// w w  w . j  ava2  s.  c  o m
}

From source file:org.apache.tez.dag.app.dag.RootInputInitializerManager.java

public void handleInitializerEvents(List<TezEvent> events) {
    ListMultimap<InitializerWrapper, TezEvent> eventMap = LinkedListMultimap.create();

    for (TezEvent tezEvent : events) {
        Preconditions.checkState(tezEvent.getEvent() instanceof InputInitializerEvent);
        InputInitializerEvent event = (InputInitializerEvent) tezEvent.getEvent();
        Preconditions.checkState(vertex.getName().equals(event.getTargetVertexName()),
                "Received event for incorrect vertex");
        Preconditions.checkNotNull(event.getTargetInputName(), "target input name must be set");
        InitializerWrapper initializer = initializerMap.get(event.getTargetInputName());
        Preconditions.checkState(initializer != null,
                "Received event for unknown input : " + event.getTargetInputName());
        eventMap.put(initializer, tezEvent);
    }/* w  w w.j  av a 2  s  .c o  m*/

    // This is a restriction based on current flow - i.e. events generated only by initialize().
    // TODO Rework the flow as per the first comment on TEZ-1076
    if (isStopped) {
        LOG.warn("InitializerManager already stopped for " + vertex.getLogIdentifier() + " Dropping "
                + events.size() + " events");
    }

    for (Map.Entry<InitializerWrapper, Collection<TezEvent>> entry : eventMap.asMap().entrySet()) {
        InitializerWrapper initializerWrapper = entry.getKey();
        if (initializerWrapper.isComplete()) {
            LOG.warn(entry.getValue().size() + " events targeted at vertex " + vertex.getLogIdentifier()
                    + ", initializerWrapper for Input: " + initializerWrapper.getInput().getName()
                    + " will be dropped, since Input has already been initialized.");
        } else {
            initializerWrapper.handleInputInitializerEvents(entry.getValue());
        }

    }
}

From source file:com.tinspx.util.net.FormEncodedBody.java

/**
 * Returns a modifiable view of the headers. Any header (except
 * {@code Content-Length}) may be added, including overwriting the
 * {@code Content-Type} (which defaults to
 * {@code application/x-www-form-urlencoded}).
 *//*from   w ww .java 2s  .  c o m*/
@Override
public ListMultimap<String, String> headers() {
    if (headers == null) {
        headers = LinkedListMultimap.create();
        headers.put(HttpHeaders.CONTENT_TYPE, X_WWW_FORM_URLENCODED);
    }
    if (headersView == null) {
        headersView = Predicated.listMultimap(headers, Requests.HKEY_NO_LEN, Predicates.notNull());
    }
    return headersView;
}

From source file:lombok.ast.grammar.Source.java

public Map<Node, Collection<SourceStructure>> getSourceStructures() {
    if (cachedSourceStructures != null)
        return cachedSourceStructures;
    parseCompilationUnit();//from   ww  w  .j  a v  a  2s.  c o m
    ListMultimap<Node, SourceStructure> map = LinkedListMultimap.create();

    org.parboiled.Node<Node> pNode = parsingResult.parseTreeRoot;

    buildSourceStructures(pNode, null, map);

    Map<Node, Collection<SourceStructure>> result = map.asMap();

    for (Collection<SourceStructure> structures : result.values()) {
        for (SourceStructure structure : structures) {
            structure.setPosition(new Position(mapPosition(structure.getPosition().getStart()),
                    mapPosition(structure.getPosition().getEnd())));
        }
    }

    return cachedSourceStructures = result;
}

From source file:eu.lp0.cursus.xml.scores.XMLScoresFactory.java

@Override
public OverallPositionData newOverallPositionData(Scores scores) {
    return new AbstractOverallPositionData<ScoredData>(scores) {
        @Override//  w  ww  .  j  a  va  2s. c  o m
        protected LinkedListMultimap<Integer, Pilot> calculateOverallPositionsWithOrder() {
            LinkedListMultimap<Integer, Pilot> overallPositions = LinkedListMultimap.create();
            for (ScoresXMLOverallScore overallScore : subset.getOverallScores()) {
                Pilot pilot = xmlScores.dereference(overallScore);
                overallPositions.put(overallScore.getPosition(), pilot);
            }
            return overallPositions;
        }
    };
}

From source file:com.google.errorprone.bugpatterns.inject.guice.AssistedParameters.java

private Multimap<Type, VariableTree> partitionParametersByType(List<VariableTree> parameters,
        VisitorState state) {/*  w ww  .  j  a v a2  s . co m*/

    Types types = state.getTypes();
    Multimap<Type, VariableTree> multimap = LinkedListMultimap.create();

    variables: for (VariableTree node : parameters) {
        // Normalize Integer => int
        Type type = types.unboxedTypeOrType(ASTHelpers.getType(node));
        for (Type existingType : multimap.keySet()) {
            if (types.isSameType(existingType, type)) {
                multimap.put(existingType, node);
                continue variables;
            }
        }

        // A new type for the map.
        multimap.put(type, node);
    }

    return multimap;
}

From source file:com.streamsets.pipeline.stage.processor.lookup.ForceLookupProcessor.java

private void processRetrieve(Batch batch, SingleLaneBatchMaker batchMaker) throws StageException {
    Iterator<Record> it = batch.getRecords();

    if (!it.hasNext()) {
        emptyBatch(batchMaker);/*w ww.j a  v a2  s.  com*/
        return;
    }

    // New metadata cache for each batch
    recordCreator.buildMetadataCacheFromFieldList(partnerConnection, conf.retrieveFields);

    // Could be more than one record with the same value in the lookup
    // field, so we have to build a multimap
    ListMultimap<String, Record> recordsToRetrieve = LinkedListMultimap.create();

    // Iterate through records - three cases
    // * no ID field => use default field values
    // * ID in cache => use cached field values
    // * otherwise   => add ID to list for retrieval
    while (it.hasNext()) {
        Record record = it.next();
        Field idField = record.get(conf.idField);
        String id = (idField != null) ? idField.getValueAsString() : null;
        if (Strings.isNullOrEmpty(id)) {
            switch (conf.missingValuesBehavior) {
            case SEND_TO_ERROR:
                LOG.error(Errors.FORCE_35.getMessage());
                errorRecordHandler.onError(new OnRecordErrorException(record, Errors.FORCE_35));
                break;
            case PASS_RECORD_ON:
                setFieldsInRecord(record, getDefaultFields());
                break;
            default:
                throw new IllegalStateException(
                        "Unknown missing value behavior: " + conf.missingValuesBehavior);
            }
        } else {
            Optional<List<Map<String, Field>>> entry = cache.getIfPresent(id);

            if (entry != null && entry.isPresent()) {
                // Salesforce record id is unique, so we'll always have just one entry in the list
                setFieldsInRecord(record, entry.get().get(0));
            } else {
                recordsToRetrieve.put(id, record);
            }
        }
    }

    Set<Record> badRecords = new HashSet<>();
    if (!recordsToRetrieve.isEmpty()) {
        String fieldList = ("*".equals(conf.retrieveFields.trim())) ? recordCreator.expandWildcard()
                : conf.retrieveFields;
        String[] idArray = recordsToRetrieve.keySet().toArray(new String[0]);

        // Split batch into 'chunks'
        int start = 0;
        while (start < idArray.length) {
            int end = start + Math.min(MAX_OBJECT_IDS, idArray.length - start);
            String[] ids = Arrays.copyOfRange(idArray, start, end);
            try {
                SObject[] sObjects = partnerConnection.retrieve(fieldList, conf.sObjectType, ids);

                for (SObject sObject : sObjects) {
                    String id = sObject.getId();
                    Map<String, Field> fieldMap = recordCreator.addFields(sObject, columnsToTypes);
                    for (Record record : recordsToRetrieve.get(id)) {
                        setFieldsInRecord(record, fieldMap);
                    }
                    cache.put(id, Optional.of(ImmutableList.of(fieldMap)));
                }
            } catch (InvalidIdFault e) {
                // exceptionMessage has form "malformed id 0013600001NnbAdOnE"
                String badId = e.getExceptionMessage().split(" ")[2];
                LOG.error("Bad Salesforce ID: {}", badId);
                switch (getContext().getOnErrorRecord()) {
                case DISCARD:
                    // Need to discard whole chunk!
                    addRecordsToSet(ids, recordsToRetrieve, badRecords);
                    break;
                case TO_ERROR:
                    // Need to send the entire chunk to error - none of them were processed!
                    sendChunkToError(ids, recordsToRetrieve, getContext(), e);
                    addRecordsToSet(ids, recordsToRetrieve, badRecords);
                    break;
                case STOP_PIPELINE:
                    Record badRecord = recordsToRetrieve.get(badId).get(0);
                    throw new OnRecordErrorException(badRecord, Errors.FORCE_29, badId, e);
                default:
                    throw new IllegalStateException(Utils.format("It should never happen. OnError '{}'",
                            getContext().getOnErrorRecord(), e));
                }
            } catch (InvalidFieldFault e) {
                switch (getContext().getOnErrorRecord()) {
                case DISCARD:
                    // Need to discard whole chunk!
                    addRecordsToSet(ids, recordsToRetrieve, badRecords);
                    break;
                case TO_ERROR:
                    // Need to send the entire chunk to error - none of them were processed!
                    sendChunkToError(ids, recordsToRetrieve, getContext(), e);
                    addRecordsToSet(ids, recordsToRetrieve, badRecords);
                    break;
                case STOP_PIPELINE:
                    throw new StageException(Errors.FORCE_30, e.getExceptionMessage(), e);
                default:
                    throw new IllegalStateException(Utils.format("It should never happen. OnError '{}'",
                            getContext().getOnErrorRecord(), e));
                }
            } catch (ConnectionException e) {
                throw new StageException(Errors.FORCE_28, e.getMessage(), e);
            }
            start = end;
        }
    }

    it = batch.getRecords();
    while (it.hasNext()) {
        Record record = it.next();
        if (!badRecords.contains(record)) {
            batchMaker.addRecord(record);
        }
    }
}

From source file:com.google.gerrit.server.notedb.ChangeNotesParser.java

ChangeNotesParser(Change.Id changeId, ObjectId tip, ChangeNotesRevWalk walk, ChangeNoteUtil noteUtil,
        NoteDbMetrics metrics) {/*from   w  w w  . java  2s . com*/
    this.id = changeId;
    this.tip = tip;
    this.walk = walk;
    this.noteUtil = noteUtil;
    this.metrics = metrics;
    approvals = new LinkedHashMap<>();
    bufferedApprovals = new ArrayList<>();
    reviewers = HashBasedTable.create();
    reviewersByEmail = HashBasedTable.create();
    allPastReviewers = new ArrayList<>();
    reviewerUpdates = new ArrayList<>();
    submitRecords = Lists.newArrayListWithExpectedSize(1);
    allChangeMessages = new ArrayList<>();
    changeMessagesByPatchSet = LinkedListMultimap.create();
    comments = MultimapBuilder.hashKeys().arrayListValues().build();
    patchSets = new HashMap<>();
    deletedPatchSets = new HashSet<>();
    patchSetStates = new HashMap<>();
    currentPatchSets = new ArrayList<>();
}

From source file:org.tomahawk.libtomahawk.infosystem.hatchet.HatchetInfoPlugin.java

/**
 * Core method of this InfoPlugin. Gets and parses the ordered results.
 *
 * @param infoRequestData InfoRequestData object containing the input parameters.
 * @return true if the type of the given InfoRequestData was valid and could be processed. false
 * otherwise// w  ww  .  ja  v a2s .  com
 */
private boolean getAndParseInfo(InfoRequestData infoRequestData)
        throws NoSuchAlgorithmException, KeyManagementException, IOException {
    long start = System.currentTimeMillis();
    Multimap<String, String> params = LinkedListMultimap.create();
    Map<String, Map> resultMapList = new HashMap<String, Map>();
    String rawJsonString;
    if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_USERS) {
        rawJsonString = TomahawkUtils.httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_USERS,
                infoRequestData.getParams())).mResponseText;
        infoRequestData.setInfoResult(mObjectMapper.readValue(rawJsonString, HatchetUsers.class));
        return true;
    } else if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_USERS_SELF) {
        if (TextUtils.isEmpty(mUserId)) {
            return false;
        }
        params.put(HATCHET_PARAM_IDARRAY, mUserId);
        rawJsonString = TomahawkUtils
                .httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_USERS, params)).mResponseText;
        infoRequestData.setInfoResult(mObjectMapper.readValue(rawJsonString, HatchetUsers.class));
        return true;
    } else if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_USERS_PLAYLISTS) {
        if (TextUtils.isEmpty(mUserId)) {
            return false;
        }
        params.put(HATCHET_PARAM_ID, mUserId);
        rawJsonString = TomahawkUtils.httpGet(
                buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_USERS_PLAYLISTS, params)).mResponseText;
        infoRequestData.setInfoResult(mObjectMapper.readValue(rawJsonString, HatchetPlaylists.class));
        return true;
    } else if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_PLAYLISTS_ENTRIES) {
        rawJsonString = TomahawkUtils.httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_PLAYLISTS_ENTRIES,
                infoRequestData.getParams())).mResponseText;
        infoRequestData.setInfoResult(mObjectMapper.readValue(rawJsonString, HatchetPlaylistEntries.class));
        return true;
    } else if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_USERS_LOVEDITEMS) {
        if (TextUtils.isEmpty(mUserId)) {
            return false;
        }
        Map<HatchetPlaylistInfo, HatchetPlaylistEntries> playlistEntriesMap = new HashMap<HatchetPlaylistInfo, HatchetPlaylistEntries>();
        params.put(HATCHET_PARAM_ID, mUserId);
        rawJsonString = TomahawkUtils.httpGet(
                buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_USERS_LOVEDITEMS, params)).mResponseText;
        HatchetPlaylistEntries playlistEntries = mObjectMapper.readValue(rawJsonString,
                HatchetPlaylistEntries.class);
        playlistEntriesMap.put(playlistEntries.playlist, playlistEntries);
        resultMapList.put(HATCHET_PLAYLISTS_ENTRIES, playlistEntriesMap);
        infoRequestData.setInfoResultMap(resultMapList);
        return true;
    } else if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_USERS_SOCIALACTIONS) {
        rawJsonString = TomahawkUtils
                .httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_USERS_SOCIALACTIONS,
                        infoRequestData.getParams())).mResponseText;
        infoRequestData
                .setInfoResult(mObjectMapper.readValue(rawJsonString, HatchetSocialActionResponse.class));
        return true;
    } else if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_USERS_FRIENDSFEED) {
        rawJsonString = TomahawkUtils.httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_USERS_FRIENDSFEED,
                infoRequestData.getParams())).mResponseText;
        infoRequestData
                .setInfoResult(mObjectMapper.readValue(rawJsonString, HatchetSocialActionResponse.class));
        return true;
    } else if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_USERS_PLAYBACKLOG) {
        rawJsonString = TomahawkUtils.httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_USERS_PLAYBACKLOG,
                infoRequestData.getParams())).mResponseText;
        infoRequestData
                .setInfoResult(mObjectMapper.readValue(rawJsonString, HatchetPlaybackLogsResponse.class));
        return true;
    } else if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_ARTISTS) {
        rawJsonString = TomahawkUtils.httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_ARTISTS,
                infoRequestData.getParams())).mResponseText;
        infoRequestData.setInfoResult(mObjectMapper.readValue(rawJsonString, HatchetArtists.class));
        return true;
    } else if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_ARTISTS_ALBUMS) {
        rawJsonString = TomahawkUtils.httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_ARTISTS,
                infoRequestData.getParams())).mResponseText;
        HatchetArtists artists = mObjectMapper.readValue(rawJsonString, HatchetArtists.class);

        if (artists.artists != null && artists.artists.size() > 0) {
            Map<HatchetAlbumInfo, HatchetTracks> tracksMap = new HashMap<HatchetAlbumInfo, HatchetTracks>();
            Map<HatchetAlbumInfo, HatchetImage> imageMap = new HashMap<HatchetAlbumInfo, HatchetImage>();
            params.put(HATCHET_PARAM_ID, artists.artists.get(0).id);
            rawJsonString = TomahawkUtils.httpGet(
                    buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_ARTISTS_ALBUMS, params)).mResponseText;
            HatchetCharts charts = mObjectMapper.readValue(rawJsonString, HatchetCharts.class);
            Map<String, HatchetImage> chartImageMap = new HashMap<String, HatchetImage>();
            if (charts.images != null) {
                for (HatchetImage image : charts.images) {
                    chartImageMap.put(image.id, image);
                }
            }
            if (charts.albums != null) {
                for (HatchetAlbumInfo albumInfo : charts.albums) {
                    if (albumInfo.images != null && albumInfo.images.size() > 0) {
                        imageMap.put(albumInfo, chartImageMap.get(albumInfo.images.get(0)));
                    }
                    if (albumInfo.tracks != null && albumInfo.tracks.size() > 0) {
                        params.clear();
                        for (String trackId : albumInfo.tracks) {
                            params.put(HATCHET_PARAM_IDARRAY, trackId);
                        }
                        rawJsonString = TomahawkUtils.httpGet(
                                buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_TRACKS, params)).mResponseText;
                        HatchetTracks tracks = mObjectMapper.readValue(rawJsonString, HatchetTracks.class);
                        tracksMap.put(albumInfo, tracks);
                    }
                }
            }
            resultMapList.put(HATCHET_TRACKS, tracksMap);
            resultMapList.put(HATCHET_IMAGES, imageMap);
        }
        infoRequestData.setInfoResultMap(resultMapList);
        return true;
    } else if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_ARTISTS_TOPHITS) {
        rawJsonString = TomahawkUtils.httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_ARTISTS,
                infoRequestData.getParams())).mResponseText;
        HatchetArtists artists = mObjectMapper.readValue(rawJsonString, HatchetArtists.class);

        if (artists.artists != null && artists.artists.size() > 0) {
            Map<HatchetChartItem, HatchetTrackInfo> tracksMap = new LinkedHashMap<HatchetChartItem, HatchetTrackInfo>();
            params.put(HATCHET_PARAM_ID, artists.artists.get(0).id);
            rawJsonString = TomahawkUtils.httpGet(
                    buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_ARTISTS_TOPHITS, params)).mResponseText;
            HatchetCharts charts = mObjectMapper.readValue(rawJsonString, HatchetCharts.class);
            Map<String, HatchetTrackInfo> trackInfoMap = new HashMap<String, HatchetTrackInfo>();
            if (charts.tracks != null) {
                for (HatchetTrackInfo trackInfo : charts.tracks) {
                    trackInfoMap.put(trackInfo.id, trackInfo);
                }
            }
            if (charts.chartItems != null) {
                for (HatchetChartItem chartItem : charts.chartItems) {
                    tracksMap.put(chartItem, trackInfoMap.get(chartItem.track));
                }
            }
            resultMapList.put(HATCHET_TRACKS, tracksMap);
        }
        infoRequestData.setInfoResultMap(resultMapList);
        return true;
    } else if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_ALBUMS) {
        rawJsonString = TomahawkUtils.httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_ALBUMS,
                infoRequestData.getParams())).mResponseText;
        HatchetAlbums albums = mObjectMapper.readValue(rawJsonString, HatchetAlbums.class);
        if (albums.albums != null && albums.albums.size() > 0) {
            HatchetAlbumInfo albumInfo = albums.albums.get(0);
            Map<String, HatchetImage> imageMap = new HashMap<String, HatchetImage>();
            if (albums.images != null) {
                for (HatchetImage image : albums.images) {
                    imageMap.put(image.id, image);
                }
            }
            Map<HatchetAlbumInfo, HatchetTracks> tracksMap = new HashMap<HatchetAlbumInfo, HatchetTracks>();
            if (albumInfo.tracks != null && albumInfo.tracks.size() > 0) {
                params.clear();
                for (String trackId : albumInfo.tracks) {
                    params.put(HATCHET_PARAM_IDARRAY, trackId);
                }
                rawJsonString = TomahawkUtils
                        .httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_TRACKS, params)).mResponseText;
                HatchetTracks tracks = mObjectMapper.readValue(rawJsonString, HatchetTracks.class);
                tracksMap.put(albumInfo, tracks);
            }
            infoRequestData.setInfoResult(albumInfo);
            resultMapList.put(HATCHET_IMAGES, imageMap);
            resultMapList.put(HATCHET_TRACKS, tracksMap);
        }
        infoRequestData.setInfoResultMap(resultMapList);
        return true;
    } else if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_SEARCHES) {
        rawJsonString = TomahawkUtils.httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_SEARCHES,
                infoRequestData.getParams())).mResponseText;
        infoRequestData.setInfoResult(mObjectMapper.readValue(rawJsonString, HatchetSearch.class));
        return true;
    } else if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_RELATIONSHIPS_USERS_FOLLOWERS
            || infoRequestData
                    .getType() == InfoRequestData.INFOREQUESTDATA_TYPE_RELATIONSHIPS_USERS_FOLLOWINGS) {
        rawJsonString = TomahawkUtils.httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_RELATIONSHIPS,
                infoRequestData.getParams())).mResponseText;
        HatchetRelationshipsStruct relationshipsStruct = mObjectMapper.readValue(rawJsonString,
                HatchetRelationshipsStruct.class);
        for (HatchetRelationshipStruct relationship : relationshipsStruct.relationships) {
            String userId;
            if (infoRequestData
                    .getType() == InfoRequestData.INFOREQUESTDATA_TYPE_RELATIONSHIPS_USERS_FOLLOWERS) {
                userId = relationship.user;
            } else {
                userId = relationship.targetUser;
            }
            params.put(HATCHET_PARAM_IDARRAY, userId);
        }
        rawJsonString = TomahawkUtils
                .httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_USERS, params)).mResponseText;
        HatchetUsers hatchetUsers = mObjectMapper.readValue(rawJsonString, HatchetUsers.class);
        infoRequestData.setInfoResult(hatchetUsers);
        return true;
    } else if (infoRequestData
            .getType() == InfoRequestData.INFOREQUESTDATA_TYPE_RELATIONSHIPS_USERS_STARREDALBUMS
            || infoRequestData
                    .getType() == InfoRequestData.INFOREQUESTDATA_TYPE_RELATIONSHIPS_USERS_STARREDARTISTS) {
        if (!infoRequestData.getParams().containsKey(HATCHET_PARAM_USERID)) {
            infoRequestData.getParams().put(HATCHET_PARAM_USERID, mUserId);
        }
        rawJsonString = TomahawkUtils.httpGet(buildQuery(InfoRequestData.INFOREQUESTDATA_TYPE_RELATIONSHIPS,
                infoRequestData.getParams())).mResponseText;
        HatchetRelationshipsStruct relationshipsStruct = mObjectMapper.readValue(rawJsonString,
                HatchetRelationshipsStruct.class);
        if (relationshipsStruct.relationships.isEmpty()) {
            return false;
        }
        infoRequestData.setInfoResult(relationshipsStruct);
        return true;
    }
    Log.d(TAG, "doInBackground(...) took " + (System.currentTimeMillis() - start) + "ms to finish");
    return false;
}

From source file:com.ning.http.client.RequestBuilderBase.java

public T addQueryParameter(String name, String value) {
    if (request.queryParams == null) {
        request.queryParams = LinkedListMultimap.create();
    }/*from  w  w  w . ja  v  a  2s. co m*/
    request.queryParams.put(name, value);
    return derived.cast(this);
}