@Test public void testToInstanceIdentifier() { String restPath = INTERFACE_PATH + INTERFACE_KEY_START + INTERFACE_NAME + INTERFACE_KEY_END; Optional<InstanceIdentifier<Interface>> optIid = VppPathMapper.interfaceToInstanceIdentifier(restPath); Assert.assertTrue(optIid.isPresent()); InstanceIdentifier<Interface> iid = optIid.get(); Assert.assertNotNull(iid); Assert.assertEquals(INTERFACE_KEY, iid.firstKeyOf(Interface.class)); }
public static Optional<InstanceIdentifier<Interface>> interfaceToInstanceIdentifier(@Nullable String restPath) { if (Strings.isNullOrEmpty(restPath)) { return Optional.absent(); } if (restPath.length() < INTERFACE_PATH_MIN_LENGTH) { return Optional.absent(); } if (!restPath.startsWith(INTERFACE_PATH_BEFORE_KEY)) { return Optional.absent(); } if (!restPath.endsWith(INTERFACE_PATH_AFTER_KEY)) { return Optional.absent(); } int endIndexInterfaceName = restPath.length() - INTERFACE_PATH_AFTER_KEY.length(); String interfaceName = restPath.substring(INTERFACE_PATH_BEFORE_KEY.length(), endIndexInterfaceName); return Optional.of(VppIidFactory.getInterfaceIID(new InterfaceKey(interfaceName))); }
VppPathMapper { public static Optional<InstanceIdentifier<Interface>> interfaceToInstanceIdentifier(@Nullable String restPath) { if (Strings.isNullOrEmpty(restPath)) { return Optional.absent(); } if (restPath.length() < INTERFACE_PATH_MIN_LENGTH) { return Optional.absent(); } if (!restPath.startsWith(INTERFACE_PATH_BEFORE_KEY)) { return Optional.absent(); } if (!restPath.endsWith(INTERFACE_PATH_AFTER_KEY)) { return Optional.absent(); } int endIndexInterfaceName = restPath.length() - INTERFACE_PATH_AFTER_KEY.length(); String interfaceName = restPath.substring(INTERFACE_PATH_BEFORE_KEY.length(), endIndexInterfaceName); return Optional.of(VppIidFactory.getInterfaceIID(new InterfaceKey(interfaceName))); } }
VppPathMapper { public static Optional<InstanceIdentifier<Interface>> interfaceToInstanceIdentifier(@Nullable String restPath) { if (Strings.isNullOrEmpty(restPath)) { return Optional.absent(); } if (restPath.length() < INTERFACE_PATH_MIN_LENGTH) { return Optional.absent(); } if (!restPath.startsWith(INTERFACE_PATH_BEFORE_KEY)) { return Optional.absent(); } if (!restPath.endsWith(INTERFACE_PATH_AFTER_KEY)) { return Optional.absent(); } int endIndexInterfaceName = restPath.length() - INTERFACE_PATH_AFTER_KEY.length(); String interfaceName = restPath.substring(INTERFACE_PATH_BEFORE_KEY.length(), endIndexInterfaceName); return Optional.of(VppIidFactory.getInterfaceIID(new InterfaceKey(interfaceName))); } private  VppPathMapper(); }
VppPathMapper { public static Optional<InstanceIdentifier<Interface>> interfaceToInstanceIdentifier(@Nullable String restPath) { if (Strings.isNullOrEmpty(restPath)) { return Optional.absent(); } if (restPath.length() < INTERFACE_PATH_MIN_LENGTH) { return Optional.absent(); } if (!restPath.startsWith(INTERFACE_PATH_BEFORE_KEY)) { return Optional.absent(); } if (!restPath.endsWith(INTERFACE_PATH_AFTER_KEY)) { return Optional.absent(); } int endIndexInterfaceName = restPath.length() - INTERFACE_PATH_AFTER_KEY.length(); String interfaceName = restPath.substring(INTERFACE_PATH_BEFORE_KEY.length(), endIndexInterfaceName); return Optional.of(VppIidFactory.getInterfaceIID(new InterfaceKey(interfaceName))); } private  VppPathMapper(); static String interfaceToRestPath(String interfaceName); static Optional<InstanceIdentifier<Interface>> interfaceToInstanceIdentifier(@Nullable String restPath); static Optional<String> interfacePathToInterfaceName(@Nullable String restPath); static String bridgeDomainToRestPath(String bridgeDomainName); }
VppPathMapper { public static Optional<InstanceIdentifier<Interface>> interfaceToInstanceIdentifier(@Nullable String restPath) { if (Strings.isNullOrEmpty(restPath)) { return Optional.absent(); } if (restPath.length() < INTERFACE_PATH_MIN_LENGTH) { return Optional.absent(); } if (!restPath.startsWith(INTERFACE_PATH_BEFORE_KEY)) { return Optional.absent(); } if (!restPath.endsWith(INTERFACE_PATH_AFTER_KEY)) { return Optional.absent(); } int endIndexInterfaceName = restPath.length() - INTERFACE_PATH_AFTER_KEY.length(); String interfaceName = restPath.substring(INTERFACE_PATH_BEFORE_KEY.length(), endIndexInterfaceName); return Optional.of(VppIidFactory.getInterfaceIID(new InterfaceKey(interfaceName))); } private  VppPathMapper(); static String interfaceToRestPath(String interfaceName); static Optional<InstanceIdentifier<Interface>> interfaceToInstanceIdentifier(@Nullable String restPath); static Optional<String> interfacePathToInterfaceName(@Nullable String restPath); static String bridgeDomainToRestPath(String bridgeDomainName);  }