草庐IT

mapped_type

全部标签

java - 如何使用 Java stream api 过滤 map ?

Mapmap=newHashMap();map.put(1,"f");map.put(2,"I");map.put(3,"a");map.put(4,"c");....etc现在我有一个列表:Listpicks={1,3}我想取回一个字符串列表,即在“选择”列表中找到的与键值匹配的映射值。所以,我希望取回{"f","a"}作为结果。有没有办法使用javastreamapi以优雅的方式做到这一点?当只有一个值时,我是这样做的:map.entrySet().stream().filter(entry->"a".equals(entry.getValue())).map(entry->ent

hibernate 中的 Javassist 失败 : invalid constant type: 60

我正在创建一个cli工具来管理现有的应用程序。应用程序和测试都构建良好并运行良好,但尽管我在运行jar中存在的cli工具时收到javassist失败:INFO:Bytecodeprovidername:javassist...INFO:HibernateEntityManager3.5.1-FinalExceptioninthread"main"javax.persistence.PersistenceException:UnabletoconfigureEntityManagerFactoryatorg.hibernate.ejb.Ejb3Configuration.configur

java - 在 Java 中同时实现 Map 和 List 接口(interface)?

我想要一个在Java中实现Map和List接口(interface)的对象。这个想法类似于这个问题中的问题:JavaOrderedMap我想将名称/值对添加到列表中并让列表保留序列,但也能够按名称进行查找:foo.put("name0","value0");foo.put("name1","value1");foo.get(1);-->Map.Entry("name1","value1")foo.get("name0");-->"value0"问题是:当我创建这个类时:classFooimplementsMap,List{//addallmethodshere}编译错误:"Theret

Java secondary not public 类的使用会产生错误 "Type is not Visible",即使访问的方法在主类中是公共(public)的

我有一个Main.java文件:publicclassMain{privateEntityDrawerentityDrawer;publicvoidsetEntityDrawer(EntityDrawerentityDrawer){this.entityDrawer=entityDrawer;}publicEntityDrawergetEntityDrawer(){returnentityDrawer;}}classEntityDrawer{privateEmpleadoempleado;publicEmpleadogetEmpleado(){returnempleado;}publi

java - Jersey 序列化/反序列化问题 : abstract types can only be instantiated with additional type information

我正在使用Jersey进行序列化和反序列化。我已经使用Jersey在WebLogic上创建了RESTchannel。我有包含抽象类的结果对象。Jersey使用此类的实现名称添加到结果元数据中:{"order":{"@type":"installationOrder",但是,同样的Jersey,在用于反序列化这些数据时,尖叫着以下内容:Causedby:org.codehaus.jackson.map.JsonMappingException:Cannotconstructinstanceofocl.mobile.service.data.order.DetailedOrder,prob

java - 为 Map 中的术语添加值

我正在尝试向Java中的map添加特定值,其中键非常复杂,但值是简单的Double。目前我正在使用,其中foos是java.util.TreeMap的一个实例,和amount是Double,代码如下:for(java.util.Map.Entryentry:foos.entrySet()){foos.put(entry.getKey(),entry.getValue()+amount);}但这看起来很脏,因为我必须重新插入元素,而且我担心会使迭代器失效。有更好的方法吗?我使用的是最新版本的Java。 最佳答案 因为你只想修改值,你可

java - map 中两个字符串的键?

我需要创建一个具有两个字符串键的映射。例如让我们说key=Name&Targetvalue=Permission(boolean)我是否需要创建一个特殊对象,或者在Java/GoogleCollections或CommonsCollections或CommonsLang中是否有元组构建? 最佳答案 ApacheCommonsCollections有MultiKey:map.put(newMultiKey(key1,key2),value);和一个MultiKeyMap:multiKeyMap.put(key1,key2,value)

java - 为什么我会收到错误 "File cannot be resolved to a type"?

这是我的部分代码try{BufferedReaderin=newBufferedReader(newInputStreamReader(System.in));while((line=in.readLine())!="exit"){System.out.println("Entercommand");line=in.readLine();CommandcurrentCommand=newCommand(line);FilecurrentFile=newFile(currentCommand.getLsPath());currentCommand.getLsPath()方法返回一个字符串

java - 使用 Java 8 流处理 map 列表

如何将此代码简化为单个lambda表达式?这个想法是有一个map列表,我想创建一个新的map列表,使用键上的过滤器。在这个例子中,我想重新映射它,以便它只保留键“x”和“z”。Mapm0=newLinkedHashMap();m0.put("x","123");m0.put("y","456");m0.put("z","789");Mapm1=newLinkedHashMap();m1.put("x","000");m1.put("y","111");m1.put("z","222");Listl=newArrayList(Arrays.asList(m0,m1));Listtx=ne

java - 如何使用 JAVA 8 从 map 中获取第一个键值?

至于现在我在做什么:MapprocessedItem=processedItemMap.get(i);Map.EntryentrySet=getNextPosition(processedItem);Itemkey=entrySet.getKey();Booleanvalue=entrySet.getValue();publicstaticMap.EntrygetNextPosition(MapprocessedItem){returnprocessedItem.entrySet().iterator().next();}有没有更简洁的方法用java8来做到这一点?