我有一个HashMap,我想按索引编辑这些值中的特定条目。我在语法上对如何执行此操作感到困惑,因为我的主要工具似乎已设置/获取,而获取似乎只是参考,而不是实际值。
在伪代码中,它看起来像:
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired UserService userService;
@Autowired AuthenticationProvider provider;
@Autowired BCryptPasswordEncoder encoder;
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/user/login").permitAll()
.antMatchers("/main").authenticated()
.antMatchers("main").authenticated()
.antMatchers("/**").authenticated()
.anyRequest().authenticated()
.and()
.logout()
;
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userService)
.passwordEncoder(encoder);
}
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public HttpSessionStrategy httpSessionStrategy() {
return new HeaderHttpSessionStrategy();
}
但是在Java中,我觉得我必须做类似的事情:
dictionary.get(n)[x] += 1
真恶心!
最干净的方法是什么?