org.srplib.model.MapPropertyAdapterFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of srp-model-support Show documentation
Show all versions of srp-model-support Show documentation
Single Responsibility Principle (SRP) libraries collection
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);
}
}