我试图在Kotlin项目中使用Tab Layout + Android数据绑定库,但我没有成功。
请告诉我我做错了什么?
这是我的活动:
private String configFilePath;
private Optional<ItemMasterFileProcessorConfiguration> config;
public ItemMasterFileProcessorTaskModule(String configFilePath)
{
this.configFilePath = configFilePath;
config = Optional.empty();
}
@Override
public void configure(Binder binder)
{
binder.bind(<Interface>.class).to(<ImplClass>.class);
binder.bind(<Interface>.class).to(<ImplClass>.class);
}
@Provides
public ItemMasterFileProcessorConfiguration getConfig() throws ItemMasterFileProcessorException
{
Yaml yaml = new Yaml();
try
{
if (!config.isPresent())
{
ItemMasterFileProcessorConfiguration writerConfig = yaml.loadAs(ItemMasterFileProcessorConfiguration.class.getClassLoader().getResourceAsStream(configFilePath), ItemMasterFileProcessorConfiguration.class);
config = Optional.of(writerConfig);
}
/*
* Sonar is wanting is to add isPresent() before this But if I do
* Sonar complains that it will always evaluate to TRUE
*/
return config.get();
}
catch (Exception e)
{
throw new ItemMasterFileProcessorException("Config is NULL while initializing configuration for config path : {}", e);
}
}