Unnamed attribute - How to get rid of seq. number in code generation?

Hello,
Instant generator adds a sequence number to the unnamed attributes. The sequence number also appears in getters and setters. How do I get rid of this sequence number?

I have set the unnamed attribute to “${classname}” in the options for Instant Generator.
Here is a sample of the generated code…

public class RequestContext {
private LoggingContext loggingContext921;

public void setLoggingContext921(LoggingContext loggingContext921) {
this.loggingContext921 = loggingContext921;
}

public LoggingContext getLoggingContext921() {
    return this.loggingContext921;
}

}

In the above example, it added sequence number 921 to the aggregated unnamed attribute. I would prefer to name it just “loggingContext”.

Thanks
Raju

Hello Raju,

Actually having random number appended to the attribute name is to avoid multiple unnamed attributes having the same name. Your case won’t have problem because there is only one attribute. If there are more than one, you can’t have two attributes both named as loggingContext.

Best regards,
Jick

Thanks for prompt reply.

I do understand the reason behind appending a sequence number. But I do not need it and wouldn’t prefer to see the sequence numbers through out my code that use these getters and setters.

Thanks
Raju

Hi Raju,

The behavior is fine-tuned. I will provide you with more detail. Now, please download the patch first:
http://files3.visual-paradigm.com/200706/Patch/sp2_20070526n/vpplatform.jar

Description of fix:
Random number will be added to the attribute name only if needed. If the same attribute does not exist in class, it won’t add random number to the attribute name.

To install the patch:

  1. Shutdown any running instances of VP
  2. Replace $vp-suite-install-dir/lib/vpplatform.jar with the downloaded jar file
  3. Run $vp-suite-install-dir/bin/VP Suite.exe to install the patch
  4. Restart the application

Note:

  1. If you are going to download with Internet Explorer, you may need to rename the file from .zip to .jar manually
  2. Please do not run Product Update after applying the patch. Otherwise the update will replace the patch with the previous version (I will inform you to run the update when the next release is ready)

Please let me know if it works.

Best regards,
Jick Yeung

Thank you for the patch. The code looks much cleaner now :slight_smile:

That’s good. :smiley: