Merge "BUG-997: Evolve the SchemaRegistry concepts"
authorTony Tkacik <ttkacik@cisco.com>
Sun, 3 Aug 2014 18:13:58 +0000 (18:13 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Sun, 3 Aug 2014 18:13:58 +0000 (18:13 +0000)
common/util/src/main/java/org/opendaylight/yangtools/util/ReadOnlyTrieMap.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlDocumentUtils.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BaseTypes.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/InstanceIdentifierType.java [moved from yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/InstanceIdentifier.java with 87% similarity]
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/package-info.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/ParserListenerUtils.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/TypesResolutionTest.java

index 88da121c8616f44aba44d633d9e599e1396fc5a4..4d429f1aaa11c899f6759cea472d48dabde75171 100644 (file)
@@ -27,7 +27,7 @@ final class ReadOnlyTrieMap<K, V> extends ForwardingMap<K, V> {
     private static final Logger LOG = LoggerFactory.getLogger(ReadOnlyTrieMap.class);
     private final TrieMap<K, V> readWrite;
     private final int size;
-    private TrieMap<K, V> readOnly;
+    private volatile TrieMap<K, V> readOnly;
 
     ReadOnlyTrieMap(final TrieMap<K, V> map, final int size) {
         super();
@@ -43,15 +43,18 @@ final class ReadOnlyTrieMap<K, V> extends ForwardingMap<K, V> {
 
     @Override
     protected Map<K, V> delegate() {
-        if (readOnly == null) {
+        TrieMap<K, V> ret = readOnly;
+        if (ret == null) {
             synchronized (this) {
-                if (readOnly == null) {
-                    readOnly = readWrite.readOnlySnapshot();
+                ret = readOnly;
+                if (ret == null) {
+                    ret = readWrite.readOnlySnapshot();
+                    readOnly = ret;
                 }
             }
         }
 
-        return readOnly;
+        return ret;
     }
 
     @Override
index 3233b78ce93c3c6cb473d7066abcb0bbf30bba4d..17d4e31919cb2d6302eb3a51beccaed821cc4173 100644 (file)
@@ -221,7 +221,7 @@ public class XmlDocumentUtils {
         }
         final TypeDefinition<?> baseType = XmlUtils.resolveBaseTypeFrom(schema.getType());
 
-        if (baseType instanceof org.opendaylight.yangtools.yang.model.util.InstanceIdentifier) {
+        if (baseType instanceof org.opendaylight.yangtools.yang.model.util.InstanceIdentifierType) {
             value = InstanceIdentifierForXmlCodec.deserialize(xmlElement,schemaCtx);
         } else if(baseType instanceof IdentityrefTypeDefinition){
             value = InstanceIdentifierForXmlCodec.toIdentity(xmlElement.getTextContent(), xmlElement, schemaCtx);
@@ -243,7 +243,7 @@ public class XmlDocumentUtils {
         if (codec != null) {
             value = codec.deserialize(text);
         }
-        if (schema.getType() instanceof org.opendaylight.yangtools.yang.model.util.InstanceIdentifier) {
+        if (schema.getType() instanceof org.opendaylight.yangtools.yang.model.util.InstanceIdentifierType) {
             value = InstanceIdentifierForXmlCodec.deserialize(xmlElement,schemaCtx);
         }
         if (value == null) {
index 002746fa571d8b9616e4ca78ddfd406bcfd005ef..0e40bd2964472c4a354f3d99e61b5c9893043787 100644 (file)
@@ -191,7 +191,7 @@ public final class BaseTypes {
         } else if ("empty".equals(typeName)) {
             return EmptyType.getInstance();
         } else if ("instance-identifier".equals(typeName)) {
-            return InstanceIdentifier.getInstance();
+            return InstanceIdentifierType.getInstance();
         }
         return null;
     }
similarity index 87%
rename from yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/InstanceIdentifier.java
rename to yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/InstanceIdentifierType.java
index 138b6a50a9b3e045f39b3c2c9a22e3e637a62d8a..02289efb0531f8b25931c5f513cec7379738baa4 100644 (file)
@@ -29,7 +29,7 @@ import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefi
  * @see InstanceIdentifierTypeDefinition
  *
  */
-public final class InstanceIdentifier implements InstanceIdentifierTypeDefinition, Immutable {
+public final class InstanceIdentifierType implements InstanceIdentifierTypeDefinition, Immutable {
 
     private static final QName NAME = BaseTypes.INSTANCE_IDENTIFIER_QNAME;
     private static final SchemaPath PATH = SchemaPath.create(true, NAME);
@@ -40,8 +40,8 @@ public final class InstanceIdentifier implements InstanceIdentifierTypeDefinitio
     private static final String UNITS = "";
     private final Boolean requireInstance;
 
-    private static final InstanceIdentifier INSTANCE_WITH_REQUIRED_TRUE = new InstanceIdentifier(true);
-    private static final InstanceIdentifier INSTANCE_WITH_REQUIRED_FALSE = new InstanceIdentifier(false);
+    private static final InstanceIdentifierType INSTANCE_WITH_REQUIRED_TRUE = new InstanceIdentifierType(true);
+    private static final InstanceIdentifierType INSTANCE_WITH_REQUIRED_FALSE = new InstanceIdentifierType(false);
 
     /**
      * Constructs new instance identifier.
@@ -50,7 +50,7 @@ public final class InstanceIdentifier implements InstanceIdentifierTypeDefinitio
      * @deprecated Use {@link #getInstance()} for default one, since Instance Identifier does not have xpath.
      */
     @Deprecated
-    public InstanceIdentifier(final RevisionAwareXPath xpath) {
+    public InstanceIdentifierType(final RevisionAwareXPath xpath) {
         requireInstance = true;
     }
 
@@ -62,19 +62,19 @@ public final class InstanceIdentifier implements InstanceIdentifierTypeDefinitio
      * @deprecated Use {@link #create(boolean)}, since Instance Identifier does not have xpath.
      */
     @Deprecated
-    public InstanceIdentifier(final RevisionAwareXPath xpath, final boolean requireInstance) {
+    public InstanceIdentifierType(final RevisionAwareXPath xpath, final boolean requireInstance) {
         this.requireInstance = requireInstance;
     }
 
-    private InstanceIdentifier(final boolean requiredInstance) {
+    private InstanceIdentifierType(final boolean requiredInstance) {
         this.requireInstance = requiredInstance;
     }
 
-    public static InstanceIdentifier getInstance() {
+    public static InstanceIdentifierType getInstance() {
         return INSTANCE_WITH_REQUIRED_TRUE;
     }
 
-    public static InstanceIdentifier create(final boolean requireInstance) {
+    public static InstanceIdentifierType create(final boolean requireInstance) {
         return requireInstance ? INSTANCE_WITH_REQUIRED_TRUE : INSTANCE_WITH_REQUIRED_FALSE;
     }
 
@@ -216,7 +216,7 @@ public final class InstanceIdentifier implements InstanceIdentifierTypeDefinitio
         if (getClass() != obj.getClass()) {
             return false;
         }
-        InstanceIdentifier other = (InstanceIdentifier) obj;
+        InstanceIdentifierType other = (InstanceIdentifierType) obj;
         return requireInstance.equals(other.requireInstance);
     }
 
index ec30f794b8598e88c4c93e605db3ac87761daafb..7f263193f3d3ea58995dc3ab90529009b41a7d95 100644 (file)
@@ -46,7 +46,7 @@
  *       <dt>uint64</dt>
  *       <dd>64-bit unsigned integer -{@link org.opendaylight.yangtools.yang.model.util.Int64}</dd>
  *       <dt>instance-identifier</dt>
- *       <dd>References a data tree node - {@link org.opendaylight.yangtools.yang.model.util.InstanceIdentifier}</dd>
+ *       <dd>References a data tree node - {@link org.opendaylight.yangtools.yang.model.util.InstanceIdentifierType}</dd>
  *       <dt>string</dt>
  *       <dd>{@link org.opendaylight.yangtools.yang.model.util.StringType}</dd>
  *     </dl>
index 542506045d031de4381010e849d29f9aef56b614..3ba54e404f44680010e47722baf848e4b993f590 100644 (file)
@@ -105,7 +105,7 @@ import org.opendaylight.yangtools.yang.model.util.BitsType;
 import org.opendaylight.yangtools.yang.model.util.Decimal64;
 import org.opendaylight.yangtools.yang.model.util.EnumerationType;
 import org.opendaylight.yangtools.yang.model.util.ExtendedType;
-import org.opendaylight.yangtools.yang.model.util.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.util.InstanceIdentifierType;
 import org.opendaylight.yangtools.yang.model.util.Int16;
 import org.opendaylight.yangtools.yang.model.util.Int32;
 import org.opendaylight.yangtools.yang.model.util.Int64;
@@ -1210,7 +1210,7 @@ public final class ParserListenerUtils {
             constraints.addLengths(binaryType.getLengthConstraints());
             baseType = binaryType;
         } else if ("instance-identifier".equals(typeName)) {
-            return InstanceIdentifier.create(isRequireInstance(typeBody));
+            return InstanceIdentifierType.create(isRequireInstance(typeBody));
         }
 
         if (parent instanceof TypeDefinitionBuilder && !(parent instanceof UnionTypeBuilder)) {
index 022cda45a59eae835f5989e2597f6e492bcbc2ad..53c335b874350c4f5e6b3e40d733d009a3698a41 100644 (file)
@@ -37,7 +37,7 @@ import org.opendaylight.yangtools.yang.model.util.BitsType;
 import org.opendaylight.yangtools.yang.model.util.EnumerationType;
 import org.opendaylight.yangtools.yang.model.util.ExtendedType;
 import org.opendaylight.yangtools.yang.model.util.IdentityrefType;
-import org.opendaylight.yangtools.yang.model.util.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.util.InstanceIdentifierType;
 import org.opendaylight.yangtools.yang.model.util.UnionType;
 
 public class TypesResolutionTest {
@@ -163,7 +163,7 @@ public class TypesResolutionTest {
     public void testInstanceIdentifier1() {
         Module tested = TestUtils.findModule(testedModules, "custom-types-test");
         LeafSchemaNode leaf = (LeafSchemaNode) tested.getDataChildByName("inst-id-leaf1");
-        InstanceIdentifier leafType = (InstanceIdentifier) leaf.getType();
+        InstanceIdentifierType leafType = (InstanceIdentifierType) leaf.getType();
         assertFalse(leafType.requireInstance());
         assertEquals(1, leaf.getUnknownSchemaNodes().size());
     }
@@ -172,7 +172,7 @@ public class TypesResolutionTest {
     public void testInstanceIdentifier2() {
         Module tested = TestUtils.findModule(testedModules, "custom-types-test");
         LeafSchemaNode leaf = (LeafSchemaNode) tested.getDataChildByName("inst-id-leaf2");
-        InstanceIdentifier leafType = (InstanceIdentifier) leaf.getType();
+        InstanceIdentifierType leafType = (InstanceIdentifierType) leaf.getType();
         assertTrue(leafType.requireInstance());
     }