polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niclas Hedhman (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (POLYGENE-179) Mechanism to declare Defaults factories
Date Sun, 28 May 2017 16:30:04 GMT

    [ https://issues.apache.org/jira/browse/POLYGENE-179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16027857#comment-16027857
] 

Niclas Hedhman commented on POLYGENE-179:
-----------------------------------------

NOTE: There is code about this going into 3.0 release, but it is not working and any attempt
to use it is likely to fail.

Target this for 3.1 or more likely 3.2 or later

> Mechanism to declare Defaults factories
> ---------------------------------------
>
>                 Key: POLYGENE-179
>                 URL: https://issues.apache.org/jira/browse/POLYGENE-179
>             Project: Polygene
>          Issue Type: New Feature
>            Reporter: Niclas Hedhman
>            Assignee: Niclas Hedhman
>            Priority: Minor
>
> Currently, it is possible to declare a default value for properties during assembly.
> {code}
> module.forMixin( Abc.class ).declareDefaults().someProperty().set( 123 );
> {code}
> But there is no way to do this for Property declarations that take ValueComposites as
their type, since the Runtime has not be activated yet.
> But if it was possible to declare a closure, which is capable of creating anything inside
the Polygene runtime. Then we could do something like this;
> {code}
> public interface Abc
> {
>     Property<Address> address();
> }
> void assemble( ModuleAssembly module ) 
> {
>     module.forMixin( Abc.class ).declareInitialValueProvider( (module, propertyDescriptor)
-> 
>     {
>         switch( propertyDescriptor.qualifiedName() )
>         {
>             case "Abc:address":
>                 ValueBuilder<Address> builder = module.valueBuilderFactory().newValueBuilder(
Address.class );
>                 Address prototype = builder.prototype();
>                 prototype.city().set( "<not set>" );
>                 prototype.country().set( "<not set>" );
>                 prototype.zipcode().set( "<not set>" );
>                 prototype.line1().set( "<not set>" );
>                 prototype.line2.set( "<not set>" );
>                 return builder.newInstance();
>         }
>     });
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message