commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alban Peignier <alban.peign...@free.fr>
Subject [lang] [proposal] UnsupportedImplementation
Date Fri, 04 Feb 2005 14:48:34 GMT
Hello,

These is an utility to create interface implementations which haven't
any implemantation.

Usefull to initialise no final dependencies :

private Comparator comparator = new
UnsupportedImplementation(Comparator.class).getInstance();

public void setComparator(Comparator comparator) {
	Validate.notNull(comparator);
	this.comparator = comparator;
}

public void doSomething() {
	// ...

	// no problem, comparator can't be null
	comparator.comparare(instance1, instance2);

	// ...
}

Or to create simple instances for tests, etc ...

A first enhancement could be use a specified Exception.

Hope it can be usefull.
-- 
Alban Peignier - alban.peignier@free.fr
http://people.tryphon.org/~alban


Mime
View raw message