Play stubs improvements, cleanup and return values

This commit is contained in:
Francis Alexander
2021-03-02 16:50:16 +05:30
parent 8e83de1c05
commit 4384f78595
25 changed files with 435 additions and 2870 deletions

View File

@@ -7,82 +7,25 @@ import java.io.File;
import java.io.InputStream;
import java.net.URL;
//import play.inject.Injector; -> Scala stuff
//import play.libs.Scala;
/**
* A Play application.
*
* Application creation is handled by the framework engine.
*/
public interface Application {
/**
* Get the underlying Scala application.
*
* @
*/
//play.api.Application getWrappedApplication();
default File path() {
return null;
}
/**
* Get the application configuration.
*
* @
*/
//Configuration configuration();
default ClassLoader classloader() {
return null;
}
/**
* Get the injector for this application.
*
* @
*/
//Injector injector();
default File getFile(String relativePath) {
return null;
}
/**
* Get the application path.
*
* @
*/
default File path() {
}
default URL resource(String relativePath) {
return null;
}
/**
* Get the application classloader.
*
* @
*/
default ClassLoader classloader() {
}
/**
* Get a file relative to the application root path.
*
* @param relativePath relative path of the file to fetch
* @
*/
default File getFile(String relativePath) {
}
/**
* Get a resource from the classpath.
*
* @param relativePath relative path of the resource to fetch
* @
*/
default URL resource(String relativePath) {
}
/**
* Get a resource stream from the classpath.
*
* @param relativePath relative path of the resource to fetch
* @
*/
default InputStream resourceAsStream(String relativePath) {
}
}
default InputStream resourceAsStream(String relativePath) {
return null;
}
}

View File

@@ -1,20 +1,10 @@
package play;
/**
* High-level API to access Play global features.
*
* @deprecated Please use dependency injection. Deprecated since 2.5.0.
*/
@Deprecated
public class Play {
/**
* @deprecated inject the {@link play.Application} instead. Deprecated since 2.5.0.
* @return Deprecated
*/
@Deprecated
public static Application application() {
return null;
}
//private static play.api.Application privateCurrent() { }
}
}

View File

@@ -1,6 +1,3 @@
package play.api.mvc;
/** Scala dummy */
public class Request<RequestBody> {
}
public class Request<RequestBody> {}

View File

@@ -1,6 +1,3 @@
package play.api.mvc;
/** Scala dummy */
public class RequestHeader {
}
public class RequestHeader {}

View File

@@ -1,6 +1,3 @@
package play.api.mvc;
/** XML utilities. */
public class StatusHeader {
}
public class StatusHeader {}

View File

@@ -1,6 +1,3 @@
package play.core.j;
/** XML utilities. */
public class JavaContextComponents {
}
public class JavaContextComponents {}

View File

@@ -1,6 +1,3 @@
package play.core.j;
/** Scala dummy */
public class RequestImpl {
}
public class RequestImpl {}

View File

@@ -5,7 +5,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** This action adds a CSRF token to the request and response if not already there. */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
public @interface AddCSRFToken {}
public @interface AddCSRFToken {}

View File

@@ -1,6 +1,3 @@
package play.http;
/** XML utilities. */
public abstract class HttpEntity {
}
public abstract class HttpEntity {}

View File

@@ -5,14 +5,5 @@
package play.i18n;
import java.util.*;
import java.util.stream.Stream;
//import play.Application;
//import play.libs.*;
//import scala.collection.immutable.Seq;
import static java.util.stream.Collectors.toList;
/** A Lang supported by the application. */
public class Lang /* extends play.api.i18n.Lang */ {
}
public class Lang /* extends play.api.i18n.Lang */ {}

View File

@@ -1,5 +1,4 @@
package play.i18n;
/** A Lang supported by the application. */
public class Langs {
}
public class Langs {}

View File

@@ -4,10 +4,4 @@
package play.i18n;
/**
* A Messages will produce messages using a specific language.
*
* <p>This interface that is typically backed by MessagesImpl, but does not return MessagesApi.
*/
public interface Messages {
}
public interface Messages {}

View File

