Solved

How to load a HashMap with all items from a Group<>

Posted on 2014-11-03
7
176 Views
Last Modified: 2014-11-08
C#.net guy, trying to write .java code; fumbling around on something that seems should be simple.

I have need to load a HashMap with a data that I am receiving from a class that is coming to be as a Group<>
Object model looks something like this;

VmGroupResource vmGroupResource = provider.getVmGroupResource(root.getVms());
Group<Vm> vms = vmGroupResource.getAllVms();

From there I need to put the data in the return data as a HashMap, but I get a type mismatch when I try to do;

(vccdata is the HashMap)
vccdata.putAll(Map) vms);

The IDE doesn't show me an error, but it throws an exception when debugging using NetBeans.
0
Comment
Question by:Michael Krumpe
  • 3
  • 3
7 Comments
 
LVL 16

Expert Comment

by:krakatoa
ID: 40419963
Best post your code with the exception so we can see it in situ.
0
 
LVL 4

Author Comment

by:Michael Krumpe
ID: 40420059
Working on that. Is my code though the proper way to push a Group<> into a a HashMap?
0
 
LVL 16

Accepted Solution

by:
krakatoa earned 500 total points
ID: 40420106
I don't recall Group being in the Java API.

Maybe you mean a collection, in which case you'd be referring to java Collections I reckon. In which case, pls take a shuftee at the API for it.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Expert Comment

by:CEHJ
ID: 40420169
Group<Vm> itself would have to be a Map. Somehow that seems unlikely
0
 
LVL 4

Assisted Solution

by:Michael Krumpe
Michael Krumpe earned 0 total points
ID: 40420310
I am using an SDK provided class model. Drilling into the definition of Group, it looks like it is a type created in the class that extends Entity. It is pulling together some Json types from com.fasterxml.jackson.annotation, and then later adds
type, items, first, last, next, prev, build as interfaces.

the interface for .items is a List.

Thanks for pointing me in the direction to drill in a little more. That said, should I just treat it like a Collection and do:
for (Vm i: vms.getItems()) vccdata.put(i.getId(), i);

Open in new window


Should work... I think. Its giving me back 0 items as a size count. ... just want to make sure I'm doing it right before I bark up the SDK developer's tree.
0
 
LVL 16

Expert Comment

by:krakatoa
ID: 40420603
Not objecting as such to your close request, but wondering if you are entirely in the clear with it, given CEHJ's comment, and then my lack of full understanding of your requirements. Question.
0
 
LVL 4

Author Closing Comment

by:Michael Krumpe
ID: 40430074
Feedback pointed me in the right direction to see it as a collection, which needed to be treated as its own for loop.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 77
GUI builder for Eclipse? 8 27
Error trying to install RTMT Win7 5 38
netstat -ano | find "8000" and taskkill /f /pid 2984 3 29
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now