Class NewInsertion


public class NewInsertion extends TypedInsertion
  • Field Details

    • qualifyType

      protected boolean qualifyType
      If true, the type will be qualified with the name of the superclass.
  • Constructor Details

    • NewInsertion

      public NewInsertion(Type type, Criteria criteria, List<Insertion> innerTypeInsertions)
      Construct a NewInsertion.

      If "new" already exists in the initializer, then pass a DeclaredType thats name is the empty String. This will only insert an annotation on the existing type.

      To insert the annotation along with "new" and the type (for example, @Anno new Type[] \{...\}), set the name to the type to insert. This can be done either before calling this constructor, or by modifying the return value of TypedInsertion.getType().

      Parameters:
      type - the type to use when inserting the receiver
      criteria - where to insert the text
      innerTypeInsertions - the inner types to go on this receiver
  • Method Details

    • getText

      protected String getText(boolean abbreviate)
      Description copied from class: Insertion
      Gets the insertion text.
      Specified by:
      getText in class Insertion
      Parameters:
      abbreviate - if true, the package name will be removed from the annotations. The package name can be retrieved again by calling the Insertion.getPackageNames() method.
      Returns:
      the text to insert
    • setQualifyType

      public void setQualifyType(boolean qualifyType)
      If true, qualify type with the name of the superclass. This will only happen if a "new" is inserted.
    • addLeadingSpace

      protected boolean addLeadingSpace(boolean gotSeparateLine, int pos, char precedingChar)
      Description copied from class: Insertion
      Indicates if a preceding space should be added to this insertion. Subclasses may override this method for custom leading space rules.
      Overrides:
      addLeadingSpace in class Insertion
      Parameters:
      gotSeparateLine - true if this insertion is actually added on a separate line
      pos - the source position where this insertion will be inserted
      precedingChar - the character directly preceding where this insertion will be inserted. This value will be ignored if pos is 0.
      Returns:
      true if a leading space should be added, false otherwise
    • addTrailingSpace

      protected boolean addTrailingSpace(boolean gotSeparateLine)
      Description copied from class: Insertion
      Indicates if a trailing space should be added to this insertion. Subclasses may override this method for custom trailing space rules.
      Overrides:
      addTrailingSpace in class Insertion
      Parameters:
      gotSeparateLine - true if this insertion is actually added on a separate line
      Returns:
      true if a trailing space should be added, false otherwise
    • getKind

      public Insertion.Kind getKind()
      Description copied from class: Insertion
      Gets the kind of this insertion.
      Specified by:
      getKind in class Insertion
      Returns:
      the kind of this insertion