Class OpenOp

All Implemented Interfaces:
Op

@Immutable public abstract class OpenOp extends HasUniqueId implements Op
An OpenOp opens a level. It is an Op in the sequence of Ops generated by OpsBuilder. When the sequence is turned into a Doc by DocBuilder, Input.Toks delimited by OpenOp-CloseOp pairs turn into nested Levels.
  • Constructor Details

    • OpenOp

      public OpenOp()
  • Method Details

    • plusIndent

      public abstract Indent plusIndent()
      The extra indent inside this level.
    • breakBehaviour

      @Default public BreakBehaviour breakBehaviour()
      When this level doesn't fit on one line, controls whether this level is to be broken (its breaks taken) or partially inlined onto the current line.
    • breakabilityIfLastLevel

      @Default public LastLevelBreakability breakabilityIfLastLevel()
      If it's the last level of its parent, when to inline this level rather than break the parent.
    • partialInlineability

      @Default public PartialInlineability partialInlineability()
    • complexity

      @Default public OpenOp.Complexity complexity()
      A level is "simple" if it doesn't have multiple parameters (in the case of a method call), or multiple chained method calls.

      This is used to poison the ability to partially inline method arguments down the line if a parent level was too complicated, so that you can't end up with this:

       method(arg1, arg2, arg3.foo().stream()
               .filter(...)
               .map(...));
       
      or
       log.info("Message", exception, SafeArg.of(
               "foo", foo);
       
      But you can still get this (see test B20128760):
       Stream itemIdsStream = stream(members).flatMap(m -> m.getFieldValues().entrySet().stream()
               .filter(...)
               .map(...));
       
      or this:
       method(anotherMethod(arg3.foo().stream()
               .filter(...)
               .map(...)));
       
      or this:
       method(anotherMethod(
               ...)); // long arguments
       
    • debugName

      public abstract Optional<String> debugName()
    • columnLimitBeforeLastBreak

      public abstract OptionalInt columnLimitBeforeLastBreak()
      Custom max column limit that contents of this level before the last break may not exceed.
    • make

      public static Op make(Indent plusIndent)
      Make an ordinary OpenOp.
      See Also:
    • add

      public void add(DocBuilder builder)
      Description copied from interface: Op
      Add an Op to a DocBuilder.
      Specified by:
      add in interface Op
      Parameters:
      builder - the DocBuilder
    • builder

      public static OpenOp.Builder builder()
      See Also:
      • Builder()