![](/img/trans.png)
[英]Difference between add(E e) and offer(E e) of ArrayDqueue Class
[英]Finesse Class<E> into Class<E[]>
public abstract class AbstractRESTClientService<E extends IDable<String>>
implements GenericService<E, String> {
private Class<E> classType;
private Class<E[]> classArray;
private String controllerPath;
public AbstractRESTClientService(final Class<E> classType,
final Class<E[]> classArray,
final String controllerPath) {
this.classType = classType;
this.classArray = classArray;
this.controllerPath = controllerPath;
this.webService = new GenericWebClientService<E>();
}
// ... other methods
}
有没有办法将 classType 操作到 classArray 中,这样我就不需要将 classArray 作为参数传入?
我讨厌认为这是最好的方法,但这是我处理它的方式。
public abstract class AbstractRESTClientService<E extends IDable<String>>
implements GenericService<E, String> {
private Class<E> classType;
private Class<E[]> classArray;
private String controllerPath;
@SuppressWarnings("unchecked")
public AbstractRESTClientService(final Class<E[]> classArray,
final String controllerPath) {
this.classType = (Class<E>) classArray.getComponentType();
this.classArray = classArray;
this.controllerPath = controllerPath;
this.webService = new GenericWebClientService<E>();
}
// ... other methods
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.