One of my biggest annoyances with the Windchill libraries is that whenever you encounter a WTCollection type in some code, there is no way to know what kind of item will return from it's get and it's getPersistable method.
For example:
foo()
{
QuerySpec spec=new QuerySpec(PartList.class);
//...build query here
WTCollection parts=(WTCollection)PersistenceHelper.manager.find(spec,new WTArrayList());
Iterator<WTPart> iter=parts.persistableIterator(); //<---COMPILES FINE, BUT WILL THROW RUNTIME EXCEPTION
while(iter.hasNext())
{
//....etc....
}
}
There is no way to know until you go to run it if the WTCollection "parts" actually contains WTPart objects.
If it doesn't, you'll get a runtime exception.
What I'd like to see is all of the collection type objects in Windchill modified to support type parameterization
example:
foo()
{
QuerySpec<PartList> spec=new QuerySpec();
//....build query here....
WTCollection<WTPart>=(WTCollection<WTPart>)PersistenceHelper.manager.find(spec,new WTArrayList<WTPart>); //<---COMPILER ERROR
Iterator<WTPart> iter=parts.persistableIterator();
while(iter.hasNext())
{
//....etc....
}
}
In the case of getPersistableIterator, we expect it to return WTPart or PartList.
In the case of getIterator(), we would expect it to return a parameterized WTReference
example:
Iterator<WTReference<WTPart>> refIter=parts.iterator();
This would remove a MASSIVE headache for me as a developer.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.