polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@hedhman.org>
Subject @Construction
Date Fri, 19 May 2017 09:10:35 GMT
I just had this crazy idea;

public interface MyValueBuilder
    MyValue create( String name, LocalDate expiry );

    MyValue create( String name, String description, LocalDate expiry );

public interface MyValue
    interface State
        Property<String> name();

        Property<String> description();

        Property<LocalDate> expiry();

Now, the MyValueBuilder could simply be a service, which has a generic
mixin that uses the "parameter names" to initialize the properties

But it would be much neater if the MyValueBuilder is registered at assembly
as the ValueBuilder for the MyValue type, and that it is automatically
returned. Of course, in that case it is a subinterface of

MyValueBuilder builder = vbf.newValueBuilder(MyValueBuilder.class);
MyValue first = builder.create( "NIclas", LocalDate.now().plusDays(1) );
MyValue second = builder.create( "Paul", "More stamina",
LocalDate.now().plusDays(14) );

BUT WAIT, there is more... But then this could mean that the MyValueBuilder
would end up being a Composite with a Mixin, i.e. the Composite Builders
could themselves be Composites???  Chicken-Egg problem?

Any thoughts?

Niclas Hedhman, Software Developer
http://polygene.apache.org - New Energy for Java

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message