Speed up toString() for XML elements
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / codec / xml / XmlUtils.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. 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 package org.opendaylight.yangtools.yang.data.impl.codec.xml;
9
10 import javax.annotation.Nonnull;
11 import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec;
12 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
13
14 /**
15  * Common XML-related utility methods, which are not specific to a particular
16  * JAXP API.
17  */
18 public final class XmlUtils {
19     public static final XmlCodecProvider DEFAULT_XML_CODEC_PROVIDER = new XmlCodecProvider() {
20         @Override
21         public TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>> codecFor(final TypeDefinition<?> baseType) {
22             return TypeDefinitionAwareCodec.from(baseType);
23         }
24     };
25
26     private XmlUtils() {
27         throw new UnsupportedOperationException();
28     }
29
30     /**
31      * @deprecated This utility method is no longer needed: check type identity directly
32      */
33     @Deprecated
34     public static TypeDefinition<?> resolveBaseTypeFrom(final @Nonnull TypeDefinition<?> type) {
35         TypeDefinition<?> superType = type;
36         while (superType.getBaseType() != null) {
37             superType = superType.getBaseType();
38         }
39         return superType;
40     }
41 }