Skip to content

Commit c7ddb86

Browse files
committed
Reduce use of generic classes with omitted type params
1 parent a04f57b commit c7ddb86

File tree

18 files changed

+163
-169
lines changed

18 files changed

+163
-169
lines changed

container/openejb-core/src/main/java/org/apache/openejb/InjectionProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private void construct() throws OpenEJBException {
132132
throw new OpenEJBException("Error while creating bean " + clazz.getName(), e);
133133
}
134134

135-
final Map unsetProperties = objectRecipe.getUnsetProperties();
135+
final Map<String, Object> unsetProperties = objectRecipe.getUnsetProperties();
136136
if (unsetProperties.size() > 0) {
137137
for (final Object property : unsetProperties.keySet()) {
138138
logger.warning("Injection: No such property '" + property + "' in class " + clazz.getName());

container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private String first(final List<Interfaces> list) {
187187

188188
private List<Interfaces> filter(final List<Interfaces> list, final String name) {
189189
final String shortName = name.replaceAll(".*/", "");
190-
final List<Interfaces> matches = new ArrayList();
190+
final List<Interfaces> matches = new ArrayList<>();
191191
for (final Interfaces entry : list) {
192192
if (name.equalsIgnoreCase(entry.getId())) {
193193
matches.add(entry);
@@ -199,7 +199,7 @@ private List<Interfaces> filter(final List<Interfaces> list, final String name)
199199
}
200200

201201
private List<Interfaces> filter(final List<Interfaces> list, final Type type) {
202-
final List<Interfaces> matches = new ArrayList();
202+
final List<Interfaces> matches = new ArrayList<>();
203203
for (final Interfaces entry : list) {
204204
if (type == Type.UNKNOWN || type == entry.type) {
205205
matches.add(entry);

container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/cmd/Info2Properties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ private static void print(final PrintStream out, final String cr, final ServiceI
269269
String uri = "new://" + info.service;
270270
if (info.service.matches("Container|Resource|Connector")) {
271271
try {
272-
final Map query = new HashMap();
272+
final Map<String, String> query = new HashMap<>();
273273
query.put("type", info.types.get(0));
274274
uri += "?" + URISupport.createQueryString(query);
275275
} catch (final Exception e) {

container/openejb-core/src/main/java/org/apache/openejb/config/SunConversion.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ private List<List<String>> parseQueryParamters(final String queryParams) {
10891089
return Collections.emptyList();
10901090
}
10911091

1092-
final List bits = Collections.list(new StringTokenizer(queryParams, " \t\n\r\f,", false));
1092+
final List<Object> bits = Collections.list(new StringTokenizer(queryParams, " \t\n\r\f,", false));
10931093
final List<List<String>> params = new ArrayList<>(bits.size() / 2);
10941094
for (int i = 0; i < bits.size(); i++) {
10951095
final String type = resolveType((String) bits.get(i));
@@ -1166,7 +1166,7 @@ private static enum TokenType {
11661166

11671167
private List<String> tokenize(final String queryFilter) {
11681168
final LinkedList<String> tokens = new LinkedList<>();
1169-
final List bits = Collections.list(new StringTokenizer(queryFilter, " \t\n\r\f()&|<>=!~+-/*", true));
1169+
final List<Object> bits = Collections.list(new StringTokenizer(queryFilter, " \t\n\r\f()&|<>=!~+-/*", true));
11701170

11711171
boolean inWitespace = false;
11721172
StringBuilder currentSymbol = new StringBuilder();

container/openejb-core/src/main/java/org/apache/openejb/config/WsDeployer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ private void resolveServiceRefs(final DeploymentModule module, final JndiConsume
9696
final String wsdlFile = serviceRef.getWsdlFile();
9797
final Definition definition = getWsdl(module, wsdlFile);
9898

99-
final Set serviceQNames = definition.getServices().keySet();
99+
final Set<QName> serviceQNames = definition.getServices().keySet();
100100
if (serviceQNames.size() == 1) {
101-
final QName serviceQName = (QName) serviceQNames.iterator().next();
101+
final QName serviceQName = serviceQNames.iterator().next();
102102
serviceRef.setServiceQname(serviceQName);
103103
} else if (serviceQNames.isEmpty()) {
104104
logger.error("The service-ref " + serviceRef.getName() + " must define service-qname because the wsdl-file " + serviceRef.getWsdlFile() + " does not constain any service definitions ");

container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckIncorrectPropertyNames.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
public class CheckIncorrectPropertyNames extends ValidationBase {
2828

29-
Map incorrectAndCorrectPropNames = new HashMap<String, String>();
29+
Map<String, String> incorrectAndCorrectPropNames = new HashMap<>();
3030

3131
{
3232
//incorrect property key : correct property key
@@ -46,7 +46,6 @@ public class CheckIncorrectPropertyNames extends ValidationBase {
4646
incorrectAndCorrectPropNames.put("java.xml.soap.MetaFactory", "jakarta.xml.soap.MetaFactory");
4747
incorrectAndCorrectPropNames.put("java.persistence.sharedCache.mode", "jakarta.persistence.sharedCache.mode");
4848
incorrectAndCorrectPropNames.put("java.persistence.validation.mode", "jakarta.persistence.validation.mode");
49-
incorrectAndCorrectPropNames.put("java.persistence.transactionType", "jakarta.persistence.transactionType");
5049

5150
incorrectAndCorrectPropNames.put("javax.naming.applet", "java.naming.applet");
5251
incorrectAndCorrectPropNames.put("javax.naming.authoritative", "java.naming.authoritative");
@@ -71,8 +70,7 @@ public void validate(final AppModule appModule) {
7170
this.module = appModule;
7271
final Properties systemProperties = SystemInstance.get().getProperties();
7372

74-
for (Object o : incorrectAndCorrectPropNames.entrySet()) {
75-
final Map.Entry<String, String> entry = (Map.Entry<String, String>) o;
73+
for (Map.Entry<String, String> entry : incorrectAndCorrectPropNames.entrySet()) {
7674
if (systemProperties.containsKey(entry.getKey())) {
7775
warn(appModule.toString(), "incorrect.property.name", entry.getKey(), entry.getValue());
7876
}

container/openejb-jee/src/main/java/org/apache/openejb/jee/Interceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ public Map<String, ContextService> getContextServiceMap() {
496496
@Override
497497
public Map<String, ManagedExecutor> getManagedExecutorMap() {
498498
if (managedExecutor == null) {
499-
managedExecutor = new KeyedCollection();
499+
managedExecutor = new KeyedCollection<>();
500500
}
501501
return this.managedExecutor.toMap();
502502
}

container/openejb-junit/src/main/java/org/apache/openejb/junit/security/TestLoginModule.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import javax.security.auth.callback.PasswordCallback;
3030
import javax.security.auth.login.LoginException;
3131
import javax.security.auth.spi.LoginModule;
32+
import java.security.Principal;
3233
import java.util.HashSet;
3334
import java.util.Map;
3435
import java.util.Set;
@@ -45,13 +46,15 @@ public class TestLoginModule implements LoginModule {
4546

4647
private String user;
4748

48-
private final Set principals = new HashSet();
49+
private final Set<Principal> principals = new HashSet<>();
4950

51+
@Override
5052
public void initialize(final Subject subject, final CallbackHandler callbackHandler, final Map sharedState, final Map options) {
5153
this.subject = subject;
5254
this.callbackHandler = callbackHandler;
5355
}
5456

57+
@Override
5558
public boolean login() throws LoginException {
5659
final Callback[] callbacks = new Callback[2];
5760

@@ -67,7 +70,8 @@ public boolean login() throws LoginException {
6770

6871
return true;
6972
}
70-
73+
74+
@Override
7175
public boolean commit() throws LoginException {
7276
principals.add(new UserPrincipal(user));
7377
principals.add(new GroupPrincipal(user));
@@ -78,11 +82,13 @@ public boolean commit() throws LoginException {
7882
return true;
7983
}
8084

85+
@Override
8186
public boolean abort() throws LoginException {
8287
user = null;
8388
return true;
8489
}
8590

91+
@Override
8692
public boolean logout() throws LoginException {
8793
subject.getPrincipals().removeAll(principals);
8894
principals.clear();

examples/component-interfaces/src/main/java/org/superbiz/FriendlyPerson.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ public class FriendlyPerson implements FriendlyPersonLocal, FriendlyPersonRemote
5757
private String defaultLanguage;
5858

5959
public FriendlyPerson() {
60-
greetings = new HashMap();
60+
greetings = new HashMap<>();
6161
languagePreferences = new Properties();
6262
defaultLanguage = Locale.getDefault().getLanguage();
6363

64+
addGreeting("de", "Hallo {0}!");
6465
addGreeting("en", "Hello {0}!");
6566
addGreeting("es", "Hola {0}!");
6667
addGreeting("fr", "Bonjour {0}!");

itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestClient.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ protected final void processFieldInjections() {
5858

5959
finder = new ClassFinder(getClassPath());
6060
fieldList = finder.findAnnotatedFields(EJB.class);
61-
for (final Iterator fields = fieldList.iterator(); fields.hasNext(); ) {
62-
final Field field = (Field) fields.next();
61+
for (final Field field : fieldList) {
6362
final EJB ejbAnnotation = field.getAnnotation(EJB.class);
6463
if ((ejbAnnotation.name() != null) && (ejbAnnotation.name() != "") && (ejbAnnotation.beanInterface() != null)) {
6564
try {
@@ -83,8 +82,7 @@ protected final void processSetterInjections() {
8382

8483
finder = new ClassFinder(getClassPath());
8584
methodList = finder.findAnnotatedMethods(EJB.class);
86-
for (final Iterator methods = methodList.iterator(); methods.hasNext(); ) {
87-
final Method method = (Method) methods.next();
85+
for (final Method method : methodList) {
8886
final EJB ejbAnnotation = method.getAnnotation(EJB.class);
8987
if ((ejbAnnotation.name() != null) && (ejbAnnotation.name() != "") && (ejbAnnotation.beanInterface() != null)) {
9088
try {

0 commit comments

Comments
 (0)