I have a method:
private Replace ReplaceType(final ReplaceTypeDao replaceTypeDao, final Long key) {
final Optional<ReplaceType> replaceTypeEntry = replaceTypeDao.findById(key, true);
if (!replaceTypeEntry.isPresent()) {
throw new TypeIsMissing(key);
}
return replaceTypeEntry.get();
}
which is exactly the same in other classes but from different packages. I could create class (but in which package?) with method replaceTypeProcess
, then call new class constructor and newClassInstance.replaceTypeProcess()
but I don't like this solution. How to do it in best manner?