public static List<Tuple> extractTuplesFromObject(Object obj) {
		if ( obj instanceof Iterable ) {
			Iterable<?> it = (Iterable) obj;
			return StreamSupport.stream( it.spliterator(), false )
					.map( TupleExtractor::extractFromObject )
					.collect( Collectors.toList() );
		}
		Tuple tuple = new Tuple();
		tuple.put( "result", obj );
		return Collections.singletonList( tuple );
	}
public static List < Tuple > extractTuplesFromObject ( Object obj ) { if ( obj instanceof Iterable ) { Iterable < ? > it = ( Iterable ) obj ; return StreamSupport . stream ( it . spliterator ( ) , false ) . map ( TupleExtractor :: extractFromObject ) . collect ( Collectors . toList ( ) ) ; } Tuple tuple = new Tuple ( ) ; tuple . put ( "result" , obj ) ; return Collections . singletonList ( tuple ) ; }
<p>
Extract {@link Tuple} values from given object. If the given object is an {@link Iterable} a list of tuples extracted from its
elements will be returned. Otherwise, a single element list with a {@link Tuple} of key 'result' and value of 'obj' itself will
be returned.
</p>
<p>
If given object is an {@link Iterable}, this method also try to determine its element type. If the element is a
{@link Map}, a {@link Tuple} with equivalent key/value will be extracted. Otherwise, element is treated as a POJO
and introspected values will be returned.
</p>
<p>
Examples:
<pre>{@code
// equivalent to List [ Tuple( key, value ) ]
TupleExtractor.extractTuplesFromObject( singleton( singletonMap( "key", "value" ) ) );
// equivalent to List [ Tuple( key, value ) ]
TupleExtractor.extractTuplesFromObject( singleton( new Subject( "key", "value" ) ) );
// equivalent to List [ Tuple( result, 1 ) ]
TupleExtractor.extractTuplesFromObject( 1 );
}</pre>
</p>

@param obj object to be extracted

@return list tuple result