@@ -335,6 +335,9 @@ public static Class<?> getMetamodelClassFor(String className) {
335335 }
336336
337337 public static File getMetaModelSourceFileFor (Class <?> clazz , boolean prefix ) {
338+ if ( clazz .isMemberClass () ) {
339+ return getMetaModelSourceFileFor ( clazz .getEnclosingClass (), prefix );
340+ }
338341 String metaModelClassName = getMetaModelClassName (clazz , prefix );
339342 // generate the file name
340343 String fileName = metaModelClassName .replace ( PACKAGE_SEPARATOR , PATH_SEPARATOR );
@@ -351,13 +354,17 @@ public static File getMetaModelSourceFileFor(String className) {
351354 }
352355
353356 private static String getMetaModelClassName (Class <?> clazz , boolean prefix ) {
354- return prefix
355- ? clazz .getPackageName () + '.' + META_MODEL_CLASS_POSTFIX + clazz .getSimpleName ()
356- : clazz .getName () + META_MODEL_CLASS_POSTFIX ;
357+ final String packageName = clazz .getPackageName ();
358+ return prefix ? packageName + '.' + META_MODEL_CLASS_POSTFIX + clazz .getName ().substring ( packageName .length () + 1 )
359+ .replaceAll ( "\\ $" , "\\ $_" )
360+ : packageName + clazz .getName ().substring ( packageName .length () )
361+ .replaceAll ( "\\ $" , "_\\ $" ) + META_MODEL_CLASS_POSTFIX ;
357362 }
358363
359364 private static String getMetaModelClassName (String className ) {
360- return className + META_MODEL_CLASS_POSTFIX ;
365+ final int index = className .lastIndexOf ( '.' );
366+ final String packageName = className .substring ( 0 , index + 1 );
367+ return packageName + className .substring ( packageName .length () ).replaceAll ( "\\ $" , "_\\ $" ) + META_MODEL_CLASS_POSTFIX ;
361368 }
362369
363370 public static String getMetaModelSourceAsString (Class <?> clazz ) {
0 commit comments