gpt4 book ai didi

java - 从 protected Java方法返回Map

转载 作者:行者123 更新时间:2023-12-02 11:00:19 26 4
gpt4 key购买 nike

protected void createIdUpdateMapForMapObjects()
{
for (Iterator it = d_mapObjectList.iterator(); it.hasNext(); )
{
MapObject mapObj = (MapObject) it.next();
long transientId = mapObj.id();
long persistentId = g.getNewId();
boolean minDPTObjectIdSet = false;
long minDPTObjectId ;
long maxDPTObjectId = g.upperBound();

if(minDPTObjectIdSet == false) {
minDPTObjectId = persistentId;
System.out.println("min dpt" + minDPTObjectId);
System.out.println("max dpt" + maxDPTObjectId);
//insertDPTObjectId("minDPTObjectId", minDPTObjectId, "Starting change ID");
//insertDPTObjectId("maxDPTObjectId", maxDPTObjectId, "End change ID");
minDPTObjectIdSet = true;

}

public Map<String, Long> getMinMaxDPTObjectId(String Name, long minmaxDPTObjectId) {
Map<String,Long> minMaxDPTObjectId = new HashMap<String,Long>();

minMaxDPTObjectId.put("minDPTObjectId",minDPTObjectId);
//minDPTObjectId which i need to get from above method
minMaxDPTObjectId.put("maxDPTObjectId",maxDPTObjectId);
//same

return minMaxDPTObjectId;
}

我无法将必须在另一个包中使用的minDPTObjectId和maxDPTObjectId的值返回给Map。
我认为返回 map 是个不错的选择,但是卡住了ob怎么做

最佳答案

public Map createIdUpdateMapForMapObjects()
{
IdGenerator g = d_idm.getGenerator(OraclePropertyAdapter.NEXTID); // could be null
Map<String, Long> minMaxDPTObjectIdMap = null;
for (Iterator it = d_mapObjectList.iterator(); it.hasNext(); )
{
MapObject mapObj = (MapObject) it.next();
long transientId = mapObj.id();
long persistentId = g.getNewId();
boolean minDPTObjectIdSet = false;
long minDPTObjectId ;
long maxDPTObjectId = g.upperBound();
minMaxDPTObjectIdMap = new HashMap<String, Long>();
minMaxDPTObjectIdMap.put("maxDPTObjectId",maxDPTObjectId);

if(minDPTObjectIdSet == false) {
minDPTObjectId = persistentId;
minMaxDPTObjectIdMap.put("minDPTObjectId",minDPTObjectId);
minDPTObjectIdSet = true;
}
return minMaxDPTObjectIdMap;

这看起来不错吗?

关于java - 从 protected Java方法返回Map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43862414/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com