我是Java的新手,现在最近学习netty。
一些通用的类代码让我感到困惑。像这样:
package io.netty.util;
/**
* A singleton which is safe to compare via the {@code ==} operator. Created and managed by {@link ConstantPool}.
*/
public interface Constant<T extends Constant<T>> extends Comparable<T> {
/**
* Returns the unique number assigned to this {@link Constant}.
*/
int id();
/**
* Returns the name of this {@link Constant}.
*/
String name();
}
常量的通用定义是 self 的子类,这让我感觉像一个循环引用。这种代码的目的是什么?
智慧大石
相关分类