我尝试合并两张地图
private void mergeMaps(HashMap<String, FailureExample> current,
HashMap<String, FailureExample> other) {
current.forEach((k, v) -> other.merge(k, v,
(v1, v2) -> {
FailureExample answer = new FailureExample();
addFromListWithSizeLimit(v1, answer);
addFromListWithSizeLimit(v2, answer);
// answer.requests.addAll(v1.requests);
// answer.requests.addAll(v2.requests);
return answer;
}));
}
Run Code Online (Sandbox Code Playgroud)
但是当current有0个元素时,lambda不会被执行.
如果没有合并可以不合并吗?
我想要:
map1{} ; map2{<a,<a1>>} returns map3{<a,<a1>>}
map1{<a,<b1>>} ; map2{<a,<a1>>} returns map3{<a,<a1, b1>>}
Run Code Online (Sandbox Code Playgroud) String str = commonClient.authorizedRequestBuilder(commonClient.webTarget
.path("/apps/get_current_version/default/"+appName+"/"+appName)
.queryParam("object_type", "app"))
.accept(MediaType.APPLICATION_JSON_TYPE)
.get()
.readEntity(String.class);
Run Code Online (Sandbox Code Playgroud)
我明白了
str = {"versions": {"ap": "Not Set", "am": "topic-test-publisher-1.0.16", "il": "topic-test-publisher-1.0.16", "row": "topic-test-publisher-1.0.49"}, "provider": "gce"}
Run Code Online (Sandbox Code Playgroud)
然后我改成这段代码
Version version = commonClient.authorizedRequestBuilder(commonClient.webTarget
.path("/apps/get_current_version/default/"+appName+"/"+appName)
.queryParam("object_type", "app"))
.accept(MediaType.APPLICATION_JSON_TYPE)
.get(ClientResponse.class)
.readEntity(new GenericType<Version>(){});
Run Code Online (Sandbox Code Playgroud)
并得到一个例外:
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not find a deserializer for non-concrete Map type [map type; class javax.ws.rs.core.MultivaluedMap, [simple type, class java.lang.String] -> [collection type; class java.util.List, contains [simple type, class java.lang.Object]]]
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:269)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:428)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.findDeserializer(StdDeserializer.java:947)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:439) …Run Code Online (Sandbox Code Playgroud) 我有一个谷歌存储java客户端.
我想重命名云上的文件夹.
有办法吗?
我看到了更新帖子,但我不确定如何更改名称元数据.
这是我的尝试,但我不知道该填写什么,"entity"没有oac.setName()
public void renameDirectory(String oldPath, String newName) throws IOException {
final Storage gsClient = GCSlientFactory.get(PromptoConfig.s.GCP_PROJECT_ID).getGSClient();
final URI uri = URI.create(oldPath);
ObjectAccessControl oac = new ObjectAccessControl();
oac.setId("newName");
final Storage.ObjectAccessControls.Update update = gsClient.objectAccessControls().update(BUCKET_NAME, uri.toString().replace("gs://"+BUCKET_NAME+"/", ""), "", oac);
update.execute();
}
Run Code Online (Sandbox Code Playgroud)
并且:
final Storage gsClient = GCSlientFactory.get(PromptoConfig.s.GCP_PROJECT_ID).getGSClient();
final URI uri = URI.create(oldPath);
ObjectAccessControl oac = new ObjectAccessControl();
oac.set("name", newName);
final Storage.ObjectAccessControls.Update update = gsClient.objectAccessControls().update(BUCKET_NAME, uri.toString().replace("gs://"+BUCKET_NAME+"/", ""), "allUsers", oac);
update.execute();
Run Code Online (Sandbox Code Playgroud) java google-app-engine file google-cloud-storage google-cloud-platform
我尝试编写pubsub的测试:
@Test
public void sendTopic() throws Exception {
CustomSubscriber customSubscriber = new CustomSubscriber();
customSubscriber.startAndWait();
CustomPublisher customPublisher = new CustomPublisher();
customPublisher.publish("123");
}
Run Code Online (Sandbox Code Playgroud)
和:
public CustomSubscriber() {
this.subscriptionName = SubscriptionName.create(SdkServiceConfig.s.GCP_PROJECT_ID, SdkServiceConfig.s.TOPIC_ID );
this.receiveMsgAction = (message, consumer) -> {
// handle incoming message, then ack/nack the received message
System.out.println("Id : " + message.getMessageId());
System.out.println("Data : " + message.getData().toStringUtf8());
consumer.ack();
};
this.afterStopAction = new ApiFutureEmpty();
}
// [TARGET startAsync()]
public void startAndWait() throws Exception {
Subscriber subscriber = createSubscriberWithCustomCredentials();
subscriber.startAsync();
// Wait for a …Run Code Online (Sandbox Code Playgroud) 我有这个代码:
final ViewTreeObserver[] viewTreeObserver = {myAcco
viewTreeObserver[0].addOnPreDrawListener(
new OnPreDrawListener() {
@Override
public boolean onPreDraw() {
int chipWidth =
myAccountView.getMeasuredWidth()
- myAccountView.getPaddingLeft()
- myAccountView.getPaddingRight();
if (chipWidth > 0) {
myAccountView.setText(
setChipTextWithCorrectLength(
getContext().getString(R.string.og_my_account_desc_long_length),
getContext().getString(R.string.og_my_account_desc_meduim_length),
getContext().getString(R.string.og_my_account_desc_short_length),
chipWidth));
viewTreeObserver[0] = myAccountView.getViewTreeObserver();
if (viewTreeObserver[0].isAlive()) {
viewTreeObserver[0].removeOnPreDrawListener(this);
}
}
return true;
}
});
}
@VisibleForTesting
String setChipTextWithCorrectLength(
String longDesc, String mediumDesc, String shortDesc, int clipWidth) {
if (!isTextEllipsized(longDesc, clipWidth)) {
return longDesc;
}
if (!isTextEllipsized(mediumDesc, clipWidth)) {
return mediumDesc;
}
return shortDesc;
}
private boolean isTextEllipsized(String …Run Code Online (Sandbox Code Playgroud) user-interface android width textview android-viewtreeobserver
我知道我可以为某些 Android 版本 + 夜间模式添加资源。
但是 API 21+ 的夜间模式资源文件夹的名称是什么?
drawable-night-v21?
我在winserver2008桌面上有一个名为a.bat的批处理文件.
该批处理文件仅将SessionID(从环境变量)写入本地事件日志.
我想使用cmd远程执行它(否则会出现SessionName).
所以我试过了
c:\PsTools\psexec.exe \\<Server> -u test2 -p <Password> -i 2 cmd "c:\Users\test-2\Desktop\a"
Run Code Online (Sandbox Code Playgroud)
要么
c:\PsTools\psexec.exe \\<server> -u test2 -p <Password> -i 2 "cmd \"c:\Users\test-2\Desktop\a\"";exit
Run Code Online (Sandbox Code Playgroud)
所有这些只是打开远程机器上的终端但不执行批处理.
任何想法?
最好的祝福,
我想在字典中保存一些对.
最后,我想将字典序列化为JSON对象.然后我打印JSON内容.我希望这些对的打印顺序与它们在字典中输入的顺序相同.
起初我用了一本普通的字典.但后来我觉得订单可能没有保留.然后我迁移到OrderedDictionary,但它不使用Generic,这意味着它不是类型安全的.
你有其他任何好的练习解决方案吗?
有3个表:
电影(id,title,yr,score,votes,director)actor(id,name)cast(movieid,actorid,ord)
问:"约翰特拉沃尔塔"最繁忙的几年.显示他每年制作的电影数量.
答:我的尝试是语法上的.为什么?
select yr, count(*)
from
(actor join casting
on (actor.id = casting.actorid)
join
on (movie.id = casting.movieid)
group by yr
having actor.name='John Travolta'
Run Code Online (Sandbox Code Playgroud) 我记得这是几个线程(例如边框)之间代码的汇合点,但我无法在Google上找到它.你还记得那个词吗?