Class WrapIdentifier<T extends JobParameters>

All Implemented Interfaces:
Activatable, ActivatableLifecycleUser<T>, LifecycleUser<T>

public class WrapIdentifier<T extends JobParameters> extends ConfigurableTransformation<T>
The wrap identifier transformation wraps the usage of a certain identifier with new code by replacing its usage with a new expression and inserting code that takes care of handling the conversion from the new to the old value. It also checks that the wrapped value isn't already present in the code. This class uses a chaining configuration pattern. The class is constructed with an empty constructor and then configured by calling some configuration methods. Additionally, configuration values can be generated dynamically by overriding the getter methods.
  • Constructor Details

    • WrapIdentifier

      public WrapIdentifier()
  • Method Details

    • setupGraph

      protected void setupGraph()
      Setup is done here so that it can be overridden in subclasses.
      Overrides:
      setupGraph in class Transformation<T extends JobParameters>
    • getWrapResultDetector

      protected ActivatableLifecycleUser<T> getWrapResultDetector()
      Gets the value of a configuration property. This method should not be called by subclasses, only implemented in case a custom value generation is needed.
      Returns:
      The configuration property value
    • getDetectionResult

      protected String getDetectionResult()
      Gets the value of a configuration property. This method should not be called by subclasses, only implemented in case a custom value generation is needed.
      Returns:
      The configuration property value
    • getParsedReplacement

      protected String getParsedReplacement()
      Gets the value of a configuration property. This method should not be called by subclasses, only implemented in case a custom value generation is needed.
      Returns:
      The configuration property value
    • getParseMethod

      protected Function<io.github.douira.glsl_transformer.GLSLParser,ExtendedContext> getParseMethod()
      Gets the value of a configuration property. This method should not be called by subclasses, only implemented in case a custom value generation is needed.
      Returns:
      The configuration property value
    • getWrappingReplacer

      protected ActivatableLifecycleUser<T> getWrappingReplacer()
      Gets the value of a configuration property. This method should not be called by subclasses, only implemented in case a custom value generation is needed.
      Returns:
      The configuration property value
    • getWrapHandlerTargets

      protected Collection<HandlerTarget<T>> getWrapHandlerTargets()
      Gets the value of a configuration property. This method should not be called by subclasses, only implemented in case a custom value generation is needed.
      Returns:
      The configuration property value
    • getWrapTarget

      protected String getWrapTarget()
      Gets the value of a configuration property. This method should not be called by subclasses, only implemented in case a custom value generation is needed.
      Returns:
      The configuration property value
    • getInjector

      protected ActivatableLifecycleUser<T> getInjector()
      Gets the value of a configuration property. This method should not be called by subclasses, only implemented in case a custom value generation is needed.
      Returns:
      The configuration property value
    • getInjectionLocation

      protected InjectionPoint getInjectionLocation()
      Gets the value of a configuration property. This method should not be called by subclasses, only implemented in case a custom value generation is needed.
      Returns:
      The configuration property value
    • getInjectionExternalDeclaration

      protected String getInjectionExternalDeclaration()
      Gets the value of a configuration property. This method should not be called by subclasses, only implemented in case a custom value generation is needed.
      Returns:
      The configuration property value
    • wrapResultDetector

      public WrapIdentifier<T> wrapResultDetector(ActivatableLifecycleUser<T> wrapResultDetector)
      Sets the detector that will be used to check if the detection result exists already. Generated from the detection result by default.
      Parameters:
      wrapResultDetector - The result detector
      Returns:
      This object
    • detectionResult

      public WrapIdentifier<T> detectionResult(String detectionResult)
      Sets the result that will be present in the code after the wrapping. Generated from the parsed replacement by default. However, if a parsed replacement is used, the detection result should usually be set manually if the replacement isn't just a single identifier. If used without an explicit expression to insert, this must be an identifier since it's not parsed.
      Parameters:
      detectionResult - The detection result
      Returns:
      This object
    • parsedReplacement

      public WrapIdentifier<T> parsedReplacement(String parsedReplacement)
      Sets the parsed replacement that replaces the target. Has no default but is only used if a parser method is set.
      Parameters:
      parsedReplacement - The parsed replacement
      Returns:
      This object
    • parseMethod

      public WrapIdentifier<T> parseMethod(Function<io.github.douira.glsl_transformer.GLSLParser,ExtendedContext> parseMethod)
      Sets the parser method that will be used to parse the wrap expression. Is the default expression parsing method by default.
      Parameters:
      parseMethod - The replacement parsing method
      Returns:
      This object
    • wrappingReplacer

      public WrapIdentifier<T> wrappingReplacer(ActivatableLifecycleUser<T> wrappingReplacer)
      Sets the replacer that will be used to replace the target with the wrap expression.
      Parameters:
      wrappingReplacer - The replacer
      Returns:
      This object
    • wrapHandlerTargets

      public WrapIdentifier<T> wrapHandlerTargets(Collection<HandlerTarget<T>> wrapHandlerTargets)
      Sets the handler target that does the replacement of the target. Generated from the wrap target by default.
      Parameters:
      wrapHandlerTargets - The replacement target handler
      Returns:
      This object
    • wrapTarget

      public WrapIdentifier<T> wrapTarget(String wrapTarget)
      Sets the target that will be replaced.
      Parameters:
      wrapTarget - The replacement target identifier
      Returns:
      This object
    • injector

      public WrapIdentifier<T> injector(ActivatableLifecycleUser<T> injector)
      Sets the injector that will be used to inject additional code after replacement is done. Generated from the injection location and the injection external declaration by default.
      Parameters:
      injector - The injector
      Returns:
      This object
    • injectionLocation

      public WrapIdentifier<T> injectionLocation(InjectionPoint injectionLocation)
      Sets the injection location for the generated injector.
      Parameters:
      injectionLocation - The injection location
      Returns:
      This object
    • injectionExternalDeclaration

      public WrapIdentifier<T> injectionExternalDeclaration(String injectionExternalDeclaration)
      Sets the external declaration for the generated injector.
      Parameters:
      injectionExternalDeclaration - The external declaration
      Returns:
      This object
    • wrapResultDetector

      public WrapIdentifier<T> wrapResultDetector(Supplier<ActivatableLifecycleUser<T>> wrapResultDetector)
      Sets the supplier for a configuration property.
      Parameters:
      wrapResultDetector - The value supplier
      Returns:
      This object
    • detectionResult

      public WrapIdentifier<T> detectionResult(Supplier<String> detectionResult)
      Sets the supplier for a configuration property.
      Parameters:
      detectionResult - The value supplier
      Returns:
      This object
    • parsedReplacement

      public WrapIdentifier<T> parsedReplacement(Supplier<String> parsedReplacement)
      Sets the supplier for a configuration property.
      Parameters:
      parsedReplacement - The value supplier
      Returns:
      This object
    • parseMethod

      public WrapIdentifier<T> parseMethod(Supplier<Function<io.github.douira.glsl_transformer.GLSLParser,ExtendedContext>> parseMethod)
      Sets the supplier for a configuration property.
      Parameters:
      parseMethod - The value supplier
      Returns:
      This object
    • wrappingReplacer

      public WrapIdentifier<T> wrappingReplacer(Supplier<ActivatableLifecycleUser<T>> wrappingReplacer)
      Sets the supplier for a configuration property.
      Parameters:
      wrappingReplacer - The value supplier
      Returns:
      This object
    • wrapHandlerTargets

      public WrapIdentifier<T> wrapHandlerTargets(Supplier<Collection<HandlerTarget<T>>> wrapHandlerTargets)
      Sets the supplier for a configuration property.
      Parameters:
      wrapHandlerTargets - The value supplier
      Returns:
      This object
    • wrapTarget

      public WrapIdentifier<T> wrapTarget(Supplier<String> wrapTarget)
      Sets the supplier for a configuration property.
      Parameters:
      wrapTarget - The value supplier
      Returns:
      This object
    • injector

      public WrapIdentifier<T> injector(Supplier<ActivatableLifecycleUser<T>> injector)
      Sets the supplier for a configuration property.
      Parameters:
      injector - The value supplier
      Returns:
      This object
    • injectionLocation

      public WrapIdentifier<T> injectionLocation(Supplier<InjectionPoint> injectionLocation)
      Sets the supplier for a configuration property.
      Parameters:
      injectionLocation - The value supplier
      Returns:
      This object
    • injectionExternalDeclaration

      public WrapIdentifier<T> injectionExternalDeclaration(Supplier<String> injectionExternalDeclaration)
      Sets the supplier for a configuration property.
      Parameters:
      injectionExternalDeclaration - The value supplier
      Returns:
      This object
    • wrapResultDetector

      public WrapIdentifier<T> wrapResultDetector(CachePolicy newPolicy)
      Changes the cache policy of a configuration property.
      Parameters:
      newPolicy - The new cache policy
      Returns:
      This object
    • detectionResult

      public WrapIdentifier<T> detectionResult(CachePolicy newPolicy)
      Changes the cache policy of a configuration property.
      Parameters:
      newPolicy - The new cache policy
      Returns:
      This object
    • parsedReplacement

      public WrapIdentifier<T> parsedReplacement(CachePolicy newPolicy)
      Changes the cache policy of a configuration property.
      Parameters:
      newPolicy - The new cache policy
      Returns:
      This object
    • parseMethod

      public WrapIdentifier<T> parseMethod(CachePolicy newPolicy)
      Changes the cache policy of a configuration property.
      Parameters:
      newPolicy - The new cache policy
      Returns:
      This object
    • wrappingReplacer

      public WrapIdentifier<T> wrappingReplacer(CachePolicy newPolicy)
      Changes the cache policy of a configuration property.
      Parameters:
      newPolicy - The new cache policy
      Returns:
      This object
    • wrapHandlerTargets

      public WrapIdentifier<T> wrapHandlerTargets(CachePolicy newPolicy)
      Changes the cache policy of a configuration property.
      Parameters:
      newPolicy - The new cache policy
      Returns:
      This object
    • wrapTarget

      public WrapIdentifier<T> wrapTarget(CachePolicy newPolicy)
      Changes the cache policy of a configuration property.
      Parameters:
      newPolicy - The new cache policy
      Returns:
      This object
    • injector

      public WrapIdentifier<T> injector(CachePolicy newPolicy)
      Changes the cache policy of a configuration property.
      Parameters:
      newPolicy - The new cache policy
      Returns:
      This object
    • injectionLocation

      public WrapIdentifier<T> injectionLocation(CachePolicy newPolicy)
      Changes the cache policy of a configuration property.
      Parameters:
      newPolicy - The new cache policy
      Returns:
      This object
    • injectionExternalDeclaration

      public WrapIdentifier<T> injectionExternalDeclaration(CachePolicy newPolicy)
      Changes the cache policy of a configuration property.
      Parameters:
      newPolicy - The new cache policy
      Returns:
      This object
    • wrapResultDetector

      protected final ActivatableLifecycleUser<T> wrapResultDetector()
      Returns the proper value of a configuration property.
      Returns:
      The configuration property value
    • detectionResult

      protected final String detectionResult()
      Returns the proper value of a configuration property.
      Returns:
      The configuration property value
    • parsedReplacement

      protected final String parsedReplacement()
      Returns the proper value of a configuration property.
      Returns:
      The configuration property value
    • parseMethod

      protected final Function<io.github.douira.glsl_transformer.GLSLParser,ExtendedContext> parseMethod()
      Returns the proper value of a configuration property.
      Returns:
      The configuration property value
    • wrappingReplacer

      protected final ActivatableLifecycleUser<T> wrappingReplacer()
      Returns the proper value of a configuration property.
      Returns:
      The configuration property value
    • wrapHandlerTargets

      protected final Collection<HandlerTarget<T>> wrapHandlerTargets()
      Returns the proper value of a configuration property.
      Returns:
      The configuration property value
    • wrapTarget

      protected final String wrapTarget()
      Returns the proper value of a configuration property.
      Returns:
      The configuration property value
    • injector

      protected final ActivatableLifecycleUser<T> injector()
      Returns the proper value of a configuration property.
      Returns:
      The configuration property value
    • injectionLocation

      protected final InjectionPoint injectionLocation()
      Returns the proper value of a configuration property.
      Returns:
      The configuration property value
    • injectionExternalDeclaration

      protected final String injectionExternalDeclaration()
      Returns the proper value of a configuration property.
      Returns:
      The configuration property value