/*
 * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * 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.concepts;

import javax.annotation.concurrent.ThreadSafe;

@ThreadSafe
public class HandlerRegistry<CLASS, PARSER, SERIALIZER> {
	private final MultiRegistry<Class<? extends CLASS>, SERIALIZER> serializers = new MultiRegistry<>();
	private final MultiRegistry<Integer, PARSER> parsers = new MultiRegistry<>();

	public AbstractRegistration registerParser(final int type, final PARSER parser) {
		return parsers.register(type, parser);
	}

	public PARSER getParser(final int type) {
		return parsers.get(type);
	}

	public AbstractRegistration registerSerializer(final Class<? extends CLASS> clazz, final SERIALIZER serializer) {
		return serializers.register(clazz, serializer);
	}

	public SERIALIZER getSerializer(final Class<? extends CLASS> clazz) {
		return serializers.get(clazz);
	}
}

/*
 * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * 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.concepts;

import javax.annotation.concurrent.ThreadSafe;

@ThreadSafe
public class HandlerRegistry<C, P, S> {
	private final MultiRegistry<Class<? extends C>, S> serializers = new MultiRegistry<>();
	private final MultiRegistry<Integer, P> parsers = new MultiRegistry<>();

	public AbstractRegistration registerParser(final int type, final P parser) {
		return parsers.register(type, parser);
	}

	public P getParser(final int type) {
		return parsers.get(type);
	}

	public AbstractRegistration registerSerializer(final Class<? extends C> clazz, final S serializer) {
		return serializers.register(clazz, serializer);
	}

	public S getSerializer(final Class<? extends C> clazz) {
		return serializers.get(clazz);
	}
}

Rename generic arguments to silence sonar
Rename generic arguments to silence sonar

Change-Id: Ie578bbfb3a82e7c33cdd4c9abd4d8d43d2e0d35e
Signed-off-by: Robert Varga <b8bd3df785fdc0ff42dd1710c5d91998513c57ef@cisco.com>
