Record Class GenerationPolicy

java.lang.Object
java.lang.Record
org.ek9lang.compiler.fuzz.GenerationPolicy

record GenerationPolicy(String name, int[] constructWeights, int maxNestingDepth) extends Record
Named generation policy that biases construct selection and exploration depth. Policies rotate periodically to systematically cover different grammar regions and break ATN saturation from uniform random distribution.

Each policy defines 19 weights corresponding to the 19 construct cases in AtnBasedGenerator.appendRandomConstruct(): 0=class, 1=function, 2=record, 3=constant, 4=program, 5=trait, 6=component, 7=application, 8=text, 9=package, 10=enumeration, 11=constrained-type, 12=trait-impl, 13=generic-type, 14=class-hierarchy, 15=service, 16=dispatcher, 17=dynamic-function, 18=dynamic-class.

  • Constructor Details

    • GenerationPolicy

      GenerationPolicy(String name, int[] constructWeights, int maxNestingDepth)
      Creates an instance of a GenerationPolicy record class.
      Parameters:
      name - the value for the name record component
      constructWeights - the value for the constructWeights record component
      maxNestingDepth - the value for the maxNestingDepth record component
  • Method Details

    • equals

      public boolean equals(Object other)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      other - the object with which to compare
      Returns:
      true if this object is the same as the other argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • balanced

      static GenerationPolicy balanced()
      Balanced: uniform weights (reproduces original behavior).
    • hierarchyHeavy

      static GenerationPolicy hierarchyHeavy()
      Hierarchy-heavy: favors class, trait, class-hierarchy, trait-impl.
    • genericsHeavy

      static GenerationPolicy genericsHeavy()
      Generics-heavy: favors generic-type, function, constrained-type.
    • serviceHeavy

      static GenerationPolicy serviceHeavy()
      Service-heavy: favors service, application, component.
    • controlFlowHeavy

      static GenerationPolicy controlFlowHeavy()
      Control-flow-heavy: deeper nesting, more functions and programs.
    • errorHeavy

      static GenerationPolicy errorHeavy()
      Error-heavy: favors dispatcher, constrained-type, dynamic constructs for more errors.
    • selectConstruct

      int selectConstruct(Random random)
      Select a construct case using weighted random distribution.
      Returns:
      index 0-18 corresponding to a construct case
    • forIteration

      static GenerationPolicy forIteration(long iteration)
      Get the appropriate policy for a given iteration count. Rotates through all policies every ROTATION_INTERVAL iterations.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • constructWeights

      public int[] constructWeights()
      Returns the value of the constructWeights record component.
      Returns:
      the value of the constructWeights record component
    • maxNestingDepth

      public int maxNestingDepth()
      Returns the value of the maxNestingDepth record component.
      Returns:
      the value of the maxNestingDepth record component