Package hudson.matrix

Class Axis

All Implemented Interfaces:
ExtensionPoint, Describable<Axis>, Comparable<Axis>, Iterable<String>
Direct Known Subclasses:
JDKAxis, LabelAxis, LabelExpAxis, TextAxis

public class Axis extends AbstractDescribableImpl<Axis> implements Comparable<Axis>, Iterable<String>, ExtensionPoint
Configuration axis.

This class represents a single dimension of the configuration matrix. For example, the JAX-WS RI test configuration might include one axis "container={glassfish,tomcat,jetty}" and another axis "stax={sjsxp,woodstox}", and so on.

Author:
Kohsuke Kawaguchi
  • Field Details

    • name

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public final String name
      Deprecated.
      as of 1.373 Use getName()
      Name of this axis. Used as a variable name.
    • values

      @Deprecated @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince("1.463") public final List<String> values
      Deprecated.
      as of 1.373 Use getValues()
      Possible values for this axis.
  • Constructor Details

    • Axis

      public Axis(String name, List<String> values)
    • Axis

      public Axis(String name, String... values)
    • Axis

      @DataBoundConstructor public Axis(String name, String valueString)
      Used to build Axis from form. Axis with empty values need to be removed later.
  • Method Details

    • isSystem

      @Deprecated public boolean isSystem()
      Deprecated.
      as of 1.373 System vs user difference are generalized into extension point.
      Returns true if this axis is a system-reserved axis that used to have special treatment.
    • iterator

      public Iterator<String> iterator()
      Specified by:
      iterator in interface Iterable<String>
    • size

      public int size()
    • value

      public String value(int index)
    • indexOf

      public int indexOf(String value)
      The inverse of value(int).
    • compareTo

      public int compareTo(Axis that)
      Axis is fully ordered so that we can convert between a list of axis and a string unambiguously.
      Specified by:
      compareTo in interface Comparable<Axis>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getName

      public String getName()
      Name of this axis. Used as a variable name.
    • getValues

      public List<String> getValues()
      Possible values for this axis.
    • rebuild

      public List<String> rebuild(MatrixBuild.MatrixBuildExecution context)
      Called right at the beginning of MatrixBuild execution to allow Axis to update values based on the current build.

      Historically, axes values are considered static. They were assumed to reflect what the user has typed in, and their values are changed only when the project is reconfigured. So abstractions are built around this notion, and so for example MatrixProject has the current axes and their values, which it uses to render its UI.

      So when the need was identified to change the values of axes per build, we decided that this be represented as a kind of project configuration update (where a project gets reconfigured every time a build runs), and this call back was added to allow Axis to update the next return value from the getValues() (which is typically done by updating values.)

      While it is not strictly required, because of these historical reasons, UI will look better if Future calls to getValues() return the same values as what this method returns (until the next rebuild call).

      Parameters:
      context - The ongoing build. Never null.
      Returns:
      Never null. Returns the updated set of values.
      Since:
      1.471
    • getDescriptor

      public AxisDescriptor getDescriptor()
      Specified by:
      getDescriptor in interface Describable<Axis>
      Overrides:
      getDescriptor in class AbstractDescribableImpl<Axis>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getValueString

      public String getValueString()
      Used for generating the config UI. If the axis is big and occupies a lot of space, use newline for separator to display multi-line text.
    • parsePrefixed

      public static Axis parsePrefixed(org.kohsuke.stapler.StaplerRequest2 req, String name)
      Parses the submitted form (where possible values are presented as a list of checkboxes) and creates an axis
    • readResolve

      public Object readResolve()
      Previously we used to persist Axis, but now those are divided into subtypes. So upon deserialization, resolve to the proper type.
    • all

      Returns all the registered AxisDescriptors.
    • addBuildVariable

      public void addBuildVariable(String value, Map<String,String> map)
      Converts the selected value (which is among values) and adds that to the given map, which serves as the build variables.