@@ -4,14 +4,4 @@
package play.i18n;
//import javax.inject.Singleton;
/**
* A Messages will produce messages using a specific language.
*
* <p>This interface that is typically backed by MessagesImpl, but does not return MessagesApi.
*/
//@Singleton
public class MessagesApi {
}
public class MessagesApi {}

View File

@@ -7,9 +7,6 @@ package play.libs;
import java.util.*;
import java.util.concurrent.*;
// import scala.concurrent.ExecutionContext;
/** Defines a set of functional programming style helpers. */
public class F {
public static class Promise<A> { // this is needed for play.libs.F for Play 2.3.x
public static <A> Promise<A> pure(final A a) {

View File

@@ -4,40 +4,30 @@
package play.libs;
//import javax.inject.Inject;
import java.io.File;
import java.nio.file.Path;
/** Contains TemporaryFile and TemporaryFileCreator operations. */
public final class Files {
/** This creates temporary files when Play needs to keep overflow data on the filesystem. */
public interface TemporaryFileCreator {
TemporaryFile create(String prefix, String suffix);
TemporaryFile create(Path path);
boolean delete(TemporaryFile temporaryFile);
// Needed for RawBuffer compatibility
}
/** A temporary file created by a TemporaryFileCreator. */
public interface TemporaryFile {
/** @return the path to the temporary file. */
Path path();
/**
* @return the temporaryFile as a java.io.File.
* @deprecated Use path() over file().
*/
@Deprecated
File file();
TemporaryFileCreator temporaryFileCreator();
default TemporaryFile moveTo(File to) {
return null;
}
TemporaryFile moveTo(File to, boolean replace);
@@ -45,65 +35,61 @@ public final class Files {
TemporaryFile atomicMoveWithFallback(File to);
}
/** A temporary file creator that delegates to a Scala TemporaryFileCreator. */
public static class DelegateTemporaryFileCreator implements TemporaryFileCreator {
//private final play.api.libs.Files.TemporaryFileCreator temporaryFileCreator;
//@Inject
/* public DelegateTemporaryFileCreator(
play.api.libs.Files.TemporaryFileCreator temporaryFileCreator) {
*///}
public TemporaryFile create(String prefix, String suffix) {
return null;
}
public TemporaryFile create(Path path) {
return null;
}
public boolean delete(TemporaryFile temporaryFile) {
return true;
}
//public play.api.libs.Files.TemporaryFileCreator asScala() {}
}
/** Delegates to the Scala implementation. */
public static class DelegateTemporaryFile implements TemporaryFile {
public Path path() {
return null;
}
public File file() {
return null;
}
public TemporaryFileCreator temporaryFileCreator() {
return null;
}
public TemporaryFile moveTo(File to, boolean replace) {
return null;
}
public TemporaryFile atomicMoveWithFallback(File to) {
return null;
}
}
/**
* A temporary file creator that uses the Scala play.api.libs.Files.SingletonTemporaryFileCreator
* class behind the scenes.
*/
public static class SingletonTemporaryFileCreator implements TemporaryFileCreator {
public TemporaryFile create(String prefix, String suffix) {
return null;
}
public TemporaryFile create(Path path) {
return null;
}
public boolean delete(TemporaryFile temporaryFile) {
return true;
}
}
private static final TemporaryFileCreator instance = new Files.SingletonTemporaryFileCreator();
/** @return the singleton instance of SingletonTemporaryFileCreator. */
public static TemporaryFileCreator singletonTemporaryFileCreator() {
return null;
}
}
}

View File

@@ -1,6 +1,3 @@
package play.libs;
/** XML utilities. */
public class XML {
}
public class XML {}

View File

@@ -4,13 +4,4 @@
package play.libs.typedmap;
//import play.api.libs.typedmap.TypedKey$;
/**
* A TypedKey is a key that can be used to get and set values in a {@link TypedMap} or any object
* with typed keys. This class uses reference equality for comparisons, so each new instance is
* different key.
*/
public final class TypedKey<A> {
}
public final class TypedKey<A> {}

View File

@@ -4,22 +4,4 @@
package play.libs.typedmap;
import play.libs.typedmap.TypedKey;
import java.util.Optional;
/**
* A TypedMap is an immutable map containing typed values. Each entry is associated with a {@link
* TypedKey} that can be used to look up the value. A <code>TypedKey</code> also defines the type of
* the value, e.g. a <code>TypedKey&lt;String&gt;</code> would be associated with a <code>String
* </code> value.
*
* <p>Instances of this class are created with the {@link #empty()} method.
*
* <p>The elements inside TypedMaps cannot be enumerated. This is a decision designed to enforce
* modularity. It's not possible to accidentally or intentionally access a value in a TypedMap
* without holding the corresponding {@link TypedKey}.
*/
public final class TypedMap {
}
public final class TypedMap {}

View File

@@ -9,30 +9,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** A body parser parses the HTTP request body content. */
public interface BodyParser<A> {
/**
* Return an accumulator to parse the body of the given HTTP request.
*
* <p>The accumulator should either produce a result if an error was encountered, or the parsed
* body.
*
* @param request The request to create the body parser for.
* @return The accumulator to parse the body.
*/
/** Specify the body parser to use for an Action method. */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@interface Of {
/**
* The class of the body parser to use.
*
* @return the class
*/
//Class<? extends BodyParser> value();
}
}
@interface Of {}
}

View File

@@ -3,13 +3,4 @@
*/
package play.mvc;
/**
* Any action result.
*/
public class Call {
/**
* Retrieves the real (Scala-based) result.
*/
// play.api.mvc.Result toScala();
}
public class Call {}

View File

@@ -1,110 +1,59 @@
package play.mvc;
import play.i18n.Lang;
import play.mvc.Http.HeaderNames;
import play.mvc.Http.Response;
import play.mvc.Http.Context;
import play.mvc.Http.Flash;
import play.mvc.Http.HeaderNames;
import play.mvc.Http.Request;
import play.mvc.Http.Response;
import play.mvc.Http.Session;
import play.mvc.Http.Status;
import play.mvc.Http.Flash;
/**
* Superclass for a Java-based controller.
*/
public abstract class Controller extends Results implements Status, HeaderNames {
/**
* Returns the current HTTP context.
*/
public static Context ctx() {
public static Context ctx() {
return null;
}
}
public static Request request() {
return null;
}
/**
* Returns the current HTTP request.
*/
public static Request request() {
public static Lang lang() {
return null;
}
}
public static boolean changeLang(String code) {
return true;
}
/**
* Returns the current lang.
*/
public static Lang lang() {
public static boolean changeLang(Lang lang) {
return true;
}
}
public static void clearLang() {}
/**
* Change durably the lang for the current user
* @param code New lang code to use (e.g. "fr", "en-US", etc.)
* @
*/
public static boolean changeLang(String code) {
public static Response response() {
return null;
}
}
public static Session session() {
return null;
}
/**
* Change durably the lang for the current user
* @param lang New Lang object to use
* @
*/
public static boolean changeLang(Lang lang) {
public static void session(String key, String value) {}
}
public static String session(String key) {
return "";
}
/**
* Clear the lang for the current user.
*/
public static void clearLang() {
}
public static Flash flash() {
return null;
}
/**
* Returns the current HTTP response.
*/
public static Response response() {
public static void flash(String key, String value) {}
}
/**
* Returns the current HTTP session.
*/
public static Session session() {
}
/**
* Puts a new value into the current session.
*/
public static void session(String key, String value) {
}
/**
* Returns a value from the session.
*/
public static String session(String key) {
}
/**
* Returns the current HTTP flash scope.
*/
public static Flash flash() {
}
/**
* Puts a new value into the flash scope.
*/
public static void flash(String key, String value) {
}
/**
* Returns a value from the flash scope.
*/
public static String flash(String key) {
}
}
public static String flash(String key) {
return "";
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,4 @@
package play.mvc;
/** Any action result. */
public class Result {
}
public class Result {}

File diff suppressed because it is too large Load Diff

View File

@@ -3,9 +3,4 @@
*/
package play.twirl.api;
/**
* Play twirl Content result. (Part of scala)
*/
public class Content {
}
public class Content {}