I want to create an object which implements interface FileTree in Gradle.
From what I can find from documentation FileTreeAdapter class implements FileTree, but it is internal class.
How can I initialize my object filesToDelete? And how can I find which classes implements FileTree interface from the documentation?
public class DeleteDirTask extends DefaultTask {
#InputFiles #Optional
FileTree filesToDelete = files("/src/")
...
}
How can I initialize my object filesToDelete?
Use project.fileTree(). (project.files() is for FileCollections.)
And how can I find which classes implements FileTree interface from the documentation?
The implementation classes are internal, and you shouldn't have to worry about them.
Related
I'm a new learner, I'm practicing the base and child classes. My question is how do we decide which class should be instantiated, extended or the Baseclass?
Thanks in advance
package MavenProject2Package2;
import org.testng.annotations.Test;
import MavenProject2Package.JavaTesting;
public class JavaTesting2 extends JavaTesting
{
#Test
public void f1()
{
JavaTesting a1 = new JavaTesting();
System.out.println(a1.msg);
JavaTesting2 a2 = new JavaTesting2();
System.out.println(a2.msg);
}
}
Base class - it's a class which you should be extending from. - eg - superclass.
In superclass you may put some general fields and methods, which are used across your web app. For example, locators for header as well as footer items, because they are the same for all the pages (mostly).
We are receiving the following exceptions in one of our code :
java.lang.IllegalAccessError: tried to access class base.BaseMessage from class message.beans.TerminalPowerCommandProducer$Proxy$_$$_WeldSubclass
Our class structure is as follows :
The Base Message creator class with default message properties
package messages.base
//... required imports
abstract class BaseMessage{ //some protected variables and methods }
the intermediate message class with extension to BaseMessage some additional properties for specific message types
package messages.base
//... required imports
public abstract class PowerMessage extends BaseMessage {//some more protected variables and Logger(using #Inject) and methods}
The actual implementation of the above abstract classes
package messages.beans
//... required imports
#Named
public class TerminalCommandMessage extends PowerMessage {// some more variables with injections and methods with abstract method implementation}
This class is now injected in some other classes :
package messages.beans
#Named
public class TerminalPowerCommandProducer {
#Inject
TerminalCommandMessage commandMessage
//some other code
}
We are receiving exception as reported above.
We are using WildFly version 10.1.0 Final with jdk 8
Is there an issue with the way we have consumed it?
Because if we mark the BaseMessage class as public it all works fine.
We have two auth methods for different modules – UserAuthModule and ServiceAuthModule. We’ve created 2 base classes that modules derive from. We’ve interfaced the AuthProviders into IAuthProvider. Then we have a dependency in the constructors that should get the correct AuthProvider injected. However, we can’t find a way to tell Nancy/TinyIoC which concrete class to use. Here is the pseudo-code:
abstract class UserAuthModule : NancyModule
{
public UserAuthModule(IAuthProvider authProvider) // should get the UserAuthProvider concrete class
}
abstract class ServiceAuthModule : NancyModule
{
public ServiceAuthModule(IAuthProvider authProvider) // should get the ServiceAuthProvider concrete class
}
Here's an example of one of the concrete module's class declaration:
public class AccountModule : UserAuthModule
We then get stuck: how do we register 2 concrete classes for the IAuthProvider interface? We could name them, but can’t figure out how Nancy knows which class to inject when it does the constructor injection.
Inside our bootstrapper we have:
Container.Register<IAuthProvider, UserAuthProvider>(“UserAuth”);
Container.Register<IAuthProvider, ServiceAuthProvider>(“ServiceAuth”);
We could resolve the type from the container, but there's not container access within the Nancy module.
Is creating a unique interface for each based off of IAuthProvider out of the question?
interface IUserAuthProvider : IAuthProvider { }
interface IServiceAuthProvider : IAuthProvider { }
And then register:
Container.Register<IUserAuthProvider, UserAuthProvider>();
Container.Register<IServiceAuthProvider, ServiceAuthProvider>();
And then modify the constructors:
public UserAuthModule(IUserAuthProvider authProvider)
public ServiceAuthModule(IServiceAuthProvider authProvider)
I'm compiling three.d.ts (available from here) with the TypeScript develop branch. I get the following error:
Types of static property 'Utils' of class 'THREE.Shape' and class 'THREE.Path'
are incompatible
The problem is that
Shape defines a static Utils class
Shape indirectly inherits from Curve
Curve also defines a static Utils class with a signature unrelated to Shape.Utils
which is ill-formed according to the language spec. Summarised, three.d.ts contains something like the following code:
declare class A {
static Utils: {
f (): any;
}
}
declare class B extends A {
static Utils: {
// incompatible with A.Utils, without f(): any
g (): any;
}
}
Putting aside the question of why the type of a static member must be compatible with that of an inherited static member of the same name - which isn't the case in several other OO languages, but which does appear to be the case in TypeScript - I would like to know how to fix three.d.ts so I can compile it.
My current workaround is simply to copy and paste the signature of Curve.Utils into Shape.Utils, so that the latter structurally extends the former. But what is the "right" way to capture the signature of the underlying three.js file (here) in a .d.ts file? Is this a case of inheritance being used incorrectly?
Short answer is, per spec, Typescript doesn't allow member hiding through inheritance, like C# does automatically for example.
As defined in the language specifications section 8.2.3
A derived class inherits all members from its base class it doesn’t override. Inheritance means that a
derived class implicitly contains all non-overridden members of the base class. Both public and private
members are inherited, but only public members can be overridden. A member in a derived class is said
to override a member in a base class when the derived class member has the same name and kind
(instance or static) as the base class member. The type of an overriding member must be a subtype
(section 3.8.2) of the type of the overridden member, or otherwise a compile-time error occurs.
and
Base class static members can be overridden by derived class static members of any kind as >long as the
types are compatible, as described above.
Maybe they added some type checking into the latest compiler version which was missing before...
Here is a proposed solution, based on inheritance:
declare class UtilsA{
f():any;
}
declare class UtilsB extends UtilsA{
g():any;
}
declare class A {
static Utils:UtilsA;
}
declare class B extends A {
static Utils:UtilsB;
}
I am looking for a maven plugin that will auto generate EntityProxy interfaces from my domain classes.
The class could implement the various interfaces to be generated and then each field or accessor method could use an annotation.
public class MyDomainObject implements MyDOProxyFoo, MyDOProxyBar {
#ExposedBy({MyDOProxyFoo.class})
public String foo;
#ExposedBy({MyDOProxyBar.class})
public String bar;
#ExposedBy({MyDOProxyFoo.class,MyDOProxyBar.class})
public String foobar;
...
}
Then the getters/setters for the respective fields would be in the respective generated interfaces.
You could do something like a readonly attribute in the annotation to only expose a getter in the specified interfaces.
...
#ExposedBy({MyDOProxyBar.class}, readOnly = {MyDOProxyFoo.class})
public String bar;
...
I could run something like
mvn rfproxygen:generateproxies
and I would have all my proxy interfaces nicely created in the generated sources directory.
I guess the argument is deciding wether you should have service data binding logic in your domain model.
I don't know a maven plugin that is capable of generating proxies but there is an issue addressing this for GWTP. Maybe this will of interests for you if it's finished.