@@ -0,0 +1,3234 @@
+package com.google.research.bleth.simulator;%0A%0Aimport org.reflections.Reflections;%0A%0Aimport java.lang.reflect.InvocationTargetException;%0Aimport java.util.ArrayList;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Set;%0A%0A/**%0A * A singleton class providing a methods for mapping strings to movement strategy objects and awakeness strategies types.%0A * In addition, the strategies mapper class provides methods for generating a list of strings representing all existing%0A * movement and awakeness strategies, to be used in the new simulation form.%0A */%0Apublic class StrategiesMapper %7B%0A%0A    private static StrategiesMapper instance = null;%0A    private HashMap%3CString, Class%3C? extends IMovementStrategy%3E%3E movement = new HashMap%3C%3E();%0A    private HashMap%3CString, AwakenessStrategyFactory.Type%3E awakeness = new HashMap%3C%3E();%0A%0A    /**%0A     * A static method to create an instance of the strategies mapper class.%0A     * @return the single instance of the mapper class.%0A     */%0A    public static StrategiesMapper getInstance() %7B%0A        if (instance == null) %7B%0A            instance = new StrategiesMapper();%0A        %7D%0A        return instance;%0A    %7D%0A%0A    /**%0A     * Create and return a new movement strategy based on the type provided as a string.%0A     * @param typeAsString a string indicating the type of movement strategy to create.%0A     * @return a movement strategy object.%0A     * @throws NoSuchMethodException if the concrete movement strategy does not have a declared constructor.%0A     * @throws IllegalAccessException if the concrete movement strategy's constructor is not accessible.%0A     * @throws InstantiationException if the instantiation fails.%0A     */%0A    public IMovementStrategy getMovementStrategy(String typeAsString)%0A            throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException %7B%0A        return movement.get(typeAsString).getDeclaredConstructor().newInstance();%0A    %7D%0A%0A    /**%0A     * Return the awakeness strategy type corresponding to the given string.%0A     * @param typeAsString a string indicating the type of awakeness strategy to return.%0A     * @return an awakeness strategy type.%0A     */%0A    public AwakenessStrategyFactory.Type getAwakenessStrategy(String typeAsString) %7B%0A        return awakeness.get(typeAsString);%0A    %7D%0A%0A    /** Return a list of all strings representing all existing movement strategies. */%0A    public List%3CString%3E listMovementStrategies() %7B%0A        return new ArrayList%3C%3E(movement.keySet());%0A    %7D%0A%0A    /** Return a list of all strings representing all existing awakeness strategies. */%0A    public List%3CString%3E listAwakenessStrategies() %7B%0A        return new ArrayList%3C%3E(awakeness.keySet());%0A    %7D%0A%0A    private StrategiesMapper() %7B%0A        Reflections reflections = new Reflections(%22com.google.research.bleth.simulator%22);%0A        Set%3CClass%3C? extends IMovementStrategy%3E%3E implementations = reflections.getSubTypesOf(IMovementStrategy.class);%0A        for (Class%3C? extends IMovementStrategy%3E impl : implementations) %7B%0A            movement.put(impl.toString(), impl);%0A        %7D%0A%0A        for (AwakenessStrategyFactory.Type type : AwakenessStrategyFactory.Type.values()) %7B%0A            awakeness.put(type.toString(), type);%0A        %7D%0A    %7D%0A%7D%0A

implement strategies mapper class.