Class GoodGrandchild
java.lang.Object
com.github.rvesse.airline.examples.inheritance.Parent
com.github.rvesse.airline.examples.inheritance.Child
com.github.rvesse.airline.examples.inheritance.GoodGrandchild
- All Implemented Interfaces:
ExampleRunnable
@Command(name="good-grandchild",
description="A legal command which overrides an option defined by a parent")
public class GoodGrandchild
extends Child
When inheriting from existing classes it is possible to override previously
defined options but only if you are explicit about it. In this case Airline
uses the bottom-most definition of the option as the effective definition
Note that any values set for options are propagated to all declarations in the inheritance tree since an ancestor class will not have access to fields set in the descendants.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
We can override the definition of an existing option under certain conditions:arity
,name
andoptionType
are unchanged Type is same or a valid narrowing conversion exists from the inherited option type to the overridden type You explicitly declareoverride
to betrue
and the inherited option does not definesealed
to betrue
-
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
parent
@Option(name="--parent", description="An option can be overridden if we are explicit about it", override=true) private boolean parentWe can override the definition of an existing option under certain conditions:arity
,name
andoptionType
are unchanged- Type is same or a valid narrowing conversion exists from the inherited option type to the overridden type
- You explicitly declare
override
to betrue
and the inherited option does not definesealed
to betrue
In practise this means you can change some informative properties of the option such as the title and description. You can also choose to make it visible/hidden and required/not required as desired.
Note that often if you find yourself needing to override options frequently then this can be indicative of poorly thought out option inheritance in which case using modules may be a better option. See
Modules
for an example of this.
-
-
Constructor Details
-
GoodGrandchild
public GoodGrandchild()
-
-
Method Details
-
main
-