3 Replies Latest reply on Feb 26, 2017 7:42 PM by gastaldi

    Roaster Complex TypeVariable support

    sbordes

      Hi,

       

      With Roaster is it possible to add complex TypeVariable like this one interface Action<A extends Action<A>>

       

      I'm building an Ecore to FXJO library with fluent API and it requires to chain complex TypeVariable.

       

      Thanks!

        • 1. Re: Roaster Complex TypeVariable support
          gastaldi

          I believe that should be doable. Have you tried using

          setSuperType("Action in

          Forge - View the full discussion

          <https://developer.jboss.org/message/969154?et=watches.email.thread#969154>

          • 2. Re: Roaster Complex TypeVariable support
            sbordes

            There isn't any super type.

             

            I have An INterface Action implemented by an Abstracr class AbstractAction specialized by several concrete classes.

            To respect fluent api AbstractAction method shall return the Concrete class type passed as TypeVariable.

             

            public interface Action<A extends Action<A>> {

            }

             

            public abstract class AbstractAction<A extends Action<A>> implements Action<A>{

             

                private String name;

             

                public String name() {

                    return this.name;

                }

             

                public A name(final String name) {

                    this.name = name;

                      return (A) this;   

                 }

            }

             

            public class MyAction extends AbstractAction<MyAction> {

                private Object value;

             

                public Object value() {

                    return this.value;

                }

             

                 public MyAction setValue(final Object value) {

                    this.value = value;

                    return this;

                }

             

            With this sample I can just replace 'A extends Action<A>' by 'A' everywhere but I lose some compile type checking and for more complex samples it will be required (to generate intermediate AbstractClass with right typeVariable.

             

            Just accepting a complete String to addTypeVariable will be sufficient to hack this trouble

             

            Thanks

             

            Seb

            • 3. Re: Roaster Complex TypeVariable support
              gastaldi

              Can you open a ticket in our ROASTER - JBoss Issue Tracker with steps to reproduce (a test case would be great).

               

              Thanks!