import org.wamblee.xmlrouter.config.RouterConfig;
import org.wamblee.xmlrouter.config.Transformation;
+// TODO implement copying of routerconfig.
+
/**
* Represents a single configuration set of a single configuration client of the
* XML router.
*/
public class SingleRouterConfig implements ExtendedRouterConfig {
private Id<RouterConfig> id;
+
private ExtendedConfig<DocumentType> documentTypes;
private ExtendedConfig<Transformation> transformations;
private ExtendedConfig<Filter> filters;
/**
* Constructs a router configuration.
*
- * @param aSequenceNumberGenerator
- * Sequence number generator to use.
+ * @param aId
+ * Unique id for this configuration.
*/
public SingleRouterConfig(Id<RouterConfig> aId) {
id = aId;
documentTypes = new ConfigImpl<DocumentType>(new Id<Config>(
- "documentTypes")) {
+ aId.getId() + ".documenttypes")) {
@Override
public DocumentType wrap(String aPrefix, DocumentType aT) {
return new RobustDocumentType(aPrefix, aT);
}
};
transformations = new ConfigImpl<Transformation>(new Id<Config>(
- "transformations")) {
+ aId.getId() + ".transformations")) {
@Override
public Transformation wrap(String aPrefix,
Transformation aTransformation) {
return new RobustTransformation(aPrefix, aTransformation);
}
};
- filters = new ConfigImpl<Filter>(new Id<Config>("filters")) {
+ filters = new ConfigImpl<Filter>(new Id<Config>(aId.getId() +
+ ".filters")) {
@Override
public Filter wrap(String aPrefix, Filter aFilter) {
return new RobustFilter(aPrefix, aFilter);
};
}
- // TODO test getId.
@Override
public Id<RouterConfig> getId() {
return id;
public Config<Filter> filterConfig() {
return filters;
}
+
+ @Override
+ public boolean equals(Object aObj) {
+ if (aObj == null) {
+ return false;
+ }
+ if (!(aObj instanceof SingleRouterConfig)) {
+ return false;
+ }
+ SingleRouterConfig obj = (SingleRouterConfig) aObj;
+
+ return documentTypes.equals(obj.documentTypes) &&
+ transformations.equals(obj.transformations) &&
+ filters.equals(obj.filters);
+ }
+
+ @Override
+ public int hashCode() {
+ return documentTypes.hashCode() + transformations.hashCode() +
+ filters.hashCode();
+ }
}