title: Refactoring into Java 8 stream
body: <p>i have method that viewed under message.
  I want refactored this method from "for each" to stream view
  like myCollect.stream().collect(Collectors.toMap(..)))
  but don't understand how it does work Collectors.toMap(..).</p>
  
  <pre><code>private &lt;T extends Entity&gt; Map&lt;String, Object&gt; prepareEntity(T entity) throws Exception {
          Map&lt;String, Object&gt; preparedEntity = new LinkedHashMap&lt;&gt;(Collections.EMPTY_MAP);
          Objects.requireNonNull(entity);
          Class clazz = entity.getClass();
  
          List&lt;Field&gt; openFields = getDeclaredFields(clazz, Collections.EMPTY_LIST);
  
          for (Field field : openFields) {
              field.setAccessible(true);
              preparedEntity.put(field.getName(), field.getType().equals(Boolean.class)
                      ? ("true".equals(field.get(entity).toString())) ? 1 : 0
                      : field.get(entity));
          }
  
          return preparedEntity;
      }
  </code></pre>