小编Tal*_*los的帖子

从自定义椭圆形注释访问注释属性

当使用自定义椭圆注释和自定义类进行检查时,是否可以访问注释并检索使用的注释属性?

\n

椭圆形参考:https ://sebthom.github.io/oval/USERGUIDE.html#custom-constraint-annotations

\n
\n

最小的例子

\n

假设我们有 class Foo。\n它有两个带注释的字段。
\n每次,注释都有不同的myValue\xe2\x80\x93ab.

\n
class Foo {\n  @CustomAnnotation(myValue = "a")\n  public String first;\n\n  @CustomAnnotation(myValue = "b")\n  public String second;\n}\n
Run Code Online (Sandbox Code Playgroud)\n

这是注释。
\n请注意,应使用 执行检查MyCheck.class,并为 设置一些默认值myValue

\n
@Retention(RetentionPolicy.RUNTIME)\n@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})\n@Constraint(checkWith = MyCheck.class)\npublic @interface CustomAnnotation {\n    String myValue() default "";\n}\n
Run Code Online (Sandbox Code Playgroud)\n

现在我们想使用 oval 来验证该字段。\n最重要的是,我们希望从注释中
提取值a或并在验证逻辑中使用它。bmyValue

\n
class Foo {\n  @CustomAnnotation(myValue = "a")\n  public String first;\n\n  @CustomAnnotation(myValue = "b")\n …
Run Code Online (Sandbox Code Playgroud)

java oval

5
推荐指数
1
解决办法
145
查看次数

Firefox:使用 Alt + [0-9] 切换选项卡

在 Arch Linux 上,我可以通过按 Alt+[tab_num] 来切换选项卡。

我必须在 Windows 上工作,而 Firefox 使用 Ctrl+[tab_num]。

真的很烦人。Ctrl 不太适合这种切换 + 我习惯使用 Alt+[tab_num] 而不是 Ctrl+[tab_num]。

有没有一种简单的方法可以在 Firefox 中管理/更改此设置?有任何扩展可以做到这一点吗?

firefox firefox-addon

4
推荐指数
1
解决办法
1329
查看次数

类内的C++静态常量数组初始化

我想创建一个常量和静态整数数组作为公共类变量。定义它并立即初始化它是很好的。有关完整示例,请参阅下面的代码。

#include <iostream>

class Foo {
public:
    constexpr static int arr[3][2] = {
            {1, 2},
            {3, 4},
            {5, 6}
    };
};

int main() {
    for (int i = 0; i < 3; i++) {
        std::cout << "Pair " << Foo::arr[i][0] << ", " << Foo::arr[i][1] << std::endl;
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但是,使用g++ --std=c++11 test.cpp产生的编译上面的代码

/usr/bin/ld: /tmp/ccc7DFI5.o: in function `main':
test.cpp:(.text+0x2f): undefined reference to `Foo::arr'
/usr/bin/ld: test.cpp:(.text+0x55): undefined reference to `Foo::arr'
collect2: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

这在 …

c++ c++11

4
推荐指数
1
解决办法
76
查看次数

标签 统计

c++ ×1

c++11 ×1

firefox ×1

firefox-addon ×1

java ×1

oval ×1