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

    Fields
    Modifier and Type
    Field
    Description
    private boolean
    We can override the definition of an existing option under certain conditions: arity, name and optionType 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 be true and the inherited option does not define sealed to be true

    Fields inherited from class com.github.rvesse.airline.examples.inheritance.Parent

    help
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    main(String[] args)
     

    Methods inherited from class com.github.rvesse.airline.examples.inheritance.Child

    run

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • parent

      @Option(name="--parent", description="An option can be overridden if we are explicit about it", override=true) private boolean parent
      We can override the definition of an existing option under certain conditions:
      • arity, name and optionType 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 be true and the inherited option does not define sealed to be true

      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

      public static void main(String[] args)