Author: hardy.ferentschik
Date: 2010-09-27 13:32:37 -0400 (Mon, 27 Sep 2010)
New Revision: 20726
Modified:
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ImportContextImpl.java
Log:
METAGEN-30 Made member variables private and cleaned up some code
Modified:
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ImportContextImpl.java
===================================================================
---
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ImportContextImpl.java 2010-09-27
17:31:42 UTC (rev 20725)
+++
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/ImportContextImpl.java 2010-09-27
17:32:37 UTC (rev 20726)
@@ -34,11 +34,11 @@
*/
public class ImportContextImpl implements ImportContext {
- Set<String> imports = new TreeSet<String>();
- Set<String> staticImports = new TreeSet<String>();
- Map<String, String> simpleNames = new HashMap<String, String>();
+ private Set<String> imports = new TreeSet<String>();
+ private Set<String> staticImports = new TreeSet<String>();
+ private Map<String, String> simpleNames = new HashMap<String, String>();
- String basePackage = "";
+ private String basePackage = "";
private static final Map<String, String> PRIMITIVES = new HashMap<String,
String>();
@@ -161,15 +161,13 @@
StringBuffer buf = new StringBuffer();
for ( String next : imports ) {
- if ( isPrimitive( next ) || inDefaultPackage( next ) || inJavaLang( next ) ||
inSamePackage( next ) ) {
- // dont add automatically "imported" stuff
- }
- else {
+ // don't add automatically "imported" stuff
+ if ( !isAutoImported( next ) ) {
if ( staticImports.contains( next ) ) {
- buf.append( "import static " + next + ";\r\n" );
+ buf.append( "import static " ).append( next ).append( ";\r\n"
);
}
else {
- buf.append( "import " + next + ";\r\n" );
+ buf.append( "import " ).append( next ).append( ";\r\n" );
}
}
}
@@ -180,9 +178,13 @@
return buf.toString();
}
+ private boolean isAutoImported(String next) {
+ return isPrimitive( next ) || inDefaultPackage( next ) || inJavaLang( next ) ||
inSamePackage( next );
+ }
+
public static String unqualify(String qualifiedName) {
- int loc = qualifiedName.lastIndexOf( "." );
- return ( loc < 0 ) ? qualifiedName : qualifiedName.substring(
qualifiedName.lastIndexOf( "." ) + 1 );
+ int loc = qualifiedName.lastIndexOf( '.' );
+ return ( loc < 0 ) ? qualifiedName : qualifiedName.substring(
qualifiedName.lastIndexOf( '.' ) + 1 );
}
public static String qualifier(String qualifiedName) {
Show replies by date