Package com.cedarsoft.spring.rcp.tree.layered

Source Code of com.cedarsoft.spring.rcp.tree.layered.LayersConfiguration

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

Related Classes of com.cedarsoft.spring.rcp.tree.layered.LayersConfiguration

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.