diff --git a/server-spi-private/src/main/java/org/keycloak/broker/provider/AbstractIdentityProviderFactory.java b/server-spi-private/src/main/java/org/keycloak/broker/provider/AbstractIdentityProviderFactory.java index 953797b51c..adfde6a7da 100755 --- a/server-spi-private/src/main/java/org/keycloak/broker/provider/AbstractIdentityProviderFactory.java +++ b/server-spi-private/src/main/java/org/keycloak/broker/provider/AbstractIdentityProviderFactory.java @@ -51,6 +51,6 @@ public abstract class AbstractIdentityProviderFactory parseConfig(KeycloakSession session, InputStream inputStream) { - return new HashMap(); + return new HashMap<>(); } } diff --git a/server-spi-private/src/main/java/org/keycloak/broker/provider/util/SimpleHttp.java b/server-spi-private/src/main/java/org/keycloak/broker/provider/util/SimpleHttp.java index cfdf51457a..49fd82ae5e 100755 --- a/server-spi-private/src/main/java/org/keycloak/broker/provider/util/SimpleHttp.java +++ b/server-spi-private/src/main/java/org/keycloak/broker/provider/util/SimpleHttp.java @@ -110,7 +110,7 @@ public class SimpleHttp { public SimpleHttp header(String name, String value) { if (headers == null) { - headers = new HashMap(); + 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(); + params = new HashMap<>(); } params.put(name, value); return this; diff --git a/server-spi-private/src/main/java/org/keycloak/events/EventBuilder.java b/server-spi-private/src/main/java/org/keycloak/events/EventBuilder.java index 1d3ff9b5d3..369e28cc47 100755 --- a/server-spi-private/src/main/java/org/keycloak/events/EventBuilder.java +++ b/server-spi-private/src/main/java/org/keycloak/events/EventBuilder.java @@ -136,7 +136,7 @@ public class EventBuilder { } if (event.getDetails() == null) { - event.setDetails(new HashMap()); + event.setDetails(new HashMap<>()); } event.getDetails().put(key, value); return this; diff --git a/server-spi-private/src/main/java/org/keycloak/models/session/PersistentUserSessionAdapter.java b/server-spi-private/src/main/java/org/keycloak/models/session/PersistentUserSessionAdapter.java index 7fcec1c8be..5a19aabb93 100644 --- a/server-spi-private/src/main/java/org/keycloak/models/session/PersistentUserSessionAdapter.java +++ b/server-spi-private/src/main/java/org/keycloak/models/session/PersistentUserSessionAdapter.java @@ -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()); + data.setNotes(new HashMap<>()); } data.getNotes().put(name, value); diff --git a/server-spi-private/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java b/server-spi-private/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java index 7e3a457d8b..7ba1229702 100755 --- a/server-spi-private/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java +++ b/server-spi-private/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java @@ -175,15 +175,13 @@ public class ModelToRepresentation { rep.setNotBefore(session.users().getNotBeforeOfUser(realm, user)); - List reqActions = new ArrayList(); Set requiredActions = user.getRequiredActions(); - reqActions.addAll(requiredActions); + List reqActions = new ArrayList<>(requiredActions); rep.setRequiredActions(reqActions); if (user.getAttributes() != null && !user.getAttributes().isEmpty()) { - Map> attrs = new HashMap<>(); - attrs.putAll(user.getAttributes()); + Map> 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(realm.getEventsListeners())); + rep.setEventsListeners(new LinkedList<>(realm.getEventsListeners())); } if (realm.getEnabledEventTypes() != null) { - rep.setEnabledEventTypes(new LinkedList(realm.getEnabledEventTypes())); + rep.setEnabledEventTypes(new LinkedList<>(realm.getEnabledEventTypes())); } rep.setAdminEventsEnabled(realm.isAdminEventsEnabled()); @@ -365,8 +363,7 @@ public class ModelToRepresentation { List defaultRoles = realm.getDefaultRoles(); if (!defaultRoles.isEmpty()) { - List roleStrings = new ArrayList(); - roleStrings.addAll(defaultRoles); + List roleStrings = new ArrayList<>(defaultRoles); rep.setDefaultRoles(roleStrings); } List defaultGroups = realm.getDefaultGroups(); @@ -379,8 +376,8 @@ public class ModelToRepresentation { } List requiredCredentialModels = realm.getRequiredCredentials(); - if (requiredCredentialModels.size() > 0) { - rep.setRequiredCredentials(new HashSet()); + 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()); + 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()); - rep.setAuthenticatorConfig(new LinkedList()); + rep.setAuthenticationFlows(new LinkedList<>()); + rep.setAuthenticatorConfig(new LinkedList<>()); List 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 config = new HashMap<>(); - config.putAll(identityProviderModel.getConfig()); + Map 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 config = new HashMap(); - config.putAll(model.getConfig()); + Map 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 config = new HashMap(); - config.putAll(model.getConfig()); + Map 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()); + rep.setAuthenticationExecutions(new LinkedList<>()); for (AuthenticationExecutionModel execution : realm.getAuthenticationExecutions(model.getId())) { rep.getAuthenticationExecutions().add(toRepresentation(realm, execution)); } diff --git a/server-spi-private/src/main/java/org/keycloak/models/utils/reflection/PropertyQuery.java b/server-spi-private/src/main/java/org/keycloak/models/utils/reflection/PropertyQuery.java index 5d7cbf5878..22ca66423a 100644 --- a/server-spi-private/src/main/java/org/keycloak/models/utils/reflection/PropertyQuery.java +++ b/server-spi-private/src/main/java/org/keycloak/models/utils/reflection/PropertyQuery.java @@ -45,7 +45,7 @@ public class PropertyQuery { } this.targetClass = targetClass; - this.criteria = new ArrayList(); + this.criteria = new ArrayList<>(); } /** @@ -148,7 +148,7 @@ public class PropertyQuery { * @return the results, or an empty list if there are no results */ private Map> getResultList(boolean writable) { - Map> properties = new HashMap>(); + Map> properties = new HashMap<>(); // First check public accessor methods (we ignore private methods) for (Method method : targetClass.getMethods()) { @@ -165,7 +165,7 @@ public class PropertyQuery { } if (match) { - MethodProperty property = Properties.createProperty(method); + MethodProperty property = Properties.createProperty(method); if (!writable || !property.isReadOnly()) { properties.put(property.getName(), property); diff --git a/server-spi-private/src/main/java/org/keycloak/storage/adapter/InMemoryUserAdapter.java b/server-spi-private/src/main/java/org/keycloak/storage/adapter/InMemoryUserAdapter.java index 90259726c9..4a0e1fec01 100644 --- a/server-spi-private/src/main/java/org/keycloak/storage/adapter/InMemoryUserAdapter.java +++ b/server-spi-private/src/main/java/org/keycloak/storage/adapter/InMemoryUserAdapter.java @@ -252,7 +252,7 @@ public class InMemoryUserAdapter implements UserModel { @Override public Set getGroups() { - if (groupIds.size() == 0) return Collections.EMPTY_SET; + if (groupIds.isEmpty()) return Collections.emptySet(); Set groups = new HashSet<>(); for (String id : groupIds) { groups.add(realm.getGroupById(id)); @@ -311,7 +311,7 @@ public class InMemoryUserAdapter implements UserModel { Set allRoles = getRoleMappings(); // Filter to retrieve just realm roles - Set realmRoles = new HashSet(); + Set 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 getClientRoleMappings(ClientModel app) { - Set result = new HashSet(); + Set result = new HashSet<>(); Set roles = getRoleMappings(); for (RoleModel role : roles) { @@ -348,7 +348,7 @@ public class InMemoryUserAdapter implements UserModel { @Override public Set getRoleMappings() { - if (roleIds.size() == 0) return Collections.EMPTY_SET; + if (roleIds.isEmpty()) return Collections.emptySet(); Set roles = new HashSet<>(); for (String id : roleIds) { roles.add(realm.getRoleById(id));