nolanerck
10/04/2024, 6:33 PMRodney
10/04/2024, 6:44 PMRodney
10/04/2024, 6:57 PMinterface IUser
{
// some code
}
// ActiveUser
component accessors=true extends=BaseBean implements=IUser
{
init()
validate()
}
interface IRepository
{
public struct function insert( required IUser theObject );
}
component implements=IRepository
{
public struct function insert( required IUser theObject )
{
...
}
}
Cage S
10/05/2024, 5:00 AMbkbk
10/07/2024, 1:20 PMBasebean user = new ActiveUser();
But that is not what the underlying problem is in this case. I suspect that the problem here concerns the overriding of the method of an interface.
In Java, when a class implements an interface, it is required to override all the methods of the interface exactly as they are declared, including the parameter types.
So what I think is that the Basebean
type is required when Service.cfc
implements insert()
. You could modify the service CFC by doing something like:
component implements=IRepository
{
public struct function insert( required Basebean theObject )
{
// Cast the object appropriately
if (isInstanceOf(theObject, "ActiveUser")) {
// Use ActiveUser here
}
}
}