Class ImmutableProgram

java.lang.Object
net.bmahe.genetics4j.gpu.spec.Program
net.bmahe.genetics4j.gpu.spec.ImmutableProgram

@Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableProgram extends Program
Immutable implementation of Program.

Use the builder to create immutable instances: ImmutableProgram.builder(). Use the static factory method to create immutable instances: ImmutableProgram.of().

  • Field Details

    • content

      private final List<String> content
    • resources

      private final Set<String> resources
    • kernelNames

      private final Set<String> kernelNames
    • buildOptions

      private final String buildOptions
  • Constructor Details

  • Method Details

    • content

      public List<String> content()
      Returns the direct OpenCL source code content as strings.

      Content represents OpenCL C source code provided directly as strings rather than loaded from resources. Multiple content strings are concatenated during compilation to form a single compilation unit.

      Specified by:
      content in class Program
      Returns:
      list of OpenCL source code strings
    • resources

      public Set<String> resources()
      Returns the classpath resource paths containing OpenCL source code.

      Resources are loaded from the classpath at compilation time and concatenated with any direct content to form the complete program source. Resource paths should be relative to the classpath root.

      Specified by:
      resources in class Program
      Returns:
      set of classpath resource paths for OpenCL source files
    • kernelNames

      public Set<String> kernelNames()
      Returns the names of kernels to be extracted from the compiled program.

      Kernel names specify which functions in the OpenCL source should be made available as executable kernels. These names must correspond to functions declared with the __kernel qualifier in the source code.

      Specified by:
      kernelNames in class Program
      Returns:
      set of kernel function names to extract after compilation
    • buildOptions

      public Optional<String> buildOptions()
      Returns the OpenCL compiler build options for program compilation.

      Build options are passed to the OpenCL compiler to control optimization, define preprocessor macros, and configure compilation behavior. Common options include optimization levels, math optimizations, and macro definitions.

      Specified by:
      buildOptions in class Program
      Returns:
      optional build options string for OpenCL compilation
    • withContent

      public final ImmutableProgram withContent(String... elements)
      Copy the current immutable object with elements that replace the content of content.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withContent

      public final ImmutableProgram withContent(Iterable<String> elements)
      Copy the current immutable object with elements that replace the content of content. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of content elements to set
      Returns:
      A modified copy of this object
    • withResources

      public final ImmutableProgram withResources(String... elements)
      Copy the current immutable object with elements that replace the content of resources.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withResources

      public final ImmutableProgram withResources(Iterable<String> elements)
      Copy the current immutable object with elements that replace the content of resources. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of resources elements to set
      Returns:
      A modified copy of this object
    • withKernelNames

      public final ImmutableProgram withKernelNames(String... elements)
      Copy the current immutable object with elements that replace the content of kernelNames.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withKernelNames

      public final ImmutableProgram withKernelNames(Iterable<String> elements)
      Copy the current immutable object with elements that replace the content of kernelNames. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of kernelNames elements to set
      Returns:
      A modified copy of this object
    • withBuildOptions

      public final ImmutableProgram withBuildOptions(String value)
      Copy the current immutable object by setting a present value for the optional buildOptions attribute.
      Parameters:
      value - The value for buildOptions
      Returns:
      A modified copy of this object
    • withBuildOptions

      public final ImmutableProgram withBuildOptions(Optional<String> optional)
      Copy the current immutable object by setting an optional value for the buildOptions attribute. An equality check is used on inner nullable value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for buildOptions
      Returns:
      A modified copy of this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableProgram that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • equalTo

      private boolean equalTo(int synthetic, ImmutableProgram another)
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: content, resources, kernelNames, buildOptions.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value Program with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • of

      public static ImmutableProgram of(List<String> content, Set<String> resources, Set<String> kernelNames)
      Construct a new immutable Program instance.
      Parameters:
      content - The value for the content attribute
      resources - The value for the resources attribute
      kernelNames - The value for the kernelNames attribute
      Returns:
      An immutable Program instance
    • of

      public static ImmutableProgram of(Iterable<String> content, Iterable<String> resources, Iterable<String> kernelNames)
      Construct a new immutable Program instance.
      Parameters:
      content - The value for the content attribute
      resources - The value for the resources attribute
      kernelNames - The value for the kernelNames attribute
      Returns:
      An immutable Program instance
    • validate

      private static ImmutableProgram validate(ImmutableProgram instance)
    • copyOf

      public static ImmutableProgram copyOf(Program instance)
      Creates an immutable copy of a Program value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable Program instance
    • builder

      public static ImmutableProgram.Builder builder()
      Creates a builder for ImmutableProgram.
       ImmutableProgram.builder()
          .addContent|addAllContent(String) // content elements
          .addResources|addAllResources(String) // resources elements
          .addKernelNames|addAllKernelNames(String) // kernelNames elements
          .buildOptions(String) // optional buildOptions
          .build();
       
      Returns:
      A new ImmutableProgram builder
    • createSafeList

      private static <T> List<T> createSafeList(Iterable<? extends T> iterable, boolean checkNulls, boolean skipNulls)
    • createUnmodifiableList

      private static <T> List<T> createUnmodifiableList(boolean clone, List<T> list)
    • createUnmodifiableSet

      private static <T> Set<T> createUnmodifiableSet(List<T> list)
      Unmodifiable set constructed from list to avoid rehashing.