In Eclipse, how do I change the default modifiers in the class/type template?
- by gustafc
Eclipse's default template for new types (Window Preferences Code Style Code Templates New Java Files) looks like this:
${filecomment}
${package_declaration}
${typecomment}
${type_declaration}
Creating a new class, it'll look something like this:
package pkg;
import blah.blah;
public class FileName {
// Class is accessible to everyone, and can be inherited
}
Now, I'm fervent in my belief that access should be as restricted as possible, and inheritance should be forbidden unless explicitly permitted, so I'd like to change the ${type_declaration} to declare all classes as final rather than public:
package pkg;
import blah.blah;
final class FileName {
// Class is only accessible in package, and can't be inherited
}
That seems easier said than done. The only thing I've found googling is a 2004 question on Eclipse's mailing list which was unanswered.
So, the question in short: How can I change the default class/type modifiers in Eclipse?
I'm using Eclipse Galileo (3.5) if that matters.