Samples JDK
Dish.java
1 package com.freemindcafe.java8.sample1;
2 
3 import java.util.Arrays;
4 import java.util.List;
5 
6 public class Dish {
7 
8  private final String name;
9  private final boolean vegetarian;
10  private final int calories;
11  private final Type type;
12 
13  public Dish(String name, boolean vegetarian, int calories, Type type) {
14  this.name = name;
15  this.vegetarian = vegetarian;
16  this.calories = calories;
17  this.type = type;
18  }
19 
20  public String getName() {
21  return name;
22  }
23 
24  public boolean isVegetarian() {
25  return vegetarian;
26  }
27 
28  public int getCalories() {
29  return calories;
30  }
31 
32  public Type getType() {
33  return type;
34  }
35 
36  public enum Type { MEAT, FISH, OTHER }
37 
38  @Override
39  public String toString() {
40  return name;
41  }
42 
43  public static final List<Dish> menu =
44  Arrays.asList( new Dish("pork", false, 800, Dish.Type.MEAT),
45  new Dish("beef", false, 700, Dish.Type.MEAT),
46  new Dish("chicken", false, 400, Dish.Type.MEAT),
47  new Dish("french fries", true, 530, Dish.Type.OTHER),
48  new Dish("rice", true, 350, Dish.Type.OTHER),
49  new Dish("season fruit", true, 120, Dish.Type.OTHER),
50  new Dish("pizza", true, 550, Dish.Type.OTHER),
51  new Dish("prawns", false, 400, Dish.Type.FISH),
52  new Dish("salmon", false, 450, Dish.Type.FISH));
53 }