MovieLister Class – Java

package moviefindertest.springxml;

import java.util.Iterator;
import java.util.List;

public class MovieLister {
      private static int lastVersionID = 0;
      private final int versionID;
      public int getVersionID() {
            return versionID;

      private MovieFinder finder;
    public MovieLister(MovieFinder finder) {
            this.finder = finder;
    public MovieLister() {
            this.versionID = ++MovieLister.lastVersionID;

      public MovieFinder getFinder() {
            return finder;

      public void setFinder(MovieFinder finder) {
            this.finder = finder;

      public Movie[] moviesDirectedBy(String arg) {
        List<Movie> allMovies = finder.findAll();
        for (Iterator<Movie> it = allMovies.iterator(); it.hasNext();) {
            Movie movie = (Movie);
            if (!movie.getDirector().equals(arg)) it.remove();
        return (Movie[]) allMovies.toArray(new Movie[allMovies.size()]);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s