Class WrapIdentifier<T extends JobParameters>
java.lang.Object
io.github.douira.glsl_transformer.transform.LifecycleUserImpl<T>
io.github.douira.glsl_transformer.transform.Transformation<T>
io.github.douira.glsl_transformer.core.ConfigurableTransformation<T>
io.github.douira.glsl_transformer.core.WrapIdentifier<T>
- All Implemented Interfaces:
Activatable,ActivatableLifecycleUser<T>,LifecycleUser<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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final StringReturns the proper value of a configuration property.detectionResult(CachePolicy newPolicy) Changes the cache policy of a configuration property.detectionResult(String detectionResult) Sets the result that will be present in the code after the wrapping.detectionResult(Supplier<String> detectionResult) Sets the supplier for a configuration property.protected StringGets the value of a configuration property.protected StringGets the value of a configuration property.protected InjectionPointGets the value of a configuration property.protected ActivatableLifecycleUser<T>Gets the value of a configuration property.protected StringGets the value of a configuration property.protected Function<io.github.douira.glsl_transformer.GLSLParser,ExtendedContext> Gets the value of a configuration property.protected Collection<HandlerTarget<T>>Gets the value of a configuration property.protected ActivatableLifecycleUser<T>Gets the value of a configuration property.protected ActivatableLifecycleUser<T>Gets the value of a configuration property.protected StringGets the value of a configuration property.protected final StringReturns the proper value of a configuration property.injectionExternalDeclaration(CachePolicy newPolicy) Changes the cache policy of a configuration property.injectionExternalDeclaration(String injectionExternalDeclaration) Sets the external declaration for the generated injector.injectionExternalDeclaration(Supplier<String> injectionExternalDeclaration) Sets the supplier for a configuration property.protected final InjectionPointReturns the proper value of a configuration property.injectionLocation(CachePolicy newPolicy) Changes the cache policy of a configuration property.injectionLocation(InjectionPoint injectionLocation) Sets the injection location for the generated injector.injectionLocation(Supplier<InjectionPoint> injectionLocation) Sets the supplier for a configuration property.protected final ActivatableLifecycleUser<T>injector()Returns the proper value of a configuration property.injector(CachePolicy newPolicy) Changes the cache policy of a configuration property.injector(ActivatableLifecycleUser<T> injector) Sets the injector that will be used to inject additional code after replacement is done.injector(Supplier<ActivatableLifecycleUser<T>> injector) Sets the supplier for a configuration property.protected final StringReturns the proper value of a configuration property.parsedReplacement(CachePolicy newPolicy) Changes the cache policy of a configuration property.parsedReplacement(String parsedReplacement) Sets the parsed replacement that replaces the target.parsedReplacement(Supplier<String> parsedReplacement) Sets the supplier for a configuration property.protected final Function<io.github.douira.glsl_transformer.GLSLParser,ExtendedContext> Returns the proper value of a configuration property.parseMethod(CachePolicy newPolicy) Changes the cache policy of a configuration property.parseMethod(Function<io.github.douira.glsl_transformer.GLSLParser, ExtendedContext> parseMethod) Sets the parser method that will be used to parse the wrap expression.parseMethod(Supplier<Function<io.github.douira.glsl_transformer.GLSLParser, ExtendedContext>> parseMethod) Sets the supplier for a configuration property.protected voidSetup is done here so that it can be overridden in subclasses.protected final Collection<HandlerTarget<T>>Returns the proper value of a configuration property.wrapHandlerTargets(CachePolicy newPolicy) Changes the cache policy of a configuration property.wrapHandlerTargets(Collection<HandlerTarget<T>> wrapHandlerTargets) Sets the handler target that does the replacement of the target.wrapHandlerTargets(Supplier<Collection<HandlerTarget<T>>> wrapHandlerTargets) Sets the supplier for a configuration property.protected final ActivatableLifecycleUser<T>Returns the proper value of a configuration property.wrappingReplacer(CachePolicy newPolicy) Changes the cache policy of a configuration property.wrappingReplacer(ActivatableLifecycleUser<T> wrappingReplacer) Sets the replacer that will be used to replace the target with the wrap expression.wrappingReplacer(Supplier<ActivatableLifecycleUser<T>> wrappingReplacer) Sets the supplier for a configuration property.protected final ActivatableLifecycleUser<T>Returns the proper value of a configuration property.wrapResultDetector(CachePolicy newPolicy) Changes the cache policy of a configuration property.wrapResultDetector(ActivatableLifecycleUser<T> wrapResultDetector) Sets the detector that will be used to check if the detection result exists already.wrapResultDetector(Supplier<ActivatableLifecycleUser<T>> wrapResultDetector) Sets the supplier for a configuration property.protected final StringReturns the proper value of a configuration property.wrapTarget(CachePolicy newPolicy) Changes the cache policy of a configuration property.wrapTarget(String wrapTarget) Sets the target that will be replaced.wrapTarget(Supplier<String> wrapTarget) Sets the supplier for a configuration property.Methods inherited from class io.github.douira.glsl_transformer.core.ConfigurableTransformation
addSupplier, cachingSupplier, once, removeSupplier, swapPolicy, swapSupplier, swapSupplier, triggerJobInternal, valueMethods inherited from class io.github.douira.glsl_transformer.transform.Transformation
addDependency, addDependent, addEndDependent, addRootDependency, appendDependent, chainConcurrentDependency, chainConcurrentDependent, chainConcurrentSibling, chainDependency, chainDependent, prependDependency, repeat, repeatParallel, repeatSequentialMethods inherited from class io.github.douira.glsl_transformer.transform.LifecycleUserImpl
activation, getPlanner, isActive, isInitialized, setInitialized, setPlannerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.douira.glsl_transformer.transform.LifecycleUser
getJobParameters, getLexer, getParser, getRootNode, init, initOnce, resetState
-
Constructor Details
-
WrapIdentifier
public WrapIdentifier()
-
-
Method Details
-
setupGraph
protected void setupGraph()Setup is done here so that it can be overridden in subclasses.- Overrides:
setupGraphin classTransformation<T extends JobParameters>
-
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
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
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
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
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
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
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
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
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
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
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
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
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
Sets the replacer that will be used to replace the target with the wrap expression.- Parameters:
wrappingReplacer- The replacer- Returns:
- This object
-
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
Sets the target that will be replaced.- Parameters:
wrapTarget- The replacement target identifier- Returns:
- This object
-
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
Sets the injection location for the generated injector.- Parameters:
injectionLocation- The injection location- Returns:
- This object
-
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
Sets the supplier for a configuration property.- Parameters:
detectionResult- The value supplier- Returns:
- This object
-
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
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
Sets the supplier for a configuration property.- Parameters:
wrapTarget- The value supplier- Returns:
- This object
-
injector
Sets the supplier for a configuration property.- Parameters:
injector- The value supplier- Returns:
- This object
-
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
Changes the cache policy of a configuration property.- Parameters:
newPolicy- The new cache policy- Returns:
- This object
-
detectionResult
Changes the cache policy of a configuration property.- Parameters:
newPolicy- The new cache policy- Returns:
- This object
-
parsedReplacement
Changes the cache policy of a configuration property.- Parameters:
newPolicy- The new cache policy- Returns:
- This object
-
parseMethod
Changes the cache policy of a configuration property.- Parameters:
newPolicy- The new cache policy- Returns:
- This object
-
wrappingReplacer
Changes the cache policy of a configuration property.- Parameters:
newPolicy- The new cache policy- Returns:
- This object
-
wrapHandlerTargets
Changes the cache policy of a configuration property.- Parameters:
newPolicy- The new cache policy- Returns:
- This object
-
wrapTarget
Changes the cache policy of a configuration property.- Parameters:
newPolicy- The new cache policy- Returns:
- This object
-
injector
Changes the cache policy of a configuration property.- Parameters:
newPolicy- The new cache policy- Returns:
- This object
-
injectionLocation
Changes the cache policy of a configuration property.- Parameters:
newPolicy- The new cache policy- Returns:
- This object
-
injectionExternalDeclaration
Changes the cache policy of a configuration property.- Parameters:
newPolicy- The new cache policy- Returns:
- This object
-
wrapResultDetector
Returns the proper value of a configuration property.- Returns:
- The configuration property value
-
detectionResult
Returns the proper value of a configuration property.- Returns:
- The configuration property value
-
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
Returns the proper value of a configuration property.- Returns:
- The configuration property value
-
wrapHandlerTargets
Returns the proper value of a configuration property.- Returns:
- The configuration property value
-
wrapTarget
Returns the proper value of a configuration property.- Returns:
- The configuration property value
-
injector
Returns the proper value of a configuration property.- Returns:
- The configuration property value
-
injectionLocation
Returns the proper value of a configuration property.- Returns:
- The configuration property value
-
injectionExternalDeclaration
Returns the proper value of a configuration property.- Returns:
- The configuration property value
-