/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015, 2017 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml;
+import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
-import java.util.Date;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListDependenciesAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
+import org.opendaylight.yangtools.yang.common.Revision;
public class ObjectXmlReader extends AttributeIfcSwitchStatement<AttributeReadingStrategy> {
private String key;
- private Map<String, Map<Date, IdentityMapping>> identityMap;
+ private Map<String, Map<Optional<Revision>, IdentityMapping>> identityMap;
- public Map<String, AttributeReadingStrategy> prepareReading(final Map<String, AttributeIfc> yangToAttrConfig, final Map<String, Map<Date, IdentityMapping>> identityMap) {
+ @SuppressWarnings("checkstyle:hiddenField")
+ public Map<String, AttributeReadingStrategy> prepareReading(final Map<String, AttributeIfc> yangToAttrConfig,
+ final Map<String, Map<Optional<Revision>, IdentityMapping>> identityMap) {
Map<String, AttributeReadingStrategy> strategies = Maps.newHashMap();
this.identityMap = identityMap;
return strategies;
}
- private AttributeReadingStrategy prepareReadingStrategy(final String key, final AttributeIfc attributeIfc) {
- this.key = key;
+ private AttributeReadingStrategy prepareReadingStrategy(final String attrKey, final AttributeIfc attributeIfc) {
+ this.key = attrKey;
return switchAttribute(attributeIfc);
}
@Override
public AttributeReadingStrategy caseJavaArrayAttribute(final ArrayType<?> openType) {
- SimpleAttributeReadingStrategy innerStrategy = new SimpleAttributeReadingStrategy(getLastAttribute().getNullableDefault());
+ SimpleAttributeReadingStrategy innerStrategy = new SimpleAttributeReadingStrategy(
+ getLastAttribute().getNullableDefault());
return new ArrayAttributeReadingStrategy(getLastAttribute().getNullableDefault(), innerStrategy);
}
@Override
public AttributeReadingStrategy caseJavaCompositeAttribute(final CompositeType openType) {
- Preconditions.checkState(openType.keySet().size() == 1, "Unexpected number of elements for open type %s, should be 1", openType);
+ Preconditions.checkState(openType.keySet().size() == 1,
+ "Unexpected number of elements for open type %s, should be 1", openType);
String mappingKey = openType.keySet().iterator().next();
return new SimpleCompositeAttributeReadingStrategy(getLastAttribute().getNullableDefault(), mappingKey);
}
protected AttributeReadingStrategy caseJavaIdentityRefAttribute(final OpenType<?> openType) {
Preconditions.checkState(openType instanceof CompositeType);
Set<String> keys = ((CompositeType) openType).keySet();
- Preconditions.checkState(keys.size() == 1, "Unexpected number of elements for open type %s, should be 1", openType);
+ Preconditions.checkState(keys.size() == 1, "Unexpected number of elements for open type %s, should be 1",
+ openType);
String mappingKey = keys.iterator().next();
- return new SimpleIdentityRefAttributeReadingStrategy(getLastAttribute().getNullableDefault(), mappingKey, identityMap);
+ return new SimpleIdentityRefAttributeReadingStrategy(getLastAttribute().getNullableDefault(), mappingKey,
+ identityMap);
}
@Override
protected AttributeReadingStrategy caseTOAttribute(final CompositeType openType) {
AttributeIfc lastAttribute = getLastAttribute();
Preconditions.checkState(lastAttribute instanceof TOAttribute);
- Map<String, AttributeIfc> inner = ((TOAttribute)lastAttribute).getYangPropertiesToTypesMap();
+ Map<String, AttributeIfc> inner = ((TOAttribute) lastAttribute).getYangPropertiesToTypesMap();
Map<String, AttributeReadingStrategy> innerStrategies = Maps.newHashMap();
innerAttrEntry.getValue());
innerStrategies.put(innerAttrEntry.getKey(), innerStrat);
}
-
return new CompositeAttributeReadingStrategy(lastAttribute.getNullableDefault(), innerStrategies);
}
protected AttributeReadingStrategy caseListAttribute(final ArrayType<?> openType) {
AttributeIfc lastAttribute = getLastAttribute();
Preconditions.checkState(lastAttribute instanceof ListAttribute);
- AttributeReadingStrategy innerStrategy = prepareReadingStrategy(key, ((ListAttribute) lastAttribute).getInnerAttribute());
+ AttributeReadingStrategy innerStrategy = prepareReadingStrategy(key,
+ ((ListAttribute) lastAttribute).getInnerAttribute());
return new ArrayAttributeReadingStrategy(lastAttribute.getNullableDefault(), innerStrategy);
}
AttributeReadingStrategy innerStrategy = caseDependencyAttribute(SimpleType.OBJECTNAME);
return new ArrayAttributeReadingStrategy(lastAttribute.getNullableDefault(), innerStrategy);
}
-
}