Is multiple level inheritence supported (properly?)

35 views
Skip to first unread message

Olivier Bourdon

unread,
Aug 29, 2012, 6:42:32 AM8/29/12
to jewe...@googlegroups.com
Hello everyone

let's assume I have the following options hierarchy:

public interface UserOSAddOptions extends UserOSBaseOptions {}

public interface UserOSBaseOptions extends UserOrgBaseOptions {
@CliMandatory
@Option(
longName = "os",
description = "operating system(s) list to enable access (can be regexps
like '.*') separated by spaces"
)
List<String> getOs();
boolean isOs();
}

public interface UserOrgBaseOptions extends UserBaseOptions {
@CliOptional
@Option(
longName = "org",
description = "the organization where the user is/will be a member. If
no organization is provided, then the "
+ "default organization is used."
)
String getOrg();
boolean isOrg();
}

and finally

public interface UserBaseOptions extends BaseOptions {
@CliMandatory
@Option(
longName = "account",
description = "user name of the account for which the current command
should be executed"
)
String getAccount();
boolean isAccount();
}

public interface BaseOptions {

@Option(
longName = "version",
description = "show program's version and exit"
)
boolean isVersion();
...
}

will this work ?

Tim Wood

unread,
Aug 29, 2012, 8:45:41 AM8/29/12
to jewe...@googlegroups.com
Hi,

The intention is that it should work. Are you seeing a problem?

I am not sure I understand what "@CliMandatory" and "@CliOptional" are
for. You should be able to make an option mandatory simply by omitting
the corresponding "is" method.

Cheers,

Tim
> --
> You received this message because you are subscribed to the Google Groups
> "jewelcli" group.
> To post to this group, send email to jewe...@googlegroups.com.
> To unsubscribe from this group, send email to
> jewelcli+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/jewelcli?hl=en.
>

Olivier Bourdon

unread,
Aug 29, 2012, 8:59:45 AM8/29/12
to jewe...@googlegroups.com, Tim Wood
Thanks for the insights indeed removing some of the isXXX() methods did
the work.

FYI I had defined some annotations as follows

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CliOptional {
}

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CliMandatory {
}

so that I can do some clever coding distinguishing between optional and
mandatory arguments as I did not know how to achieve this directly from
the JewelCLI library. May be this could be good for the future (if not
already there of course)

Thanks again for your time and help

Best regards
Olivier
Reply all
Reply to author
Forward
0 new messages