mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-19 01:50:56 +07:00
34 lines
742 B
Java
34 lines
742 B
Java
import java.util.function.Function;
|
|
|
|
class Test {
|
|
static class MyMap<V>
|
|
{
|
|
V put( char[] key, V value )
|
|
{
|
|
return null;
|
|
}
|
|
|
|
V put( String key, V value )
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
static final MyMap<Test.F> s_funcMap = new MyMap<>();
|
|
|
|
interface F extends Function<Thread,Number> { }
|
|
|
|
static
|
|
{
|
|
// without casts
|
|
s_funcMap.put( "ID", Thread::getId );
|
|
s_funcMap.put( "ID", thread -> thread.getId() + 1 );
|
|
s_funcMap.put( "ID", thread -> { return thread.getId() + 1; } );
|
|
|
|
// with casts
|
|
s_funcMap.put( "ID", (Test.F) Thread::getId );
|
|
s_funcMap.put( "ID", (Test.F) thread -> thread.getId() + 1 );
|
|
s_funcMap.put( "ID", (Test.F) thread -> { return thread.getId() + 1; } );
|
|
}
|
|
}
|