google / google/guice

Problem binding Base abstract class

Open
#1,082 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
12.7k
Forks
1.7k
Avg merge
11m
Merged PRs (30d)
2

Description

I have multiple hierarchical class like below

public abstract class Page extends SelPage
{
public method 1{}
public method 2{}
public method 3{}
}

Class DashboardPage extens Class Page{
{ }

Here I need to bind new Page class
Class ProjPage extends Page{
public method1{} /* change method implementation */
public method 2{} /* change method implementation */
public method 3{} /* change method implementation */
}

public class ProjSeleniumSuite extends SeleniumSuite {

private static Injector injector;

@BeforeClass
public static void setUp() throws Exception {
injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
System.out.println("configuriung");
bind(Page.class).to(ProjPage.class);
}
});
}
@AfterClass
public static void tearDown() throws Exception {
injector = null;
}
}

The above code runs fine..but it is not binding the Page class method implementation with ProjPage class methods
Can i achieve this using Guice binder like above?

The thing i need to achieve is, when i instantiate DashboardPage , i want ProjPage methods to be called instead of Page class methods.

Please help

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.