All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nhl.link.move.runtime.key.KeyAdapterFactory Maven / Gradle / Ivy

There is a newer version: 3.0.M6
Show newest version
package com.nhl.link.move.runtime.key;

import java.util.HashMap;
import java.util.Map;

import com.nhl.link.move.mapper.ByteArrayKeyAdapter;
import com.nhl.link.move.mapper.KeyAdapter;

public class KeyAdapterFactory implements IKeyAdapterFactory {

	private KeyAdapter noopAdapter;
	private Map, KeyAdapter> adapters;

	public KeyAdapterFactory() {
		this.noopAdapter = new KeyAdapter() {

			@Override
			public Object toMapKey(Object rawKey) {
				return rawKey;
			}
			
			@Override
			public Object fromMapKey(Object mapKey) {
				return mapKey;
			}
		};

		this.adapters = new HashMap<>();
		this.adapters.put(byte[].class, new ByteArrayKeyAdapter());
	}

	@Override
	public KeyAdapter adapter(Class type) {
		KeyAdapter b = adapters.get(type);

		return b != null ? b : noopAdapter;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy