@@ -337,6 +337,9 @@ public static Class<?> getMetamodelClassFor(String className) {
337337 }
338338
339339 public static File getMetaModelSourceFileFor (Class <?> clazz , boolean prefix ) {
340+ if ( clazz .isMemberClass () ) {
341+ return getMetaModelSourceFileFor ( clazz .getEnclosingClass (), prefix );
342+ }
340343 String metaModelClassName = getMetaModelClassName (clazz , prefix );
341344 // generate the file name
342345 String fileName = metaModelClassName .replace ( PACKAGE_SEPARATOR , PATH_SEPARATOR );
@@ -353,13 +356,17 @@ public static File getMetaModelSourceFileFor(String className) {
353356 }
354357
355358 private static String getMetaModelClassName (Class <?> clazz , boolean prefix ) {
356- return prefix
357- ? clazz .getPackageName () + '.' + META_MODEL_CLASS_POSTFIX + clazz .getSimpleName ()
358- : clazz .getName () + META_MODEL_CLASS_POSTFIX ;
359+ final String packageName = clazz .getPackageName ();
360+ return prefix ? packageName + '.' + META_MODEL_CLASS_POSTFIX + clazz .getName ().substring ( packageName .length () + 1 )
361+ .replaceAll ( "\\ $" , "\\ $_" )
362+ : packageName + clazz .getName ().substring ( packageName .length () )
363+ .replaceAll ( "\\ $" , "_\\ $" ) + META_MODEL_CLASS_POSTFIX ;
359364 }
360365
361366 private static String getMetaModelClassName (String className ) {
362- return className + META_MODEL_CLASS_POSTFIX ;
367+ final int index = className .lastIndexOf ( '.' );
368+ final String packageName = className .substring ( 0 , index + 1 );
369+ return packageName + className .substring ( packageName .length () ).replaceAll ( "\\ $" , "_\\ $" ) + META_MODEL_CLASS_POSTFIX ;
363370 }
364371
365372 public static String getMetaModelSourceAsString (Class <?> clazz ) {
0 commit comments