package com.cedarsoft.spring.rcp.tree.layered;
import com.cedarsoft.NotFoundException;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
/**
* Configuration for the children
*/
public class LayersConfiguration {
/**
* Returns the layer configuration
*
* @param parentType the parent type
* @return the layer configuration
* @throws NotFoundException
*/
@NotNull
public <P, C> TreeLayer<P, C> getLayer( @NotNull Class<P> parentType ) throws NotFoundException {
TreeLayer<?, ?> tree = configurations.get( parentType );
if ( tree == null ) {
throw new NotFoundException( "No tree layer found for " + parentType );
}
return ( TreeLayer<P, C> ) tree;
}
@NotNull
private final Map<Class<?>, TreeLayer<?, ?>> configurations = new HashMap<Class<?>, TreeLayer<?, ?>>();
public <P, C> void addConfiguration( @NotNull Class<P> parentType, TreeLayer<P, C> tree ) {
configurations.put( parentType, tree );
}
}