Class CodeSnippet

java.lang.Object
de.spraener.nxtgen.target.CodeSnippet
Direct Known Subclasses:
CodeBlockSnippet, SingleLineSnippet

public abstract class CodeSnippet extends Object
Responsibility A CodeSnippet is a atomar piece of code that can be referenced by an aspect and an optional ModelElement. It can evaluate itself into a StringBuilder. It always has an "aspect" this snippet is needed for, and it can have a ModelElement for which this Snippet is also needed.
  • Constructor Details

    • CodeSnippet

      public CodeSnippet()
    • CodeSnippet

      public CodeSnippet(Object aspect)
      Create a snippet to implement the given aspect. The ModelELement is set to null.
      Parameters:
      aspect - The aspect this snippet is needed for.
    • CodeSnippet

      public CodeSnippet(Object aspect, ModelElement me)
      Create a Snippet to implement the given aspect for the given ModelElement. For example the snippet implements the JPA-Aspect for a MAttribute.
      Parameters:
      aspect - The aspect this snippet is needed for.
      me - The ModelElement this snippet is needed for.
  • Method Details

    • evaluate

      public abstract void evaluate(StringBuilder sb)
    • matches

      public boolean matches(Object aspect, ModelElement me)
      Does this snippet match the given aspect and ModelElement? If the snippet has no ModelElement it only matches requests with ModelElement parameter is null. A null-ModelElement on a snippet does not match any ModelElement-Parameter.
      Parameters:
      aspect - The Aspect to retrieve snippets for
      me - the ModelElement to retrieve snippets for or null.
      Returns:
      TRUE if the snippet matches the given parameters
    • getAspect

      public Object getAspect()
    • getModelElement

      public ModelElement getModelElement()