I am sorry for what sounds like a simple question but I cannot seem to figure out the syntax of putting in two keys for a value in my Hashtable.
Already searched throughout the web and could not find an example.
Here is my declaration:
private Hashtable<Integer, Map<Integer, BACnetObject>> liftList = new Hashtable<Integer, Map<Integer, BACnetObject>>();
Here is some of my attempts at getting the syntax correct:
BACnetObject l = ........;
liftList.put(0, (0, l));
liftList.put(0, new Map(0, l));
liftList.put(0, Map<0, l>);
I am working in Eclipse and the most it does to help is suggest that I am not putting the applicable argument.
From Eclipse:
The method put(Integer, Map<Integer,BACnetObject>) in the type Hashtable<Integer,Map<Integer,BACnetObject>> is not applicable for the arguments (int)
What I am trying to achieve:
I am looping through two different types of objects and need two keys to access the correct second object each iteration. Here is my code:
private Hashtable<Integer, LocalDevice> localList = new Hashtable<Integer, LocalDevice>(); //comes from xml
private Hashtable<Integer, IController> controllerList = new Hashtable<Integer, IController>();
private Hashtable<Integer, Map<Integer, BACnetObject>> liftList = new Hashtable<Integer, Map<Integer, BACnetObject>>();
for(int i = 0; i < localList.size(); i++)
{
BACnetObject eg = new BACnetObject(localList.get(i), localList.get(i).getNextInstanceObjectIdentifier(ObjectType.ElevatorGroupType));
groupId = eg.getId();
eg.setProperty(PropertyIdentifier.objectIdentifier, new ObjectIdentifier(ObjectType.ElevatorGroupType, 0));
eg.setProperty(PropertyIdentifier.objectName, new CharacterString("MCE group"));
eg.setProperty(PropertyIdentifier.objectType, new ObjectType(128));
eg.setProperty(PropertyIdentifier.description, new CharacterString("ICue"));
eg.setProperty(PropertyIdentifier.machineRoomID, /*comes from xml??*/mr.getId());
eg.setProperty(PropertyIdentifier.groupID, new Unsigned8(0));
eg.setProperty(PropertyIdentifier.groupMembers, lifts);
localList.get(i).addObject(eg);
//if(controllerList.get(i).isConnected())
if(true)
{
//int numOfCars = controllerList.get(i).getNumberOfControllers();
int numOfCars = 3;
Map<Float, Map<Float, Integer>> map = new HashMap<>();
//Hashtable<Integer, Map<Integer, BACnetObject>> maps = new Hashtable<>();
//Hashtable<Integer, Map<Integer, BACnetObject>> liftList = new Hashtable<Integer, Map<Integer, BACnetObject>>();
for(int j = 0; j < numOfCars; j++)
{
final int p = j;
final int ii = i;
liftList.put(i, new Hashtable(){{put(j,l);}}); //The "duplicate" answer suggests doing it this way, but it gives me a bunch of warnings and it just overall seems messy. I am looking for a different way to do this.
}
Let me know your ideas please, thanks.