org.osgl.inject.KeyExtractor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of genie Show documentation
Show all versions of genie Show documentation
A JSR330 style dependency injection solution
package org.osgl.inject;
import org.osgl.$;
/**
* `KeyExtractor` can be used to extract or derive "key" from
* a value data. The result "key" can be used to index the value
* in a {@link java.util.Map} data structure.
*
* A general contract implementation must obey is
* different value must generate different key
*
* @param generic type of the key
* @param generic type of the value
*/
public interface KeyExtractor {
/**
* Get the key of data
*
* @param hint optional, a string value provides hint to extract key
* @param data the value data
* @return the key of the data
*/
K keyOf(String hint, V data);
class PropertyExtractor implements KeyExtractor {
@Override
public Object keyOf(String hint, Object data) {
return $.getProperty(data, hint);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy