jnr.posix.SimpleFunctionMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jnr-unixsocket-nodep Show documentation
Show all versions of jnr-unixsocket-nodep Show documentation
com.github.jnr:jnr-unixsocket with orh.objectweb.asm shaded
The newest version!
package jnr.posix;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class SimpleFunctionMapper implements jnr.ffi.mapper.FunctionMapper {
private final Map functionNameMap;
private SimpleFunctionMapper(Map map) {
functionNameMap = Collections.unmodifiableMap(new HashMap(map));
}
public String mapFunctionName(String functionName, Context context) {
String nativeFunction = functionNameMap.get(functionName);
return nativeFunction != null ? nativeFunction : functionName;
}
public static class Builder {
private final Map functionNameMap = Collections.synchronizedMap(new HashMap());
public Builder map(String posixName, String nativeFunction) {
functionNameMap.put(posixName, nativeFunction);
return this;
}
public SimpleFunctionMapper build() {
return new SimpleFunctionMapper(functionNameMap);
}
}
}