Expand Cut Tags

No cut tags
microcell: (Default)
К примеру, у нас есть интерфейс для вызова функций ResultSet:
 
public interface FieldProcessor<T> {
    T get(ResultSet rs, int number) throws SQLException;
 
К нему мы добавим еще один интерфейс, без дополнительных параметров:
 
public interface Field<T> {
    T getValue(ResultSet rs) throws SQLException;
}
 
 
Теперь попытаемся сгенерировать ламбду для первого интерфейса (весь лишний код я, понятное дело, опустил):
    
public class QueryRunner {
 
    public static <T> T getResult(Connection con, String query, FieldProcessor<T> processor) throws SQLException {
        return null;
    }
 
    public static <T> T getResult(Connection con, String query, Field<T> field) throws SQLException {
        return null;
    }
 
    public static Integer getIntegerResult(Connection con, String query) throws SQLException {
        return getResult(con, query, ResultSet::getInt);
    }
}    
 
Казалось бы, ResultSet::getInt(int columnIndex) соответствует первому интерфейсу и никак иначе. Но компилятор джавы почему-то считает иначе. Bugged!
 
 

Profile

microcell: (Default)
microcell

July 2018

S M T W T F S
12345 67
891011121314
15161718192021
22232425262728
293031    

Most Popular Tags

Syndicate

RSS Atom

Style Credit

Page generated Aug. 19th, 2025 03:56 am
Powered by Dreamwidth Studios