* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.pcep.spi.pojo;
-import com.google.common.primitives.Ints;
-
import io.netty.buffer.ByteBuf;
-
import java.util.Optional;
import org.opendaylight.protocol.concepts.HandlerRegistry;
import org.opendaylight.protocol.pcep.spi.ObjectParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.EnterpriseSpecificInformation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.DataContainer;
public class SimpleVendorInformationObjectRegistry implements VendorInformationObjectRegistry {
-
private final HandlerRegistry<DataContainer, ObjectParser, ObjectSerializer> handlers = new HandlerRegistry<>();
- public AutoCloseable registerVendorInformationObjectParser(final EnterpriseNumber enterpriseNumber, final ObjectParser parser) {
- return this.handlers.registerParser(Ints.checkedCast(enterpriseNumber.getValue()), parser);
+ public Registration registerVendorInformationObjectParser(final EnterpriseNumber enterpriseNumber,
+ final ObjectParser parser) {
+ return this.handlers.registerParser(enterpriseNumber.getValue().intValue(), parser);
}
- public AutoCloseable registerVendorInformationObjectSerializer(final Class<? extends EnterpriseSpecificInformation> esInformationClass, final ObjectSerializer serializer) {
+ public Registration registerVendorInformationObjectSerializer(
+ final Class<? extends EnterpriseSpecificInformation> esInformationClass,
+ final ObjectSerializer serializer) {
return this.handlers.registerSerializer(esInformationClass, serializer);
}
@Override
- public Optional<? extends Object> parseVendorInformationObject(final EnterpriseNumber enterpriseNumber, final ObjectHeader header, final ByteBuf buffer)
+ public Optional<? extends Object> parseVendorInformationObject(final EnterpriseNumber enterpriseNumber,
+ final ObjectHeader header, final ByteBuf buffer)
throws PCEPDeserializerException {
- final ObjectParser parser = this.handlers.getParser(Ints.checkedCast(enterpriseNumber.getValue()));
+ final ObjectParser parser = this.handlers.getParser(enterpriseNumber.getValue().intValue());
if (parser == null) {
if (!header.isProcessingRule()) {
return Optional.empty();
@Override
public void serializeVendorInformationObject(final VendorInformationObject viObject, final ByteBuf buffer) {
- final ObjectSerializer serializer = this.handlers.getSerializer(viObject.getEnterpriseSpecificInformation().getImplementedInterface());
+ final ObjectSerializer serializer = this.handlers.getSerializer(
+ viObject.getEnterpriseSpecificInformation().implementedInterface());
if (serializer == null) {
return;
}
serializer.serializeObject(viObject, buffer);
}
-
}