I have two methods like
public void updateA (Object obj) throws CommonException
{
if ( !(obj instanceof A) )
{
throw new CommonException(obj);
}
}
public void updateB (Object obj) throws CommonException
{
if ( !(obj instanceof B) )
{
throw new CommonException(obj);
}
}
Now I want to extract the instance verification part into a separate method. Can the following be done?
public void chkInstance (Object obj, Class classType) throws CommonException
{
if ( !(obj instanceof classType) )
{
throw new CommonException(obj);
}
}
source
share