1// Copyright 2016 The Bazel Authors. All rights reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14package com.google.devtools.build.android.desugar.testdata; 15 16import java.util.List; 17import java.util.concurrent.Callable; 18import java.util.function.Function; 19import java.util.stream.Collectors; 20 21public class Lambda { 22 23 private final List<String> names; 24 25 public Lambda(List<String> names) { 26 this.names = names; 27 } 28 29 public List<String> as() { 30 return names 31 .stream() 32 .filter(n -> n.startsWith("A")) 33 .collect(Collectors.toList()); 34 } 35 36 public static Callable<String> hello() { 37 return (Callable<String> & java.util.RandomAccess) () -> "hello"; 38 } 39 40 public static Function<Integer, Callable<Long>> mult(int x) { 41 return new Function<Integer, Callable<Long>>() { 42 @Override 43 public Callable<Long> apply(Integer y) { 44 return () -> (long) x * (long) y; 45 } 46 }; 47 } 48 49 /** 50 * Test method for b/62456849. This method will first be converted to a synthetic method by {@link 51 * com.google.devtools.build.android.desugar.Bug62456849TestDataGenerator}, and then Desugar 52 * should keep it in this class without desugaring it (such as renaming). 53 * 54 * <p>Please ignore the lint error on the method name. The method name is intentionally chosen to 55 * trigger a bug in Desugar. 56 */ 57 public static int lambda$mult$0() { 58 return 0; 59 } 60} 61