link
Avalon
Merlin Runtime
Home PlanetProductsCentral
Criteria
Overview

The criteria package contains a parameterize Map implementation. A set of parameters are supplied on creation that are used by the implementation to (a) qualify values supplied, and (b) resolve values that are requested.

Example

The criteria object created below is now restricted to the two keys "name" and "home". The user of the class can assign String values which will be resolved to the type of object declared by the corresponding parameter object.

Parameter[] params = new Parameter[]{
  new Parameter( "name", String.class, null ),
  new Parameter( "home", 
   File.class, new File( System.getProperty( "user.dir" ) ) ) };
Map criteria = new Criteria( params );
        

For example:

public void setParameters( Map map )
{
    map.put( "home", "my-directory" );

    //
    // now just for fun - lets get the value using the "home"
    // key as a File
    //

    File home = (File) map.get( "home" );

    //
    // and just to prove the point - we can also put values
    // directory into the map the correspond to the parameterized 
    // type .. e.g.:
    // 

    map.put( "home", home );

}

What all this means is that a we have a type safe Map implementation.