Fix cost field bug and several other bugs.
[alto.git] / alto-commons / src / main / java / org / opendaylight / alto / commons / types / converter / RFC2ModelCostMapDataConverter.java
1 /*
2  * Copyright (c) 2015 Yale University and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.alto.commons.types.converter;
10
11 import java.util.LinkedList;
12 import java.util.List;
13 import java.util.Map;
14
15 import org.opendaylight.alto.commons.helper.Converter;
16 import org.opendaylight.alto.commons.types.model150404.ModelDstCosts;
17
18 public class RFC2ModelCostMapDataConverter
19     extends Converter<Map<String, Object>, List<ModelDstCosts>> {
20
21   public RFC2ModelCostMapDataConverter() {
22   }
23
24   public RFC2ModelCostMapDataConverter(Map<String, Object> _in) {
25       super(_in);
26   }
27
28   @Override
29   protected Object _convert() {
30     List<ModelDstCosts> dstCostsList = new LinkedList<ModelDstCosts>();
31     for (String dst : in().keySet()) {
32       //TODO: Should support different implementations
33       ModelDstCosts dstCosts = new ModelDstCosts();
34       dstCosts.dst = dst;
35       dstCosts.costDefault = in().get(dst).toString();
36       dstCostsList.add(dstCosts);
37     }
38     return dstCostsList;
39   }
40 }