I'm working on an application which is working on Java 1.7. I need to rewrite some code which has been writing with Java 1.8 with SpringFramework. Unfortunately, I'm not familiar with a newer version and I don't know how to rewrite this code to work with Java 7...
Below part of the code.
ConfigRepo:
public class ConfigRepo extends RepositoryRestConfigurerAdapter {
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration repoRestConfig) {
repoRestConfig.withEntityLookup().forRepository(IConfigRepo.class, (Config config) -> {
ConfigPK pk = new ConfigPK();
pk.setScope(config.getId().getScope());
pk.setKey(config.getId().getKey());
return pk;
}, IConfigRepo::findOne);
}
IConfigRepo:
public interface IConfigRepo extends CrudRepository<Config, ConfigPK> {}
EDIT: Added my code.
I'm not sure if this what I've done part of it correctly. I don't know how this Config config should be passed. Also I don't know what I should do with this method reference...
My version:
public class ConfigRepo extends RepositoryRestConfigurerAdapter {
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration repoRestConfig) {
repoRestConfig.withEntityLookup().forRepository(IConfigRepo.class, new Config() {
public ConfigPK prepareConfigPK(Config config) {
ConfigPK pk = new ConfigPK();
pk.setScope(config.getId().getScope());
pk.setKey(config.getId().getKey());
return pk;
}, IConfigRepo::findOne);
}