diff --git a/framework/src/play/classloading/ApplicationClassloader.java b/framework/src/play/classloading/ApplicationClassloader.java index 4eac8b8dea..da1ac216ca 100644 --- a/framework/src/play/classloading/ApplicationClassloader.java +++ b/framework/src/play/classloading/ApplicationClassloader.java @@ -102,7 +102,7 @@ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundE public Class loadApplicationClass(String name) { if (ApplicationClass.isClass(name)) { - Class maybeAlreadyLoaded = findLoadedClass(name); + Class maybeAlreadyLoaded = findLoadedClass(name); if (maybeAlreadyLoaded != null) { return maybeAlreadyLoaded; } @@ -401,9 +401,9 @@ private int computePathHash() { * * @return The list of well defined Class */ - public List getAllClasses() { + public List> getAllClasses() { if (allClasses == null) { - List result = new ArrayList<>(); + List> result = new ArrayList<>(); if (Play.usePrecompiled) { @@ -412,7 +412,7 @@ public List getAllClasses() { Play.classes.clear(); for (ApplicationClass applicationClass : applicationClasses) { Play.classes.add(applicationClass); - Class clazz = loadApplicationClass(applicationClass.name); + Class clazz = loadApplicationClass(applicationClass.name); applicationClass.javaClass = clazz; applicationClass.compiled = true; result.add(clazz); @@ -439,7 +439,7 @@ public List getAllClasses() { } for (ApplicationClass applicationClass : Play.classes.all()) { - Class clazz = loadApplicationClass(applicationClass.name); + Class clazz = loadApplicationClass(applicationClass.name); if (clazz != null) { result.add(clazz); } @@ -462,7 +462,7 @@ public List getAllClasses() { return allClasses; } - private List allClasses; + private List> allClasses; private Map allClassesByNormalizedName; /** @@ -497,7 +497,7 @@ public List getAssignableClasses(Class clazz) { * The class name. * @return a class */ - public Class getClassIgnoreCase(String name) { + public Class getClassIgnoreCase(String name) { getAllClasses(); String nameLowerCased = name.toLowerCase(); ApplicationClass c = allClassesByNormalizedName.get(nameLowerCased); @@ -517,17 +517,17 @@ public Class getClassIgnoreCase(String name) { * The annotation class. * @return A list of class */ - public List getAnnotatedClasses(Class clazz) { + public List> getAnnotatedClasses(Class clazz) { getAllClasses(); - List results = new ArrayList<>(); + List> results = new ArrayList<>(); for (ApplicationClass c : Play.classes.getAnnotatedClasses(clazz)) { results.add(c.javaClass); } return results; } - public List getAnnotatedClasses(Class[] clazz) { - List results = new ArrayList<>(); + public List> getAnnotatedClasses(Class[] clazz) { + List> results = new ArrayList<>(); for (Class cl : clazz) { results.addAll(getAnnotatedClasses(cl)); } diff --git a/framework/src/play/data/binding/Binder.java b/framework/src/play/data/binding/Binder.java index 4c999d571c..3a8b775a19 100644 --- a/framework/src/play/data/binding/Binder.java +++ b/framework/src/play/data/binding/Binder.java @@ -435,11 +435,11 @@ private static Object bindEnum(Class clazz, ParamNode paramNode) { } private static Object bindMap(Type type, ParamNode paramNode, BindingAnnotations bindingAnnotations) { - Class keyClass = String.class; - Class valueClass = String.class; + Class keyClass = String.class; + Class valueClass = String.class; if (type instanceof ParameterizedType) { - keyClass = (Class) ((ParameterizedType) type).getActualTypeArguments()[0]; - valueClass = (Class) ((ParameterizedType) type).getActualTypeArguments()[1]; + keyClass = (Class) ((ParameterizedType) type).getActualTypeArguments()[0]; + valueClass = (Class) ((ParameterizedType) type).getActualTypeArguments()[1]; } Map r = new HashMap<>(); @@ -510,11 +510,11 @@ private static Object bindCollection(Class clazz, Type type, ParamNode paramN } } - Collection l; + Collection l; if (clazz.equals(EnumSet.class)) { l = EnumSet.noneOf(componentClass); } else { - l = (Collection) createNewInstance(clazz); + l = (Collection) createNewInstance(clazz); } boolean hasMissing = false; for (String paramNodeValue : values) { @@ -537,11 +537,11 @@ private static Object bindCollection(Class clazz, Type type, ParamNode paramN return l; } - Collection r = (Collection) createNewInstance(clazz); + Collection r = (Collection) createNewInstance(clazz); if (List.class.isAssignableFrom(clazz)) { // Must add items at position resolved from each child's key - List l = (List) r; + List l = (List) r; // must get all indexes and sort them so we add items in correct order. Set indexes = new TreeSet<>((arg0, arg1) -> { @@ -690,7 +690,7 @@ private static Object internalDirectBind(String name, Annotation[] annotations, // application custom types have higher priority. If unable to bind proceed with the next one for (Class> c : Play.classloader.getAssignableClasses(TypeBinder.class)) { if (c.isAnnotationPresent(Global.class)) { - Class forType = (Class) ((ParameterizedType) c.getGenericInterfaces()[0]).getActualTypeArguments()[0]; + Class forType = (Class) ((ParameterizedType) c.getGenericInterfaces()[0]).getActualTypeArguments()[0]; if (forType.isAssignableFrom(clazz)) { Object result = createNewInstance(c).bind(name, annotations, value, clazz, type); if (result != null) { diff --git a/framework/src/play/db/jpa/JPAPlugin.java b/framework/src/play/db/jpa/JPAPlugin.java index 7a476ee7b6..3f59ee87be 100644 --- a/framework/src/play/db/jpa/JPAPlugin.java +++ b/framework/src/play/db/jpa/JPAPlugin.java @@ -147,10 +147,10 @@ public void onApplicationStart() { JPQL.instance = new JPQL(); } - private List entityClasses(String dbName) { - List entityClasses = new ArrayList<>(); + private List> entityClasses(String dbName) { + List> entityClasses = new ArrayList<>(); - List classes = Play.classloader.getAnnotatedClasses(Entity.class); + List> classes = Play.classloader.getAnnotatedClasses(Entity.class); for (Class clazz : classes) { if (clazz.isAnnotationPresent(Entity.class)) { // Do we have a transactional annotation matching our dbname? @@ -196,7 +196,7 @@ protected EntityManagerFactory newEntityManagerFactory(String dbName, Configurat } protected PersistenceUnitInfoImpl persistenceUnitInfo(String dbName, Configuration dbConfig) { - final List managedClasses = entityClasses(dbName); + final List> managedClasses = entityClasses(dbName); final Properties properties = properties(dbName, dbConfig); properties.put(org.hibernate.cfg.AvailableSettings.LOADED_CLASSES,managedClasses); return new PersistenceUnitInfoImpl(dbName, diff --git a/framework/src/play/db/jpa/PersistenceUnitInfoImpl.java b/framework/src/play/db/jpa/PersistenceUnitInfoImpl.java index 0f4a2bf063..d01c328199 100644 --- a/framework/src/play/db/jpa/PersistenceUnitInfoImpl.java +++ b/framework/src/play/db/jpa/PersistenceUnitInfoImpl.java @@ -25,7 +25,7 @@ public class PersistenceUnitInfoImpl implements PersistenceUnitInfo { private PersistenceUnitTransactionType transactionType = PersistenceUnitTransactionType.RESOURCE_LOCAL; - private final List managedClasses; + private final List> managedClasses; private final List mappingFileNames; private final Properties properties; @@ -34,7 +34,7 @@ public class PersistenceUnitInfoImpl implements PersistenceUnitInfo { private DataSource nonJtaDataSource; - public PersistenceUnitInfoImpl(String persistenceUnitName, List managedClasses, List mappingFileNames, Properties properties) { + public PersistenceUnitInfoImpl(String persistenceUnitName, List> managedClasses, List mappingFileNames, Properties properties) { this.persistenceUnitName = persistenceUnitName; this.managedClasses = managedClasses; this.mappingFileNames = mappingFileNames; diff --git a/framework/src/play/jobs/JobsPlugin.java b/framework/src/play/jobs/JobsPlugin.java index b6da2a55f6..3a9594e31a 100644 --- a/framework/src/play/jobs/JobsPlugin.java +++ b/framework/src/play/jobs/JobsPlugin.java @@ -25,7 +25,7 @@ public class JobsPlugin extends PlayPlugin { public static ScheduledThreadPoolExecutor executor; - public static final List scheduledJobs = new ArrayList<>(); + public static final List> scheduledJobs = new ArrayList<>(); private static final ThreadLocal>> afterInvocationActions = new ThreadLocal<>(); @Override @@ -49,7 +49,7 @@ public String getStatus() { out.println(); out.println("Scheduled jobs (" + scheduledJobs.size() + "):"); out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~"); - for (Job job : scheduledJobs) { + for (Job job : scheduledJobs) { out.print(job); if (job.getClass().isAnnotationPresent(OnApplicationStart.class) && !(job.getClass().isAnnotationPresent(On.class) || job.getClass().isAnnotationPresent(Every.class))) { @@ -85,9 +85,9 @@ public String getStatus() { out.println(); out.println("Waiting jobs:"); out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~"); - ScheduledFuture[] q = executor.getQueue().toArray(new ScheduledFuture[executor.getQueue().size()]); + ScheduledFuture[] q = executor.getQueue().toArray(new ScheduledFuture[executor.getQueue().size()]); - for (ScheduledFuture task : q) { + for (ScheduledFuture task : q) { out.println(Java.extractUnderlyingCallable((FutureTask) task) + " will run in " + task.getDelay(TimeUnit.SECONDS) + " seconds"); } @@ -98,7 +98,7 @@ public String getStatus() { @Override public void afterApplicationStart() { List> jobs = new ArrayList<>(); - for (Class clazz : Play.classloader.getAllClasses()) { + for (Class clazz : Play.classloader.getAllClasses()) { if (Job.class.isAssignableFrom(clazz)) { jobs.add(clazz); } @@ -133,7 +133,7 @@ public void afterApplicationStart() { Job job = createJob(clazz); // start running job now in the background @SuppressWarnings("unchecked") - Callable callable = (Callable) job; + Callable> callable = (Callable>) job; executor.submit(callable); } catch (InstantiationException | IllegalAccessException ex) { throw new UnexpectedException("Cannot instantiate Job " + clazz.getName(), ex); @@ -153,7 +153,7 @@ public void afterApplicationStart() { // @Every if (clazz.isAnnotationPresent(Every.class)) { try { - Job job = createJob(clazz); + Job job = createJob(clazz); String value = clazz.getAnnotation(Every.class).value(); if (value.startsWith("cron.")) { value = Play.configuration.getProperty(value); @@ -228,7 +228,7 @@ public void onApplicationStop() { List jobs = Play.classloader.getAssignableClasses(Job.class); - for (Class clazz : jobs) { + for (Class clazz : jobs) { // @OnApplicationStop if (clazz.isAnnotationPresent(OnApplicationStop.class)) { try { diff --git a/framework/src/play/libs/F.java b/framework/src/play/libs/F.java index bf6b993e00..5431f22c05 100644 --- a/framework/src/play/libs/F.java +++ b/framework/src/play/libs/F.java @@ -672,9 +672,9 @@ public synchronized Promise>> nextEvents(long lastEventSeen return filter; } - public synchronized List availableEvents(long lastEventSeen) { - List result = new ArrayList<>(); - for (IndexedEvent event : events) { + public synchronized List> availableEvents(long lastEventSeen) { + List> result = new ArrayList<>(); + for (IndexedEvent event : events) { if (event.id > lastEventSeen) { result.add(event); } @@ -695,7 +695,7 @@ public synchronized void publish(T event) { Logger.warn("Dropping message. If this is catastrophic to your app, use a BlockingEvenStream instead"); events.poll(); } - events.offer(new IndexedEvent(event)); + events.offer(new IndexedEvent(event)); notifyNewEvent(); for (EventStream eventStream : pipedStreams) { eventStream.publish(event); @@ -765,7 +765,7 @@ public static Some Some(T value) { } public static Some Some(A a) { - return new Some(a); + return new Some(a); } public static class None extends Option { diff --git a/framework/src/play/plugins/PluginCollection.java b/framework/src/play/plugins/PluginCollection.java index c5cd8ee885..2bf16f6643 100644 --- a/framework/src/play/plugins/PluginCollection.java +++ b/framework/src/play/plugins/PluginCollection.java @@ -236,7 +236,7 @@ public void reloadApplicationPlugins() throws Exception { // Is this plugin an application-supplied-plugin? if (isLoadedByApplicationClassloader(plugin)) { // This plugin is application-supplied - Must reload it - Class pluginClazz = Play.classloader.loadClass(plugin.getClass().getName()); + Class pluginClazz = Play.classloader.loadClass(plugin.getClass().getName()); PlayPlugin newPlugin = (PlayPlugin) Injector.getBeanOfType(pluginClazz); newPlugin.index = plugin.index; // Replace this plugin @@ -458,7 +458,7 @@ public F.Option> composeFilters() { Iterator itr = pluginsWithFilters.iterator(); PlayPlugin.Filter ret = itr.next().getFilter(); while (itr.hasNext()) { - ret = ret. decorate(itr.next().getFilter()); + ret = ret.decorate(itr.next().getFilter()); } return F.Option.Some(ret); } diff --git a/framework/src/play/server/HttpServerPipelineFactory.java b/framework/src/play/server/HttpServerPipelineFactory.java index ca006c307c..8c79612585 100644 --- a/framework/src/play/server/HttpServerPipelineFactory.java +++ b/framework/src/play/server/HttpServerPipelineFactory.java @@ -14,7 +14,7 @@ public class HttpServerPipelineFactory implements ChannelPipelineFactory { - protected static final Map classes = new HashMap<>(); + protected static final Map> classes = new HashMap<>(); private final String pipelineConfig = Play.configuration.getProperty("play.netty.pipeline", "play.server.FlashPolicyHandler,org.jboss.netty.handler.codec.http.HttpRequestDecoder,play.server.StreamChunkAggregator,org.jboss.netty.handler.codec.http.HttpResponseEncoder,org.jboss.netty.handler.stream.ChunkedWriteHandler,play.server.PlayHandler"); @@ -68,7 +68,7 @@ protected String getName(String name) { protected ChannelHandler getInstance(String name) throws Exception { - Class clazz = classes.computeIfAbsent(name, className -> { + Class clazz = classes.computeIfAbsent(name, className -> { try { return Class.forName(className); } catch (ClassNotFoundException e) { diff --git a/framework/src/play/templates/BaseTemplate.java b/framework/src/play/templates/BaseTemplate.java index 7b3e4fd0e0..2cb19bdd94 100644 --- a/framework/src/play/templates/BaseTemplate.java +++ b/framework/src/play/templates/BaseTemplate.java @@ -22,7 +22,7 @@ public abstract class BaseTemplate extends Template { public String compiledSource; public Map linesMatrix = new HashMap<>(); public Set doBodyLines = new HashSet<>(); - public Class compiledTemplate; + public Class compiledTemplate; public String compiledTemplateName; public BaseTemplate(String name, String source) { diff --git a/framework/src/play/templates/GroovyTemplate.java b/framework/src/play/templates/GroovyTemplate.java index 73ea940110..6848fb205b 100644 --- a/framework/src/play/templates/GroovyTemplate.java +++ b/framework/src/play/templates/GroovyTemplate.java @@ -99,7 +99,7 @@ public TClassLoader() { super(Play.classloader); } - public Class defineTemplate(String name, byte[] byteCode) { + public Class defineTemplate(String name, byte[] byteCode) { return defineClass(name, byteCode, 0, byteCode.length, Play.classloader.protectionDomain); } } @@ -113,7 +113,7 @@ void directLoad(byte[] code) throws Exception { for (int i = 4; i < lines.length; i = i + 2) { String className = lines[i]; byte[] byteCode = Codec.decodeBASE64(lines[i + 1]); - Class c = tClassLoader.defineTemplate(className, byteCode); + Class c = tClassLoader.defineTemplate(className, byteCode); if (compiledTemplate == null) { compiledTemplate = c; } @@ -153,7 +153,7 @@ public void compile() { // default output operation with the Play Groovy class handler. Field phasesF = compilationUnit.getClass().getDeclaredField("phaseOperations"); phasesF.setAccessible(true); - Collection[] phases = (Collection[]) phasesF.get(compilationUnit); + Collection[] phases = (Collection[]) phasesF.get(compilationUnit); LinkedList output = new LinkedList<>(); phases[Phases.OUTPUT] = output; output.add(groovyClassesForThisTemplate::add); @@ -409,7 +409,7 @@ public Object getProperty(String property) { } } - public void invokeTag(Integer fromLine, String tag, Map attrs, Closure body) { + public void invokeTag(Integer fromLine, String tag, Map attrs, Closure body) { String templateName = tag.replace('.', '/'); String callerExtension = (extension != null) ? extension : "tag"; @@ -466,7 +466,7 @@ public void invokeTag(Integer fromLine, String tag, Map attrs, C * @throws Exception * if problem occured when loading the class */ - public Class __loadClass(String className) throws Exception { + public Class __loadClass(String className) throws Exception { try { return Play.classloader.loadClass(className); } catch (ClassNotFoundException e) { diff --git a/framework/src/play/templates/GroovyTemplateCompiler.java b/framework/src/play/templates/GroovyTemplateCompiler.java index 78bfdb9d17..e988b1d20a 100644 --- a/framework/src/play/templates/GroovyTemplateCompiler.java +++ b/framework/src/play/templates/GroovyTemplateCompiler.java @@ -3,7 +3,6 @@ import java.io.PrintWriter; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -68,7 +67,7 @@ protected String checkScalaCompatibility(String source) { // Static access List names = new ArrayList<>(); Map originalNames = new HashMap<>(); - for (Class clazz : Play.classloader.getAllClasses()) { + for (Class clazz : Play.classloader.getAllClasses()) { if (clazz.getName().endsWith("$")) { String name = clazz.getName().substring(0, clazz.getName().length() - 1).replace('$', '.') + '$'; names.add(name); diff --git a/framework/src/play/templates/JavaExtensions.java b/framework/src/play/templates/JavaExtensions.java index 284592835d..0cbd6f3122 100644 --- a/framework/src/play/templates/JavaExtensions.java +++ b/framework/src/play/templates/JavaExtensions.java @@ -39,7 +39,7 @@ */ public class JavaExtensions { - public static Object[] enumValues(Class clazz) { + public static Object[] enumValues(Class clazz) { return clazz.getEnumConstants(); } @@ -73,7 +73,7 @@ public static String[] remove(String[] array, String s) { return temp.toArray(new String[temp.size()]); } - public static String toString(Closure closure) { + public static String toString(Closure closure) { PrintWriter oldWriter = (PrintWriter) closure.getProperty("out"); StringWriter newWriter = new StringWriter(); closure.setProperty("out", new PrintWriter(newWriter)); @@ -124,14 +124,14 @@ public static RawData raw(Object val, Object condition) { return new RawData(""); } - public static RawData asAttr(Map attributes, Object condition) { + public static RawData asAttr(Map attributes, Object condition) { if (eval(condition)) { return asAttr(attributes); } return new RawData(""); } - public static RawData asAttr(Map attributes) { + public static RawData asAttr(Map attributes) { StringBuilder buf = new StringBuilder(); for (Object key : attributes.keySet()) { buf.append(key).append("=\"").append(attributes.get(key)).append("\" "); @@ -146,7 +146,7 @@ protected static boolean eval(Object condition) { if (condition instanceof Boolean && !(Boolean) condition) { return false; } - if (condition instanceof Collection && ((Collection) condition).size() == 0) { + if (condition instanceof Collection && ((Collection) condition).size() == 0) { return false; } if (condition instanceof String && condition.toString().equals("")) { @@ -333,7 +333,7 @@ public static String pluralize(Number n) { return ""; } - public static String pluralize(Collection n) { + public static String pluralize(Collection n) { return pluralize(n.size()); } @@ -345,7 +345,7 @@ public static String pluralize(Number n, String plural) { return ""; } - public static String pluralize(Collection n, String plural) { + public static String pluralize(Collection n, String plural) { return pluralize(n.size(), plural); } @@ -357,7 +357,7 @@ public static String pluralize(Number n, String[] forms) { return forms[0]; } - public static String pluralize(Collection n, String[] forms) { + public static String pluralize(Collection n, String[] forms) { return pluralize(n.size(), forms); } @@ -429,12 +429,12 @@ public static Object last(List items) { * The separator to used * @return The concatenate items of a collection as a string */ - public static String join(Collection items, String separator) { + public static String join(Collection items, String separator) { if (items == null) { return ""; } StringBuilder sb = new StringBuilder(); - Iterator ite = items.iterator(); + Iterator ite = items.iterator(); int i = 0; while (ite.hasNext()) { if (i++ > 0) { diff --git a/framework/src/play/test/Fixtures.java b/framework/src/play/test/Fixtures.java index 6346180fff..6cf1b4e386 100644 --- a/framework/src/play/test/Fixtures.java +++ b/framework/src/play/test/Fixtures.java @@ -492,7 +492,7 @@ public static void deleteDirectory(String path) { */ static Map serialize(Map entityProperties, String prefix) { if (entityProperties == null) { - return Collections.EMPTY_MAP; + return Collections.emptyMap(); } Map serialized = new HashMap<>(); diff --git a/framework/src/play/utils/Java.java b/framework/src/play/utils/Java.java index 5fc7111f0e..0f36341ed0 100644 --- a/framework/src/play/utils/Java.java +++ b/framework/src/play/utils/Java.java @@ -140,7 +140,7 @@ public static Object invokeStatic(String clazz, String method) throws Exception * if problem occurred during invoking */ public static Object invokeStatic(Class clazz, String method, Object... args) throws Exception { - Class[] types = new Class[args.length]; + Class[] types = new Class[args.length]; for (int i = 0; i < args.length; i++) { types[i] = args[i].getClass(); } @@ -150,7 +150,7 @@ public static Object invokeStatic(Class clazz, String method, Object... args) } public static Object invokeStaticOrParent(Class clazz, String method, Object... args) throws Exception { - Class[] types = new Class[args.length]; + Class[] types = new Class[args.length]; for (int i = 0; i < args.length; i++) { types[i] = args[i].getClass(); } @@ -175,7 +175,7 @@ public static Object invokeStaticOrParent(Class clazz, String method, Object. } public static Object invokeChildOrStatic(Class clazz, String method, Object... args) throws Exception { - Class invokedClass = null; + Class invokedClass = null; List assignableClasses = Play.classloader.getAssignableClasses(clazz); if (assignableClasses.size() == 0) { invokedClass = clazz; @@ -234,7 +234,7 @@ public static String rawMethodSignature(Method method) { sig.append("."); sig.append(method.getName()); sig.append('('); - for (Class clazz : method.getParameterTypes()) { + for (Class clazz : method.getParameterTypes()) { sig.append(rawJavaType(clazz)); } sig.append(")"); @@ -242,7 +242,7 @@ public static String rawMethodSignature(Method method) { return sig.toString(); } - public static String rawJavaType(Class clazz) { + public static String rawJavaType(Class clazz) { if (clazz.getName().equals("void")) { return "V"; } @@ -298,19 +298,19 @@ public static List findAllAnnotatedMethods(Class clazz, Class findAllAnnotatedMethods(List classes, Class annotationType) { + public static List findAllAnnotatedMethods(List> classes, Class annotationType) { List methods = new ArrayList<>(); - for (Class clazz : classes) { + for (Class clazz : classes) { methods.addAll(findAllAnnotatedMethods(clazz, annotationType)); } return methods; } - public static void findAllFields(Class clazz, Set found) { + public static void findAllFields(Class clazz, Set found) { Field[] fields = clazz.getDeclaredFields(); addAll(found, fields); - Class sClazz = clazz.getSuperclass(); + Class sClazz = clazz.getSuperclass(); if (sClazz != null && sClazz != Object.class) { findAllFields(sClazz, found); } @@ -579,7 +579,7 @@ public List findAllAnnotatedMethods(Class clazz) { } } if (clazz.isAnnotationPresent(With.class)) { - for (Class withClass : clazz.getAnnotation(With.class).value()) { + for (Class withClass : clazz.getAnnotation(With.class).value()) { methods.addAll(findAllAnnotatedMethods(withClass)); } }