如何在Java中将值传递给接口函数

时间:2019-02-10 06:24:54

标签: spring function interface repository spring-projections

最近在进行Spring JPA Projections时,我遇到了以下示例:

package main

// #include <stdlib.h>
// #include <locale.h>
// #include <ncursesw/curses.h>
// #cgo LDFLAGS: -lncursesw
import "C"

import "unsafe"
import "fmt"

func main() {
    // C Code : setlocale(LC_ALL, "");
    {
        _s := C.CString("")
        defer C.free(unsafe.Pointer(_s))

        C.setlocale(C.LC_ALL, _s)
    }

    C.initscr()

    C.timeout(50)

    C.noecho()
    C.cbreak()
    C.curs_set(C.int(0))

    C.start_color()

    C.keypad(C.stdscr, C.bool(true))

    var count int = 0
    draw(count, 0)

    for {
        ch := int(C.getch())
        if ch < 0 {
            continue
        }

        count++
        draw(count, ch)
    }
}

func draw(count int, ch int) {
    // C Code : getmaxyx(stdscr, y, x)
    var y, x int
    {
        _y := C.getmaxy(C.stdscr)
        _x := C.getmaxx(C.stdscr)

        y = int(_y)
        x = int(_x)
    }

    var s string
    s = fmt.Sprintf("count=%5d y=%d x=%d ch=%d        ", count, y, x, ch)

    // C Code : mvwaddstr(stdscr, 1, 1, s);
    {
        _s := C.CString(s)
        defer C.free(unsafe.Pointer(_s))

        C.mvwaddstr(C.stdscr, C.int(1), C.int(1), _s)
    }
    C.wrefresh(C.stdscr)
}

从这里https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#projections示例78

我想知道我如何传递前缀值,因为接口无法创建对象!

0 个答案:

没有答案