jpaul.DataStructs.MapSetRelationFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jpaul Show documentation
Show all versions of jpaul Show documentation
This library was originally developed by people listed at http://jpaul.sourceforge.net.
The newest version!
// MapSetRelationFactory.java, created Mon Jul 4 09:24:08 2005 by salcianu
// Copyright (C) 2005 Alexandru Salcianu
// Licensed under the Modified BSD Licence; see COPYING for details.
package jpaul.DataStructs;
import java.util.Set;
/**
* MapSetRelationFactory
generates
* MapSetRelation
s that use a specific
* MapFactory
and a specific SetFactory
.
*
* @see MapSetRelation
*
* @author Alexandru Salcianu - [email protected]
* @version $Id: MapSetRelationFactory.java,v 1.9 2006/03/14 02:29:31 salcianu Exp $ */
class MapSetRelationFactory extends RelationFactory {
/** Default constructor: creates a
MapSetRelationFactory
based on a
HashMap
factory and a
HashSet
factory.
@see #MapSetRelationFactory(MapFactory, SetFactory)
@see jpaul.DataStructs.SetFacts#hash() SetFacts.hash()
@see jpaul.DataStructs.MapFacts#hash() MapFacts.hash() */
public MapSetRelationFactory() {
this(MapFacts.>hash(), SetFacts.hash());
}
/** Creates a MapSetRelationFactory
that will
generate MapSetRelation
s that use the map factory
mapFact
and the set factory setFact
.
This constructor allows the programmer to finely tune the kind
of relation that he wants. */
public MapSetRelationFactory(MapFactory> mapFact, SetFactory setFact) {
this.mapFact = mapFact;
this.setFact = setFact;
}
private final MapFactory> mapFact;
private final SetFactory setFact;
public Relation create() {
return new MapSetRelation(mapFact, setFact);
}
public Relation create(Relation r) {
if(r instanceof MapSetRelation/**/) {
MapSetRelation msr = (MapSetRelation) r;
return msr.clone();
}
return super.create(r);
}
}