mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-19 01:50:56 +07:00
43 lines
761 B
Java
43 lines
761 B
Java
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
|
|
class Scratch
|
|
{
|
|
public static void main(String[] args)
|
|
{
|
|
final List<ConcreteId> list = new ArrayList<>();
|
|
|
|
final List<Long> longs = list.stream()
|
|
.map(ConcreteId::getId)
|
|
.collect(Collectors.toList());
|
|
|
|
final List<Long> longs2 = list.stream()
|
|
.map(AbstractId::getId)
|
|
.collect(Collectors.toList());
|
|
}
|
|
|
|
private static abstract class AbstractId
|
|
{
|
|
private final long id;
|
|
|
|
public AbstractId(long id)
|
|
{
|
|
this.id = id;
|
|
}
|
|
|
|
public long getId()
|
|
{
|
|
return this.id;
|
|
}
|
|
}
|
|
|
|
private static class ConcreteId extends AbstractId
|
|
{
|
|
public ConcreteId(long id)
|
|
{
|
|
super(id);
|
|
}
|
|
}
|
|
}
|