### Question:
Pattern2 implements PartialFunction2<A, B, R> { private Pattern2() { this(Pattern1.build()); } private  Pattern2(); private  Pattern2(Pattern1<Tuple2<A, B>, R> pattern); @Override boolean isDefinedAt(A a, B b); @Override R apply(A a, B b); static Pattern2<A, B, R> build(); ThenStep<Pattern2<A, B, R>, A, B, R> when(Matcher2<A, B> matcher); ThenStep<Pattern2<A, B, R>, A, B, R> otherwise();  }### Answer:
@Test public void pattern2() { Pattern2<Object, Object, Object> pattern2 = Pattern2.build() .when(Object::equals).returns("a equals b") .otherwise().returns("not equals"); assertAll(() -> assertEquals("a equals b", pattern2.apply("a", "a")), () -> assertEquals("not equals", pattern2.apply("a", 12L))); }