MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / Part

Class Part

reflection/RegisteredFactories.java:10–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8import java.util.stream.*;
9
10class Part implements Supplier<Part> {
11 @Override public String toString() {
12 return getClass().getSimpleName();
13 }
14 static List<Supplier<? extends Part>> prototypes =
15 Arrays.asList(
16 new FuelFilter(),
17 new AirFilter(),
18 new CabinAirFilter(),
19 new OilFilter(),
20 new FanBelt(),
21 new PowerSteeringBelt(),
22 new GeneratorBelt()
23 );
24 private static Random rand = new Random(47);
25 @Override public Part get() {
26 int n = rand.nextInt(prototypes.size());
27 return prototypes.get(n).get();
28 }
29}
30
31class Filter extends Part {}
32

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected