在完成this问题后,我仍然无法构建以下文件:
public class ContextImpl implements Context {
private static final Logger logger = LoggerFactory.getLogger(ContextImpl.class);
private static final Map<String, TransportFactory> transportFactories = new HashMap<>();
private static final Map<String, SerializerFactory> serializerFactories = new HashMap<>();
ContextImpl() { }
ContextImpl(boolean isSecureContext) {
registerSerializerFactory(new CDRSerializerFactory());
if(isSecureContext) {
registerTransportFactory(new TcpBlockTransportFactory(/*secure = */true));
registerTransportFactory(new HttpTransportFactory(/*secure = */true));
} else {
registerTransportFactory(new TcpBlockTransportFactory(/*secure = */false));
registerTransportFactory(new HttpTransportFactory(/*secure = */false));
}
}
private static SerializerFactory getSerializerFactoryByName(String serializerName) {
synchronized (serializerFactories) {
return serializerFactories.get(serializerName);
}
}
private static TransportFactory getTransportFactoryByName(String transportName) {
synchronized (transportFactories) {
return transportFactories.get(transportName);
}
}
public static TransportFactory getTransportFactoryByURI(String uri) throws URISyntaxException {
return getTransportFactoryByURI(new URI(uri));
}
}
其中上述类的构造函数被调用为:
public static Context createContext() {
return new ContextImpl();
}
在构造函数中调用的方法是:
private static void registerTransportFactory(TransportFactory transportFactory) {
if (transportFactory == null) {
throw new NullPointerException("transportFactory");
}
final String transportName = transportFactory.getName();
if (transportName == null) {
throw new NullPointerException("transportName");
}
synchronized (transportFactories) {
transportFactories.put(transportName, transportFactory);
}
}
public static void registerSerializerFactory(String serializerName, SerializerFactory serializerFactory) {
if (serializerName == null) {
throw new NullPointerException("serializerName");
}
if (serializerFactory == null) {
throw new NullPointerException("serializerFactory");
}
synchronized (serializerFactories) {
serializerFactories.put(serializerName, serializerFactory);
}
}
返回的错误消息是:
Error:(29, 16) java: constructor ContextImpl in class org.fiware.kiara.impl.ContextImpl cannot be applied to given types;
required: boolean
found: no arguments
reason: actual and formal argument lists differ in length
为什么在调用隐式构造函数后返回此错误?