mirror of
https://github.com/apache/openjpa.git
synced 2025-02-24 11:37:21 +00:00
OPENJPA-1386: Support field types that can hide each other
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@835756 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6ae4adf687
commit
6e630e827e
@ -99,6 +99,12 @@ public class SourceCode {
|
||||
String pkgName = name.getPackageName();
|
||||
if ("java.lang".equals(pkgName))
|
||||
return false;
|
||||
for (Import i : imports) {
|
||||
if (i.getClassName().hides(name)) {
|
||||
i.getClassName().useFullName();
|
||||
name.useFullName();
|
||||
}
|
||||
}
|
||||
return imports.add(new Import(name));
|
||||
}
|
||||
|
||||
@ -584,6 +590,8 @@ public class SourceCode {
|
||||
}
|
||||
|
||||
public void write(PrintWriter out, int tab) {
|
||||
if (name.usingFullName())
|
||||
return;
|
||||
String pkg = name.getPackageName();
|
||||
if (pkg.length() == 0 || pkg.equals(getPackage().name))
|
||||
return;
|
||||
@ -597,6 +605,10 @@ public class SourceCode {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ClassName getClassName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -729,6 +741,7 @@ public class SourceCode {
|
||||
public final String simpleName;
|
||||
public final String pkgName;
|
||||
private String arrayMarker = BLANK;
|
||||
private boolean useFullName = false;
|
||||
|
||||
ClassName(String name) {
|
||||
while (isArray(name)) {
|
||||
@ -769,10 +782,10 @@ public class SourceCode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the simple name of this receiver.
|
||||
* Gets the full or simple name of this receiver based on useFullName flag.
|
||||
*/
|
||||
public String toString() {
|
||||
return getSimpleName();
|
||||
return (useFullName ? fullName : simpleName) + arrayMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -806,6 +819,19 @@ public class SourceCode {
|
||||
name.substring(0, name.length()-"[]".length());
|
||||
}
|
||||
|
||||
boolean hides(ClassName other) {
|
||||
return this.getSimpleName().equals(other.getSimpleName())
|
||||
&& !this.fullName.equals(other.fullName);
|
||||
}
|
||||
|
||||
void useFullName() {
|
||||
useFullName = true;
|
||||
}
|
||||
|
||||
boolean usingFullName() {
|
||||
return useFullName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static {
|
||||
|
Loading…
x
Reference in New Issue
Block a user