@@ -42,10 +42,10 @@ private static boolean isArray(String key) {
4242 /**
4343 * Internal use only for provider overriding purposes
4444 *
45- * @param basicObject Current object
45+ * @param basicObject Current object
4646 * @param collectionName Name of collection
47- * @param way Passed way
48- * @param <T> Adaptor type
47+ * @param way Passed way
48+ * @param <T> Adaptor type
4949 * @return return Adaptor instance
5050 * @throws DataException In case provider could not be initialized
5151 */
@@ -54,9 +54,9 @@ private static boolean isArray(String key) {
5454 /**
5555 * Internal use only for provider overriding purposes
5656 *
57- * @param basicObject Current object
57+ * @param basicObject Current object
5858 * @param collectionName Name of collection
59- * @param <T> Adaptor type
59+ * @param <T> Adaptor type
6060 * @return return Adaptor instance
6161 * @throws DataException In case provider c
6262 */
@@ -66,7 +66,7 @@ private static boolean isArray(String key) {
6666 * Internal use only for provider overriding purposes
6767 *
6868 * @param collectionName Name of collection
69- * @param <T> Adaptor type
69+ * @param <T> Adaptor type
7070 * @return Adaptor instance
7171 * @throws DataException In case provider could not be initialized
7272 */
@@ -296,23 +296,38 @@ public String getValue() throws DataException {
296296
297297 if (result == null ) {
298298 if (this .way != null && this .way .contains ("." )) {
299- this .way = this .way .split ( "[.]" )[ this . way .split ( "[.]" ). length - 1 ] ;
299+ this .way = this .way .substring ( way .lastIndexOf ( "." ) + 1 ) ;
300300 }
301301
302- result = this .basicObject .getString (this .way );
303- }
304- if (result == null ) {
305- this .basicObject .keySet ().stream ().forEach (s -> {
306- try {
307- AbstractDataProvider instance = createInstance (basicObject , collectionName , way + "." + s );
308- instance .applyGenerator (callback );
309- this .basicObject .put (s , instance .getValue ());
310- } catch (DataException e ) {
311- e .printStackTrace ();
312- }
302+ if (!(basicObject .get (way ) instanceof BasicDBObject )) {
303+ result = basicObject .getString (way );
304+ }
313305
314- });
315- result = basicObject .toString ();
306+ if (result == null ) {
307+
308+ BasicDBObject dbObject = new BasicDBObject ();
309+
310+ basicObject .keySet ().stream ().forEach (s -> {
311+ try {
312+ AbstractDataProvider instance = createInstance ((BasicDBObject ) basicObject .get (s ), collectionName , way + "." + s );
313+ instance .applyGenerator (callback );
314+ dbObject .put (s , instance .getValue ());
315+ } catch (ClassCastException e ) {
316+ AbstractDataProvider instance = null ;
317+ try {
318+ instance = createInstance ((BasicDBObject ) basicObject , collectionName , way + "." + s );
319+ instance .applyGenerator (callback );
320+ dbObject .put (s , instance .getValue ());
321+ } catch (DataException e1 ) {
322+ e1 .printStackTrace ();
323+ }
324+ } catch (DataException e ) {
325+ e .printStackTrace ();
326+ }
327+
328+ });
329+ result = dbObject .toString ();
330+ }
316331 }
317332 return applyCallBackData (result );
318333 }
0 commit comments