package com.insightfullogic.java8.examples.chapter7;

import java.util.List;
import java.util.function.ToLongFunction;

import com.insightfullogic.java8.examples.chapter1.Album;

public class CountLengthFixed {
	
	private List<Album> albums;

	public long countFeature(ToLongFunction<Album> function){
		return albums.stream().mapToLong(function).sum();
	}
}

@@ -179,16 +179,36 @@
 bum;%0D%0A%0D%0A
+// CountLength%C4%BB,%C8%A1%CD%AC%0D%0A
 public c
@@ -236,11 +236,10 @@
  %7B%0D%0A
-%09
 %0D%0A
+
 %09pri
@@ -323,16 +323,17 @@
 unction)
+ 
 %7B%0D%0A%09%09ret
@@ -383,12 +383,347 @@
 ();%0D%0A%09%7D%0D
+%0A%0D%0A%09public long countRunningTime() %7B%0D%0A%09%09return countFeature(album -%3E album.getTracks().mapToLong(track -%3E track.getLength()).sum());%0D%0A%09%7D%0D%0A%0D%0A%09public long countMusicians() %7B%0D%0A%09%09return countFeature(album -%3E album.getMusicians().count());%0D%0A%09%7D%0D%0A%0D%0A%09public long countTracks() %7B%0D%0A%09%09return countFeature(album -%3E album.getTracks().count());%0D%0A%09%7D%0D
 %0A%7D%0D%0A

complete CountLengthFixed class in chapter7