package com.insightfullogic.java8.examples.chapter1;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.Collections.unmodifiableList;
import static java.util.stream.Collectors.toList;

public final class Album implements Performance {
	
	private String name;
	private List<Track> tracks;
	private List<Artist> musicians;

	public Album(String name, List<Track> tracks, List<Artist> musicians) {
		Objects.requireNonNull(name);
		Objects.requireNonNull(tracks);
		Objects.requireNonNull(musicians);

		this.name = name;
		this.tracks = tracks;
		this.musicians = musicians;
	}
	
	public String getName(){
		return name;
	}
	
	public Stream<Track> getTracks() {
		return tracks.stream();
	}
	
	public List<Track> getTrackList(){
		return unmodifiableList(tracks);
	}
	
	public Stream<Artist> getMusicians(){
		return musicians.stream();
	}
	
	public List<Artist> getMusiciansList() {
		return unmodifiableList(musicians);
	}
	
	public Artist getMusician(){
		return musicians.get(0);
	}
	
	public Album copy(){
		List<Track> tracks=getTracks().map(Track::copy())getClass().collect(toList());
		List<Artist> musicians=getMusician().map(Artist::copy()).collector(toList());
		return new Album(name, tracks, musicians);
	}
}

@@ -331,17 +331,16 @@
 ance %7B%0D%0A
-%09
 %0D%0A%09priva
@@ -681,25 +681,24 @@
 cians;%0D%0A%09%7D%0D%0A
-%09
 %0D%0A%09public St
@@ -711,16 +711,17 @@
 etName()
+ 
 %7B%0D%0A%09%09ret
@@ -731,25 +731,24 @@
  name;%0D%0A%09%7D%0D%0A
-%09
 %0D%0A%09public St
@@ -797,33 +797,32 @@
 .stream();%0D%0A%09%7D%0D%0A
-%09
 %0D%0A%09public List%3CT
@@ -841,16 +841,17 @@
 ckList()
+ 
 %7B%0D%0A%09%09ret
@@ -877,33 +877,32 @@
 t(tracks);%0D%0A%09%7D%0D%0A
-%09
 %0D%0A%09public Stream
@@ -924,16 +924,17 @@
 icians()
+ 
 %7B%0D%0A%09%09ret
@@ -954,33 +954,32 @@
 .stream();%0D%0A%09%7D%0D%0A
-%09
 %0D%0A%09public List%3CA
@@ -1042,33 +1042,32 @@
 usicians);%0D%0A%09%7D%0D%0A
-%09
 %0D%0A%09public Artist
@@ -1080,16 +1080,17 @@
 sician()
+ 
 %7B%0D%0A%09%09ret
@@ -1116,17 +1116,16 @@
 );%0D%0A%09%7D%0D%0A
-%09
 %0D%0A%09publi
@@ -1138,16 +1138,17 @@
 m copy()
+ 
 %7B%0D%0A%09%09Lis
@@ -1162,17 +1162,19 @@
 %3E tracks
-=
+ = 
 getTrack
@@ -1196,20 +1196,8 @@
 copy
-())getClass(
 ).co
@@ -1238,17 +1238,19 @@
 usicians
-=
+ = 
 getMusic
@@ -1252,16 +1252,17 @@
 Musician
+s
 ().map(A
@@ -1272,18 +1272,16 @@
 st::copy
-()
 ).collec
@@ -1281,18 +1281,16 @@
 .collect
-or
 (toList(

complete Album class