You can assign default values also in pure Java way. Java constructor
or better is default init block. Example:
public class A {
        // default init block
        {
                System.out.println("Default init block");
        }

        private A() {
                System.out.println("Empty constructor");
        }

        public A(String msg) {
                System.out.println("Parametrized constructor");
        }

        public static void main(String arg[]) {
                A a=new A();
                A b=new A("leco");
        }
}

Output:
Default init block
Empty constructor
Default init block
Parametrized constructor

Pavel

PS: Patrik you always surprise me how fast you can tune templates.


On Wed, Oct 28, 2009 at 8:18 AM, Patrik Nordwall
<patrik.nordw...@gmail.com> wrote:
>
> Right now it is not supported from the DSL. You can define gap and initialize
> the attributes in the constructor of the hand written subclass.
>
> You could add your own AROUND in SpecialCases.xpt. It could look something
> like this:
> SpecialCases.xpt:
> «IMPORT sculptormetamodel»
> «EXTENSION extensions::helper»
> «EXTENSION extensions::properties»
>
> «AROUND templates::DomainObject::attribute(boolean annotations) FOR
> Attribute»
>        «IF isJpaAnnotationOnFieldToBeGenerated()»
>                «IF isJpaAnnotationToBeGenerated() &&
> hasMappedSuperclass(getDomainObject()) && annotations»
>                        «EXPAND templates::DomainObject::jpaAnnotations»
>                «ENDIF»
>                «IF isValidationAnnotationToBeGenerated() && annotations»
>                        «EXPAND templates::DomainObject::validationAnnotations»
>                «ENDIF»
>        «ENDIF»
>
>    private «getTypeName()» «name» «IF hasHint("defaultValue")» =
> «getHint("defaultValue")»«ELSEIF collectionType != null» = new
> «getImplTypeName()»()«ENDIF»;
> «ENDAROUND»
>
>
> and then in the DSL you can use it like this:
>
>        Entity Planet {
>            gap
>            scaffold
>            String name key;
>            String message hint='defaultValue="Hello"';
>            Integer diameter nullable min="1" hint="defaultValue=17";
>
>
> Add a request in  http://fornax.itemis.de/jira/browse/CSC jira  if you think
> it should be supported out of the box in the DSL.
>
> /Patrik
>
>
> greatfooty wrote:
>>
>> I'm looking for ability to define default values for some attributes of
>> entities within the Sculptor DSL ( in a similar way to would be possible
>> when using UML )
>>
>> My apologies if this is documented somewhere but I've checked thru the
>> docco and can't see any mention of it
>>
>
> --
> View this message in context: 
> http://www.nabble.com/Setting-%27DefaultValue%27-in-Sculptor--tp26086945s17564p26090292.html
> Sent from the Fornax-Platform mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Fornax-developer mailing list
> Fornax-developer@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fornax-developer
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Fornax-developer mailing list
Fornax-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Reply via email to