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

jnr.posix.SimpleFunctionMapper Maven / Gradle / Ivy

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);        
        }
    } 
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy