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

org.srplib.model.MapPropertyAdapterFactory Maven / Gradle / Ivy

The newest version!
package org.srplib.model;

import java.util.Map;

import org.srplib.contract.Argument;

/**
 * Implementation of {@link PropertyAdapterFactory} which creates instances of {@link ValueModel} for value of map under
 * specified keys.
 *
 * @author Anton Pechinsky
 */
public class MapPropertyAdapterFactory implements PropertyAdapterFactory {

    private Map map;

    /**
     * Creates factory for specified map.
     *
     * @param map a Map to create value models for.
     */
    public MapPropertyAdapterFactory(Map map) {
        Argument.checkNotNull(map, "Map must not be null!");
        this.map = map;
    }

    /**
     * Creates factory.
     */
    public MapPropertyAdapterFactory() {
    }

    @Override
    public ValueModel newAdapter(String property) {
        return map == null
            ? new MapValueAdapter((Class)null, property)
            : new MapValueAdapter(map, property);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy