KEYCLOAK-12220 Fix minor warnings for collections in module "server-spi-private"
This commit is contained in:
parent
04cbea71d0
commit
c8a00c2422
7 changed files with 26 additions and 32 deletions
|
@ -51,6 +51,6 @@ public abstract class AbstractIdentityProviderFactory<T extends IdentityProvider
|
|||
|
||||
@Override
|
||||
public Map<String, String> parseConfig(KeycloakSession session, InputStream inputStream) {
|
||||
return new HashMap<String, String>();
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ public class SimpleHttp {
|
|||
|
||||
public SimpleHttp header(String name, String value) {
|
||||
if (headers == null) {
|
||||
headers = new HashMap<String, String>();
|
||||
headers = new HashMap<>();
|
||||
}
|
||||
headers.put(name, value);
|
||||
return this;
|
||||
|
@ -123,7 +123,7 @@ public class SimpleHttp {
|
|||
|
||||
public SimpleHttp param(String name, String value) {
|
||||
if (params == null) {
|
||||
params = new HashMap<String, String>();
|
||||
params = new HashMap<>();
|
||||
}
|
||||
params.put(name, value);
|
||||
return this;
|
||||
|
|
|
@ -136,7 +136,7 @@ public class EventBuilder {
|
|||
}
|
||||
|
||||
if (event.getDetails() == null) {
|
||||
event.setDetails(new HashMap<String, String>());
|
||||
event.setDetails(new HashMap<>());
|
||||
}
|
||||
event.getDetails().put(key, value);
|
||||
return this;
|
||||
|
|
|
@ -198,7 +198,7 @@ public class PersistentUserSessionAdapter implements OfflineUserSessionModel {
|
|||
public void setNote(String name, String value) {
|
||||
PersistentUserSessionData data = getData();
|
||||
if (data.getNotes() == null) {
|
||||
data.setNotes(new HashMap<String, String>());
|
||||
data.setNotes(new HashMap<>());
|
||||
}
|
||||
data.getNotes().put(name, value);
|
||||
|
||||
|
|
|
@ -175,15 +175,13 @@ public class ModelToRepresentation {
|
|||
|
||||
rep.setNotBefore(session.users().getNotBeforeOfUser(realm, user));
|
||||
|
||||
List<String> reqActions = new ArrayList<String>();
|
||||
Set<String> requiredActions = user.getRequiredActions();
|
||||
reqActions.addAll(requiredActions);
|
||||
List<String> reqActions = new ArrayList<>(requiredActions);
|
||||
|
||||
rep.setRequiredActions(reqActions);
|
||||
|
||||
if (user.getAttributes() != null && !user.getAttributes().isEmpty()) {
|
||||
Map<String, List<String>> attrs = new HashMap<>();
|
||||
attrs.putAll(user.getAttributes());
|
||||
Map<String, List<String>> attrs = new HashMap<>(user.getAttributes());
|
||||
rep.setAttributes(attrs);
|
||||
}
|
||||
|
||||
|
@ -296,10 +294,10 @@ public class ModelToRepresentation {
|
|||
rep.setEventsExpiration(realm.getEventsExpiration());
|
||||
}
|
||||
if (realm.getEventsListeners() != null) {
|
||||
rep.setEventsListeners(new LinkedList<String>(realm.getEventsListeners()));
|
||||
rep.setEventsListeners(new LinkedList<>(realm.getEventsListeners()));
|
||||
}
|
||||
if (realm.getEnabledEventTypes() != null) {
|
||||
rep.setEnabledEventTypes(new LinkedList<String>(realm.getEnabledEventTypes()));
|
||||
rep.setEnabledEventTypes(new LinkedList<>(realm.getEnabledEventTypes()));
|
||||
}
|
||||
|
||||
rep.setAdminEventsEnabled(realm.isAdminEventsEnabled());
|
||||
|
@ -365,8 +363,7 @@ public class ModelToRepresentation {
|
|||
|
||||
List<String> defaultRoles = realm.getDefaultRoles();
|
||||
if (!defaultRoles.isEmpty()) {
|
||||
List<String> roleStrings = new ArrayList<String>();
|
||||
roleStrings.addAll(defaultRoles);
|
||||
List<String> roleStrings = new ArrayList<>(defaultRoles);
|
||||
rep.setDefaultRoles(roleStrings);
|
||||
}
|
||||
List<GroupModel> defaultGroups = realm.getDefaultGroups();
|
||||
|
@ -379,8 +376,8 @@ public class ModelToRepresentation {
|
|||
}
|
||||
|
||||
List<RequiredCredentialModel> requiredCredentialModels = realm.getRequiredCredentials();
|
||||
if (requiredCredentialModels.size() > 0) {
|
||||
rep.setRequiredCredentials(new HashSet<String>());
|
||||
if (!requiredCredentialModels.isEmpty()) {
|
||||
rep.setRequiredCredentials(new HashSet<>());
|
||||
for (RequiredCredentialModel cred : requiredCredentialModels) {
|
||||
rep.getRequiredCredentials().add(cred.getType());
|
||||
}
|
||||
|
@ -396,7 +393,7 @@ public class ModelToRepresentation {
|
|||
|
||||
rep.setInternationalizationEnabled(realm.isInternationalizationEnabled());
|
||||
if (realm.getSupportedLocales() != null) {
|
||||
rep.setSupportedLocales(new HashSet<String>());
|
||||
rep.setSupportedLocales(new HashSet<>());
|
||||
rep.getSupportedLocales().addAll(realm.getSupportedLocales());
|
||||
}
|
||||
rep.setDefaultLocale(realm.getDefaultLocale());
|
||||
|
@ -422,8 +419,8 @@ public class ModelToRepresentation {
|
|||
}
|
||||
|
||||
public static void exportAuthenticationFlows(RealmModel realm, RealmRepresentation rep) {
|
||||
rep.setAuthenticationFlows(new LinkedList<AuthenticationFlowRepresentation>());
|
||||
rep.setAuthenticatorConfig(new LinkedList<AuthenticatorConfigRepresentation>());
|
||||
rep.setAuthenticationFlows(new LinkedList<>());
|
||||
rep.setAuthenticatorConfig(new LinkedList<>());
|
||||
|
||||
List<AuthenticationFlowModel> authenticationFlows = new ArrayList<>(realm.getAuthenticationFlows());
|
||||
//ensure consistent ordering of authenticationFlows.
|
||||
|
@ -629,8 +626,7 @@ public class ModelToRepresentation {
|
|||
providerRep.setStoreToken(identityProviderModel.isStoreToken());
|
||||
providerRep.setTrustEmail(identityProviderModel.isTrustEmail());
|
||||
providerRep.setAuthenticateByDefault(identityProviderModel.isAuthenticateByDefault());
|
||||
Map<String, String> config = new HashMap<>();
|
||||
config.putAll(identityProviderModel.getConfig());
|
||||
Map<String, String> config = new HashMap<>(identityProviderModel.getConfig());
|
||||
providerRep.setConfig(config);
|
||||
providerRep.setAddReadTokenRoleOnCreate(identityProviderModel.isAddReadTokenRoleOnCreate());
|
||||
|
||||
|
@ -659,8 +655,7 @@ public class ModelToRepresentation {
|
|||
ProtocolMapperRepresentation rep = new ProtocolMapperRepresentation();
|
||||
rep.setId(model.getId());
|
||||
rep.setProtocol(model.getProtocol());
|
||||
Map<String, String> config = new HashMap<String, String>();
|
||||
config.putAll(model.getConfig());
|
||||
Map<String, String> config = new HashMap<>(model.getConfig());
|
||||
rep.setConfig(config);
|
||||
rep.setName(model.getName());
|
||||
rep.setProtocolMapper(model.getProtocolMapper());
|
||||
|
@ -672,8 +667,7 @@ public class ModelToRepresentation {
|
|||
rep.setId(model.getId());
|
||||
rep.setIdentityProviderMapper(model.getIdentityProviderMapper());
|
||||
rep.setIdentityProviderAlias(model.getIdentityProviderAlias());
|
||||
Map<String, String> config = new HashMap<String, String>();
|
||||
config.putAll(model.getConfig());
|
||||
Map<String, String> config = new HashMap<>(model.getConfig());
|
||||
rep.setConfig(config);
|
||||
rep.setName(model.getName());
|
||||
return rep;
|
||||
|
@ -707,7 +701,7 @@ public class ModelToRepresentation {
|
|||
rep.setProviderId(model.getProviderId());
|
||||
rep.setAlias(model.getAlias());
|
||||
rep.setDescription(model.getDescription());
|
||||
rep.setAuthenticationExecutions(new LinkedList<AuthenticationExecutionExportRepresentation>());
|
||||
rep.setAuthenticationExecutions(new LinkedList<>());
|
||||
for (AuthenticationExecutionModel execution : realm.getAuthenticationExecutions(model.getId())) {
|
||||
rep.getAuthenticationExecutions().add(toRepresentation(realm, execution));
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class PropertyQuery<V> {
|
|||
}
|
||||
|
||||
this.targetClass = targetClass;
|
||||
this.criteria = new ArrayList<PropertyCriteria>();
|
||||
this.criteria = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,7 +148,7 @@ public class PropertyQuery<V> {
|
|||
* @return the results, or an empty list if there are no results
|
||||
*/
|
||||
private Map<String, Property<V>> getResultList(boolean writable) {
|
||||
Map<String, Property<V>> properties = new HashMap<String, Property<V>>();
|
||||
Map<String, Property<V>> properties = new HashMap<>();
|
||||
|
||||
// First check public accessor methods (we ignore private methods)
|
||||
for (Method method : targetClass.getMethods()) {
|
||||
|
@ -165,7 +165,7 @@ public class PropertyQuery<V> {
|
|||
}
|
||||
|
||||
if (match) {
|
||||
MethodProperty<V> property = Properties.<V>createProperty(method);
|
||||
MethodProperty<V> property = Properties.createProperty(method);
|
||||
|
||||
if (!writable || !property.isReadOnly()) {
|
||||
properties.put(property.getName(), property);
|
||||
|
|
|
@ -252,7 +252,7 @@ public class InMemoryUserAdapter implements UserModel {
|
|||
|
||||
@Override
|
||||
public Set<GroupModel> getGroups() {
|
||||
if (groupIds.size() == 0) return Collections.EMPTY_SET;
|
||||
if (groupIds.isEmpty()) return Collections.emptySet();
|
||||
Set<GroupModel> groups = new HashSet<>();
|
||||
for (String id : groupIds) {
|
||||
groups.add(realm.getGroupById(id));
|
||||
|
@ -311,7 +311,7 @@ public class InMemoryUserAdapter implements UserModel {
|
|||
Set<RoleModel> allRoles = getRoleMappings();
|
||||
|
||||
// Filter to retrieve just realm roles
|
||||
Set<RoleModel> realmRoles = new HashSet<RoleModel>();
|
||||
Set<RoleModel> realmRoles = new HashSet<>();
|
||||
for (RoleModel role : allRoles) {
|
||||
if (role.getContainer() instanceof RealmModel) {
|
||||
realmRoles.add(role);
|
||||
|
@ -322,7 +322,7 @@ public class InMemoryUserAdapter implements UserModel {
|
|||
|
||||
@Override
|
||||
public Set<RoleModel> getClientRoleMappings(ClientModel app) {
|
||||
Set<RoleModel> result = new HashSet<RoleModel>();
|
||||
Set<RoleModel> result = new HashSet<>();
|
||||
Set<RoleModel> roles = getRoleMappings();
|
||||
|
||||
for (RoleModel role : roles) {
|
||||
|
@ -348,7 +348,7 @@ public class InMemoryUserAdapter implements UserModel {
|
|||
|
||||
@Override
|
||||
public Set<RoleModel> getRoleMappings() {
|
||||
if (roleIds.size() == 0) return Collections.EMPTY_SET;
|
||||
if (roleIds.isEmpty()) return Collections.emptySet();
|
||||
Set<RoleModel> roles = new HashSet<>();
|
||||
for (String id : roleIds) {
|
||||
roles.add(realm.getRoleById(id));
|
||||
|
|
Loading…
Reference in a new issue