本文整理汇总了Java中com.google.api.client.util.Maps.newHashMap方法的典型用法代码示例。如果您正苦于以下问题:Java Maps.newHashMap方法的具体用法?Java Maps.newHashMap怎么用?Java Maps.newHashMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.client.util.Maps
的用法示例。
在下文中一共展示了Maps.newHashMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jsonToMap
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
/**
* Parses raw JSON into a map of ID -> Value.
* Allows null and empty values (must be handled later).
*/
private Map<Integer, String> jsonToMap( List<String> jsonAttributeValues )
throws IOException
{
Map<Integer, String> parsed = Maps.newHashMap();
ObjectMapper mapper = new ObjectMapper();
for ( String jsonString : jsonAttributeValues )
{
JsonNode node = mapper.readValue( jsonString, JsonNode.class );
JsonNode nId = node.get( "id" );
JsonNode nValue = node.get( "value" );
if ( nId == null || nId.isNull() )
{
continue;
}
parsed.put( nId.asInt(), nValue.asText() );
}
return parsed;
}
示例2: getSideInputs
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
private static Map<TupleTag<?>, BroadcastHelper<?>> getSideInputs(
List<PCollectionView<?>> views,
EvaluationContext context) {
if (views == null) {
return ImmutableMap.of();
} else {
Map<TupleTag<?>, BroadcastHelper<?>> sideInputs = Maps.newHashMap();
for (PCollectionView<?> view : views) {
Iterable<? extends WindowedValue<?>> collectionView = context.getPCollectionView(view);
Coder<Iterable<WindowedValue<?>>> coderInternal = view.getCoderInternal();
@SuppressWarnings("unchecked")
BroadcastHelper<?> helper =
BroadcastHelper.create((Iterable<WindowedValue<?>>) collectionView, coderInternal);
//broadcast side inputs
helper.broadcast(context.getSparkContext());
sideInputs.put(view.getTagInternal(), helper);
}
return sideInputs;
}
}
示例3: getInventory
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
@Override
public Map<String, String> getInventory() {
Map<String, String> inventoryContents = Maps.newHashMap();
Optional<PlayerMetadata> playerMetadataOptional = gameManager.getPlayerManager().getPlayerMetadata(playerId);
if (!playerMetadataOptional.isPresent()){
return inventoryContents;
}
PlayerMetadata playerMetadata = playerMetadataOptional.get();
List<String> inventory = playerMetadata.getInventory();
for (String itemId : inventory) {
Optional<Item> itemEntityOptional = gameManager.getEntityManager().getItemEntity(itemId);
if (!itemEntityOptional.isPresent()) {
continue;
}
Item itemEntity = itemEntityOptional.get();
String itemName = itemEntity.getItemName();
final String msgWithoutColorCodes =
itemName.replaceAll("\u001B\\[[;\\d]*m", "");
inventoryContents.put(itemEntity.getItemId(), msgWithoutColorCodes);
}
return inventoryContents;
}
示例4: getLockerInventory
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
@Override
public Map<String, String> getLockerInventory() {
Map<String, String> inventoryContents = Maps.newHashMap();
Optional<PlayerMetadata> playerMetadataOptional = gameManager.getPlayerManager().getPlayerMetadata(playerId);
if (!playerMetadataOptional.isPresent()){
return inventoryContents;
}
PlayerMetadata playerMetadata = playerMetadataOptional.get();
List<String> inventory = playerMetadata.getLockerInventory();
for (String itemId : inventory) {
Optional<Item> itemEntityOptional = gameManager.getEntityManager().getItemEntity(itemId);
if (!itemEntityOptional.isPresent()) {
continue;
}
Item itemEntity = itemEntityOptional.get();
String itemName = itemEntity.getItemName();
final String msgWithoutColorCodes =
itemName.replaceAll("\u001B\\[[;\\d]*m", "");
inventoryContents.put(itemEntity.getItemId(), msgWithoutColorCodes);
}
return inventoryContents;
}
示例5: create
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
@VisibleForTesting
static Authenticator create(Authentication authentication, Clock clock) {
List<AuthProvider> providersList = authentication.getProvidersList();
if (providersList == null || providersList.isEmpty()) {
throw new IllegalArgumentException("No auth providers are defined in the config.");
}
Map<String, IssuerKeyUrlConfig> issuerKeyConfigs = generateIssuerKeyConfig(providersList);
Map<String, String> issuersToProviderIds = Maps.newHashMap();
for (AuthProvider authProvider : providersList) {
issuersToProviderIds.put(authProvider.getIssuer(), authProvider.getId());
}
HttpRequestFactory httpRequestFactory = new NetHttpTransport().createRequestFactory();
KeyUriSupplier defaultKeyUriSupplier =
new DefaultKeyUriSupplier(httpRequestFactory, issuerKeyConfigs);
JwksSupplier jwksSupplier = new DefaultJwksSupplier(httpRequestFactory, defaultKeyUriSupplier);
JwksSupplier cachingJwksSupplier = new CachingJwksSupplier(jwksSupplier);
AuthTokenVerifier authTokenVerifier = new DefaultAuthTokenVerifier(cachingJwksSupplier);
AuthTokenDecoder authTokenDecoder = new DefaultAuthTokenDecoder(authTokenVerifier);
AuthTokenDecoder cachingAuthTokenDecoder = new CachingAuthTokenDecoder(authTokenDecoder);
return new Authenticator(
cachingAuthTokenDecoder,
clock,
ImmutableMap.<String, String>copyOf(issuersToProviderIds));
}
示例6: uploadTailoredAudience
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
@Override
public TwitterTonUploadResponse uploadTailoredAudience(File file) throws TwitterException {
String baseUrl = TwitterAdsConstants.POST_TON_DATA;
Map<String, String> customHeaders = Maps.newHashMap();
List<HttpParameter> params = new ArrayList<>();
customHeaders.put("X-TON-Expires", getXTonExpireTime());
if (file.length() > SIXTY_FOUR_MB) {
return uploadInChunks(file, baseUrl, customHeaders);
} else {
customHeaders.put("Content-Type", "text/plain");
customHeaders.put("Content-Length", String.valueOf(file.length()));
params.add(new HttpParameter("file", file));
return twitterAdsClient.executeHttpRequestForTon(baseUrl, params.toArray(new HttpParameter[params.size()]), HttpVerb.POST, customHeaders);
}
}
示例7: resumableUploadTailoredAudience
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
@Override
public TwitterTonUploadResponse resumableUploadTailoredAudience(Boolean resumable, String location, InputStream inputStream, String contentRange, Integer chunkSize) throws TwitterException {
String baseUrl = "https://ton.twitter.com" + location;
Map<String, String> customHeaders = Maps.newHashMap();
List<HttpParameter> params = new ArrayList<>();
params.add(new HttpParameter("path", location, inputStream));
customHeaders.put("Content-Range", "bytes " + contentRange);
customHeaders.put("Content-Length", String.valueOf(chunkSize));
customHeaders.put("Content-Type", "text/plain");
return twitterAdsClient.executeHttpRequestForTon(baseUrl, params.toArray(new HttpParameter[params.size()]), HttpVerb.PUT, customHeaders);
}
示例8: getGlobalOptOutListOfTailoredAudience
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
@Override
public void getGlobalOptOutListOfTailoredAudience(String accountId, String location) throws TwitterException {
TwitterAdUtil.ensureNotNull(accountId, "accountId");
TwitterAdUtil.ensureNotNull(location, "location");
Map<String, String> customHeaders = Maps.newHashMap();
String baseUrl = twitterAdsClient.getBaseAdsAPIUrl() + PREFIX_ACCOUNTS_URI_2 + accountId + PATH_TAILORED_AUDIENCE_CHANGES;
List<HttpParameter> params = new ArrayList<>();
params.add(new HttpParameter("input_file_path", location));
twitterAdsClient.executeHttpRequestForTon(baseUrl, params.toArray(new HttpParameter[params.size()]), HttpVerb.PUT, customHeaders);
}
示例9: getAllTypesForConfig
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
/**
* Gets all schema for an API config.
*
* @return a {@link Map} from {@link TypeToken} to {@link Schema}. If there are no schema for
* this config, an empty map is returned.
*/
private Map<TypeToken<?>, Schema> getAllTypesForConfig(ApiConfig config) {
Map<TypeToken<?>, Schema> typesForConfig = types.get(config.getSerializationConfig());
if (typesForConfig == null) {
typesForConfig = Maps.newHashMap();
types.put(config.getSerializationConfig(), typesForConfig);
}
return typesForConfig;
}
示例10: testAddAndPopulateColumnsBeforeA
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
@Test
public void testAddAndPopulateColumnsBeforeA()
{
assertEquals( 3, gridA.getWidth() );
Map<Object, List<?>> valueMap = Maps.newHashMap();
valueMap.put( 12, Lists.newArrayList( 101, 102, 103 ) );
valueMap.put( 22, Lists.newArrayList( 201, 202, 203 ) );
valueMap.put( 32, Lists.newArrayList( 301, 302, 303 ) );
gridA.addAndPopulateColumnsBefore( 1, valueMap, 3 );
assertEquals( 6, gridA.getWidth() );
assertEquals( 11, gridA.getValue( 0, 0 ) );
assertEquals( 101, gridA.getValue( 0, 1 ) );
assertEquals( 102, gridA.getValue( 0, 2 ) );
assertEquals( 103, gridA.getValue( 0, 3 ) );
assertEquals( 12, gridA.getValue( 0, 4 ) );
assertEquals( 13, gridA.getValue( 0, 5 ) );
assertEquals( 21, gridA.getValue( 1, 0 ) );
assertEquals( 201, gridA.getValue( 1, 1 ) );
assertEquals( 202, gridA.getValue( 1, 2 ) );
assertEquals( 203, gridA.getValue( 1, 3 ) );
assertEquals( 22, gridA.getValue( 1, 4 ) );
assertEquals( 23, gridA.getValue( 1, 5 ) );
assertEquals( 31, gridA.getValue( 2, 0 ) );
assertEquals( 301, gridA.getValue( 2, 1 ) );
assertEquals( 302, gridA.getValue( 2, 2 ) );
assertEquals( 303, gridA.getValue( 2, 3 ) );
assertEquals( 32, gridA.getValue( 2, 4 ) );
assertEquals( 33, gridA.getValue( 2, 5 ) );
}
示例11: testAddAndPopulateColumnsBeforeB
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
@Test
public void testAddAndPopulateColumnsBeforeB()
{
assertEquals( 3, gridA.getWidth() );
Map<Object, List<?>> valueMap = Maps.newHashMap();
valueMap.put( 22, Lists.newArrayList( 201, 202 ) );
valueMap.put( 32, Lists.newArrayList( 301 ) );
gridA.addAndPopulateColumnsBefore( 1, valueMap, 2 );
assertEquals( 5, gridA.getWidth() );
assertEquals( 11, gridA.getValue( 0, 0 ) );
assertEquals( null, gridA.getValue( 0, 1 ) );
assertEquals( null, gridA.getValue( 0, 2 ) );
assertEquals( 12, gridA.getValue( 0, 3 ) );
assertEquals( 13, gridA.getValue( 0, 4 ) );
assertEquals( 21, gridA.getValue( 1, 0 ) );
assertEquals( 201, gridA.getValue( 1, 1 ) );
assertEquals( 202, gridA.getValue( 1, 2 ) );
assertEquals( 22, gridA.getValue( 1, 3 ) );
assertEquals( 23, gridA.getValue( 1, 4 ) );
assertEquals( 31, gridA.getValue( 2, 0 ) );
assertEquals( 301, gridA.getValue( 2, 1 ) );
assertEquals( null, gridA.getValue( 2, 2 ) );
assertEquals( 32, gridA.getValue( 2, 3 ) );
assertEquals( 33, gridA.getValue( 2, 4 ) );
}
示例12: FieldGetter
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
public FieldGetter(Class<?> clazz) {
this.fields = Maps.newHashMap();
for (Field f : clazz.getDeclaredFields()) {
f.setAccessible(true);
this.fields.put(f.getName(), f);
}
}
示例13: doInBackground
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
@Override
protected SubmitResponse doInBackground (Query... params){
//try {
JSONArray ingredients = new JSONArray();
String[] ingredientsList = ingredientsField.getText().toString().split(", ");
//ingredients.put(ingredientsField.getText().toString());
for (int i = 0; i < ingredientsList.length; i++){
ingredients.put(ingredientsList[i]);
}
String putIngredients = ingredients.toString();
upc = "099482438548";
Map<String, Object> values = Maps.newHashMap();
values.put("product_name", nameField.getText().toString());
values.put("brand", companyField.getText().toString());
values.put("ingredients", putIngredients);
values.put("upc", upc);
Metadata meta = new Metadata().user("V-Scan");
Submit submit = new Submit(values);
SubmitResponse submitResponse = factual.submit("products-cpg-nutrition", submit, meta);
return submitResponse;
/*}catch(Exception e){
runOnUiThread(new Runnable(){
@Override
public void run(){
StringBuffer sb = new StringBuffer();
sb.append("failed");
resultText.setText(sb.toString());
resultText.setVisibility(View.VISIBLE);
}
});
return null;
}*/
}
示例14: send
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
private void send(String s) throws IOException
{
HashMap<Object, Object> payloadToSend = Maps.newHashMap();
payloadToSend.put("payload", s);
requestFactory.buildPostRequest(new GenericUrl(url), new UrlEncodedContent(payloadToSend)).execute();
}
示例15: parseHeaders
import com.google.api.client.util.Maps; //导入方法依赖的package包/类
/**
* parse headers string in lines
*/
public static Map<String, String> parseHeaders(String headerStr) {
if (Strings.isNotBlank(headerStr)) {
Map<String, String> hm = Maps.newHashMap();
for (String line : headerStr.split("[\\r\\n]+")) {
String[] header = line.split(": *", 2);
hm.put(header[0], header[1]);
}
return hm;
} else {
return Collections.emptyMap();
}
}