import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.ArrayList;
*
* @see <a href="http://tools.ietf.org/html/rfc6020#section-9.13">RFC6020</a>
*/
+// FIXME: 3.0.0: this concept needs to be moved to yang-common, as parser components need the ability to refer
+// to data nodes -- most notably XPath expressions and {@code default} statement arguments need to be able
+// to represent these.
+// FIXME: FixedYangInstanceIdentifier needs YangInstanceIdentifier initialized, but that includes initializing
+// this field. Figure out a way out of this pickle.
+@SuppressFBWarnings("IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION")
public abstract class YangInstanceIdentifier implements Path<YangInstanceIdentifier>, Immutable, Serializable {
/**
- * An empty {@link YangInstanceIdentifier}. It corresponds to the path of the conceptual
- * root of the YANG namespace.
+ * An empty {@link YangInstanceIdentifier}. It corresponds to the path of the conceptual root of the YANG namespace.
*/
public static final YangInstanceIdentifier EMPTY = FixedYangInstanceIdentifier.EMPTY_INSTANCE;
private final Map<QName, Object> keyValues;
+ public NodeIdentifierWithPredicates(final QName node) {
+ super(node);
+ this.keyValues = ImmutableMap.of();
+ }
+
public NodeIdentifierWithPredicates(final QName node, final Map<QName, Object> keyValues) {
super(node);
// Retains ImmutableMap for empty maps. For larger sizes uses a shared key set.
this.keyValues = ImmutableOffsetMap.unorderedCopyOf(keyValues);
}
- public NodeIdentifierWithPredicates(final QName node, final QName key, final Object value) {
+ public NodeIdentifierWithPredicates(final QName node, final ImmutableOffsetMap<QName, Object> keyValues) {
+ super(node);
+ this.keyValues = requireNonNull(keyValues);
+ }
+
+ public NodeIdentifierWithPredicates(final QName node, final SharedSingletonMap<QName, Object> keyValues) {
super(node);
- this.keyValues = SharedSingletonMap.unorderedOf(key, value);
+ this.keyValues = requireNonNull(keyValues);
+ }
+
+ public NodeIdentifierWithPredicates(final QName node, final QName key, final Object value) {
+ this(node, SharedSingletonMap.unorderedOf(key, value));
}
public Map<QName, Object> getKeyValues() {