public static boolean isFlowPath(final InstanceIdentifier<? extends Object> path) { List<PathArgument> _path = path.getPath(); int _size = _path.size(); boolean _lessThan = (_size < 2); if (_lessThan) { return false; } List<PathArgument> _path_1 = path.getPath(); PathArgument _get = _path_1.get(2); if ((_get instanceof IdentifiableItem<?,?>)) { List<PathArgument> _path_2 = path.getPath(); PathArgument _get_1 = _path_2.get(2); final IdentifiableItem<?,? extends Identifiable<?>> item = ((IdentifiableItem<?,? extends Identifiable<?>>) _get_1); final Identifiable<?> key = item.getKey(); if ((key instanceof FlowKey)) { return true; } } return false; } }
@Override @SuppressWarnings("unchecked") protected InstanceIdentifier<D> getSpecificId(@Nonnull final InstanceIdentifier<? extends DataObject> currentId, @Nonnull final D current) { final InstanceIdentifier<D> id = (InstanceIdentifier<D>) currentId; // Make sure the key is present if (isWildcarded(id)) { return RWUtils.replaceLastInId(id, new InstanceIdentifier.IdentifiableItem<>(id.getTargetType(), current.key())); } else { return id; } }
/** * Returns child list item modification if {@code child} was modified by this modification. * * @param caseType Case type class * @param listItem Type of list item - must be list item with key * @param listKey List item key * @return Modification of {@code child} if {@code child} was modified, null otherwise. * @throws IllegalArgumentException If supplied {@code listItem} class is not valid child according * to generated model. */ default <H extends ChoiceIn<? super T> & DataObject, C extends Identifiable<K> & ChildOf<? super H>, K extends Identifier<C>> DataObjectModification<C> getModifiedChildListItem( @Nonnull final Class<H> caseType, @Nonnull final Class<C> listItem, @Nonnull final K listKey) { return (DataObjectModification<C>) getModifiedChild(IdentifiableItem.of(caseType, listItem, listKey)); }
public static RecordKeys getIdentifiableItemID( IdentifiableItem<?, Identifier<?>> ia) { RecordKeysBuilder rec = new RecordKeysBuilder(); rec.setKeyName(ia.getType().getSimpleName()); if (ia.getKey() instanceof MeterKey){ MeterKey mk = (MeterKey)ia.getKey(); rec.setKeyValue(""+mk.getMeterId().getValue()); } else if (ia.getKey() instanceof FlowKey) { FlowKey flowKey = (FlowKey) ia.getKey(); rec.setKeyValue("" + flowKey.getId().getValue()); } else if (ia.getKey() instanceof QueueKey) { QueueKey qk = (QueueKey) ia.getKey(); rec.setKeyValue("" + qk.getQueueId().getValue()); } else if (ia.getKey() instanceof GroupKey) { GroupKey gk = (GroupKey) ia.getKey(); rec.setKeyValue("" + gk.getGroupId().getValue()); } else if (ia.getKey() instanceof NodeConnectorKey) { NodeConnectorKey nck = (NodeConnectorKey) ia.getKey(); rec.setKeyValue(nck.getId().getValue()); } else if (ia.getKey() instanceof NodeKey) { NodeKey nk = (NodeKey) ia.getKey(); rec.setKeyValue(nk.getId().getValue()); } else if (ia.getKey() instanceof TableKey) { TableKey tk = (TableKey) ia.getKey(); rec.setKeyValue("" + tk.getId()); } else { throw new IllegalArgumentException("Unknown DataObject Key of type "+ia.getType().getName());
/** * Extends the given instance identifier path to include the given child. Augmentations are treated in the same way * as children; keyed children are handled correctly. * * @param path The current path. * @param child The child modification to include. * @return The extended path. */ private static <N extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<N>, T extends DataObject> InstanceIdentifier<? extends DataObject> extendPath( InstanceIdentifier path, DataObjectModification child) { Class<N> item = (Class<N>) child.getDataType(); if (child.getIdentifier() instanceof InstanceIdentifier.IdentifiableItem) { K key = (K) ((InstanceIdentifier.IdentifiableItem) child.getIdentifier()).getKey(); KeyedInstanceIdentifier<N, K> extendedPath = path.child(item, key); return extendedPath; } else { InstanceIdentifier<N> extendedPath = path.child(item); return extendedPath; } }
/** * Extends the given instance identifier path to include the given child. Augmentations are treated in the same way * as children; keyed children are handled correctly. * * @param path The current path. * @param child The child modification to include. * @return The extended path. */ private static <N extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<N>, T extends DataObject> InstanceIdentifier<? extends DataObject> extendPath( InstanceIdentifier path, DataObjectModification child) { Class<N> item = (Class<N>) child.getDataType(); if (child.getIdentifier() instanceof InstanceIdentifier.IdentifiableItem) { K key = (K) ((InstanceIdentifier.IdentifiableItem) child.getIdentifier()).getKey(); KeyedInstanceIdentifier<N, K> extendedPath = path.child(item, key); return extendedPath; } else { InstanceIdentifier<N> extendedPath = path.child(item); return extendedPath; } }
/** * Determines the Netconf Node Node ID, given the node's instance * identifier. * * @param path Node's instance identifier * @return NodeId for the node */ private NodeId getNodeId(final InstanceIdentifier<?> path) { for (InstanceIdentifier.PathArgument pathArgument : path.getPathArguments()) { if (pathArgument instanceof InstanceIdentifier.IdentifiableItem<?, ?>) { final Identifier key = ((InstanceIdentifier.IdentifiableItem) pathArgument).getKey(); if(key instanceof NodeKey) { return ((NodeKey) key).getNodeId(); } } } return null; }
/** * Create an InstanceIdentifier for a child list item. This method is a more efficient equivalent to * {@code builder().child(caze, listItem, listKey).build()}. * * @param caze Choice case class * @param listItem List to append * @param listKey List key * @param <C> Case type * @param <N> List type * @param <K> Key type * @return An InstanceIdentifier. * @throws NullPointerException if any argument is null */ @SuppressWarnings("unchecked") public final <C extends ChoiceIn<? super T> & DataObject, K extends Identifier<N>, N extends Identifiable<K> & ChildOf<? super C>> KeyedInstanceIdentifier<N, K> child(final Class<C> caze, final Class<N> listItem, final K listKey) { return (KeyedInstanceIdentifier<N, K>) childIdentifier(IdentifiableItem.of(caze, listItem, listKey)); }
/** * Fetch the host information from the given path argument, and set it * into {@code VNodePathConverter} instance. * * @param conv A {@link VNodePathConverter} instance. * @param arg A path argument which contains the host mapped by the * MAC mapping. * @throws RpcException * An invalid host information is configured in {@code arg}. */ @Override public void fetch(VNodePathConverter conv, PathArgument arg) throws RpcException { @SuppressWarnings("unchecked") IdentifiableItem<VlanHostDescList, VlanHostDescListKey> item = (IdentifiableItem<VlanHostDescList, VlanHostDescListKey>)arg; conv.macMappedHost = new MacVlan(item.getKey().getHost()); }
/** * Return the key associated with the first component of specified type in * an identifier. * * @param listItem component type * @return key associated with the component, or null if the component type * is not present. */ public final <N extends Identifiable<K> & DataObject, K extends Identifier<N>> K firstKeyOf( final Class<N> listItem) { for (final PathArgument i : pathArguments) { if (listItem.equals(i.getType())) { @SuppressWarnings("unchecked") final K ret = ((IdentifiableItem<N, K>)i).getKey(); return ret; } } return null; }
/** * Create an InstanceIdentifierBuilder for a specific type of InstanceIdentifier which represents an * {@link IdentifiableItem} in a {@code grouping} used in the {@code case} statement. * * @param caze Choice case class * @param listItem list item class * @param listKey key value * @param <C> Case type * @param <N> List type * @param <K> List key * @return A new {@link InstanceIdentifierBuilder} * @throws NullPointerException if any argument is null */ public static <C extends ChoiceIn<? extends DataRoot> & DataObject, N extends Identifiable<K> & ChildOf<? super C>, K extends Identifier<N>> InstanceIdentifierBuilder<N> builder(final Class<C> caze, final Class<N> listItem, final K listKey) { return new InstanceIdentifierBuilderImpl<N>().addNode(IdentifiableItem.of(caze, listItem, listKey)); }
/** * Determines the Netconf Node Node ID, given the node's instance * identifier. * * @param pathArgument Node's path argument * @return NodeId for the node */ public static NodeId getNodeId(final InstanceIdentifier.PathArgument pathArgument) { if (pathArgument instanceof InstanceIdentifier.IdentifiableItem<?, ?>) { final Identifier key = ((InstanceIdentifier.IdentifiableItem) pathArgument).getKey(); if(key instanceof NodeKey) { return ((NodeKey) key).getNodeId(); } } throw new IllegalStateException("Unable to create NodeId from: " + pathArgument); }
public static FlowConfig toFlowConfig(final InstanceIdentifier<? extends Object> identifier) { try { FlowConfig _flowConfig = new FlowConfig(); final FlowConfig it = _flowConfig; List<PathArgument> _path = identifier.getPath(); PathArgument _get = _path.get(2); final FlowKey key = ((IdentifiableItem<Flow,FlowKey>) _get).getKey(); Long _id = key.getId(); String _valueOf = String.valueOf(_id); it.setName(_valueOf); NodeRef _node = key.getNode(); Node _aDNode = NodeMapping.toADNode(_node); it.setNode(_aDNode); return it; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
/** * Create an InstanceIdentifier for a child list item. This method is a more efficient equivalent to * {@code builder().child(listItem, listKey).build()}. * * @param listItem List to append * @param listKey List key * @param <N> List type * @param <K> Key type * @return An InstanceIdentifier. * @throws NullPointerException if any argument is null */ @SuppressWarnings("unchecked") public final <N extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<N>> KeyedInstanceIdentifier<N, K> child(final Class<N> listItem, final K listKey) { return (KeyedInstanceIdentifier<N, K>) childIdentifier(IdentifiableItem.of(listItem, listKey)); }
/** * Return the key associated with the first component of specified type in * an identifier. * * @param listItem component type * @param listKey component key type * @return key associated with the component, or null if the component type * is not present. */ public final <N extends Identifiable<K> & DataObject, K extends Identifier<N>> K firstKeyOf(final Class<N> listItem, final Class<K> listKey) { for (final PathArgument i : pathArguments) { if (listItem.equals(i.getType())) { @SuppressWarnings("unchecked") final K ret = ((IdentifiableItem<N, K>)i).getKey(); return ret; } } return null; }
/** * Fetch the virtual interface name from the given path argument, * and set it into {@code VNodePathConverter} instance. * * @param conv A {@link VNodePathConverter} instance. * @param arg A path argument which contains the virtual interface * name. */ @Override public void fetch(VNodePathConverter conv, PathArgument arg) { @SuppressWarnings("unchecked") IdentifiableItem<Vinterface, VinterfaceKey> item = (IdentifiableItem<Vinterface, VinterfaceKey>)arg; conv.interfaceName = item.getKey().getName(); }
/** * Create an InstanceIdentifierBuilder for a specific type of InstanceIdentifier which represents an * {@link IdentifiableItem}. * * @param listItem list item class * @param listKey key value * @param <N> List type * @param <K> List key * @return A new {@link InstanceIdentifierBuilder} * @throws NullPointerException if any argument is null */ public static <N extends Identifiable<K> & ChildOf<? extends DataRoot>, K extends Identifier<N>> InstanceIdentifierBuilder<N> builder(final Class<N> listItem, final K listKey) { return new InstanceIdentifierBuilderImpl<N>().addNode(IdentifiableItem.of(listItem, listKey)); }
/** * Fetch the vBridge name from the given path argument, and set it * into {@code VNodePathConverter} instance. * * @param conv A {@link VNodePathConverter} instance. * @param arg A path argument which contains the vBridge name. */ @Override public void fetch(VNodePathConverter conv, PathArgument arg) { @SuppressWarnings("unchecked") IdentifiableItem<Vbridge, VbridgeKey> item = (IdentifiableItem<Vbridge, VbridgeKey>)arg; conv.bridgeName = item.getKey().getName(); }
/** * Fetch the VTN name from the given path argument, and set it into * {@code VNodePathConverter} instance. * * @param conv A {@link VNodePathConverter} instance. * @param arg A path argument which contains the VTN name. */ @Override public void fetch(VNodePathConverter conv, PathArgument arg) { @SuppressWarnings("unchecked") IdentifiableItem<Vtn, VtnKey> item = (IdentifiableItem<Vtn, VtnKey>)arg; conv.tenantName = item.getKey().getName(); }
@SuppressWarnings("unchecked") private Map<InstanceIdentifier, DataContainer> readUsingIdentifiableItem(final Iterable<Identifiable> dataList, final IdentifiableItem childArgument, final InstanceIdentifier parentPath) { final Identifier<?> key = childArgument.getKey(); for (Identifiable item : dataList) { if (key.equals(item.getKey()) && item instanceof DataContainer) { checkState(childArgument.getType().isInstance(item), "Found child is not instance of requested type"); InstanceIdentifier childPath = parentPath .child(childArgument.getType(), item.getKey()); return Collections.singletonMap(childPath, (DataContainer) item); } } return Collections.emptyMap(); }