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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Collection<String>The current list of detection results to use if the getter method for the detection result configuration property is not set differently.protected Collection<String>The current list of injection external declarations to use if the getter method for the external declarations configuration property is not set differently. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionactivation(Supplier<Boolean> activation)Overwrite to make type more specificvoidaddDetectionResult(String detectionResult)Adds a detection result to the list of static detection result to use.voidaddExternalDeclaration(String externalDeclaration)Adds an external declaration to the list of external declarations to use.protected StringReturns the proper value of a configuration property.detectionResult(String detectionResult)Sets a single detection result.protected Collection<String>Returns the proper value of a configuration property.detectionResults(CachePolicy newPolicy)Changes the cache policy of a configuration property.detectionResults(Collection<String> detectionResults)Sets the result that will be present in the code after the wrapping.detectionResults(Supplier<Collection<String>> detectionResults)Sets the supplier for a configuration property.protected Collection<String>Gets the value of a configuration property.protected Collection<String>Gets 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.injectionExternalDeclaration(String injectionExternalDeclaration)Sets a single external declaration for the generated injector.protected Collection<String>Returns the proper value of a configuration property.injectionExternalDeclarations(CachePolicy newPolicy)Changes the cache policy of a configuration property.injectionExternalDeclarations(Collection<String> injectionExternalDeclarations)Sets the external declarations for the generated injector.injectionExternalDeclarations(Supplier<Collection<String>> injectionExternalDeclarations)Sets the supplier for a configuration property.protected 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 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 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 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 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 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 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 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
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
-
Field Details
-
detectionResultsDirect
The current list of detection results to use if the getter method for the detection result configuration property is not set differently. Items are added to this list with theaddDetectionResult(String)method. -
externalDeclarationsDirect
The current list of injection external declarations to use if the getter method for the external declarations configuration property is not set differently. Items are added to this list with theaddExternalDeclaration(String)
-
-
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>
-
activation
Overwrite to make type more specific- Specified by:
activationin interfaceActivatable- Specified by:
activationin interfaceActivatableLifecycleUser<T extends JobParameters>- Overrides:
activationin classLifecycleUserImpl<T extends JobParameters>- Parameters:
activation- The activation supplier- Returns:
- This object
-
addDetectionResult
Adds a detection result to the list of static detection result to use. This constitutes the default behavior ofgetDetectionResults().- Parameters:
detectionResult- The detection result to add
-
addExternalDeclaration
Adds an external declaration to the list of external declarations to use. This constitutes the default behavior ofgetInjectionExternalDeclarations().- Parameters:
externalDeclaration- The external declaration to add
-
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. This method can deal with a list of detection results that is longer than one item. It can even handle this list's contents or identity changing, but it doesn't handle the list getting longer and added items will be ignored. If the list gets shorter, the generated wrap throw targets will become no-ops but still exist.- Returns:
- The configuration property value
-
getDetectionResults
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
-
getInjectionExternalDeclarations
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
-
detectionResults
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:
detectionResults- The detection results- Returns:
- This object
-
detectionResult
Sets a single detection result. Other detection results will be ignored.- Parameters:
detectionResult- The detection result- Returns:
- This object
- See Also:
detectionResults(Collection)
-
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
-
injectionExternalDeclarations
public WrapIdentifier<T> injectionExternalDeclarations(Collection<String> injectionExternalDeclarations)Sets the external declarations for the generated injector.- Parameters:
injectionExternalDeclarations- The external declarations- Returns:
- This object
-
injectionExternalDeclaration
Sets a single external declaration for the generated injector. No other external declarations will be considered.- 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
-
detectionResults
Sets the supplier for a configuration property.- Parameters:
detectionResults- 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
-
injectionExternalDeclarations
public WrapIdentifier<T> injectionExternalDeclarations(Supplier<Collection<String>> injectionExternalDeclarations)Sets the supplier for a configuration property.- Parameters:
injectionExternalDeclarations- The value supplier- Returns:
- This object
-
wrapResultDetector
Changes the cache policy of a configuration property.- Parameters:
newPolicy- The new cache policy- Returns:
- This object
-
detectionResults
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
-
injectionExternalDeclarations
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
-
detectionResults
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
-
injectionExternalDeclarations
Returns the proper value of a configuration property.- Returns:
- The configuration property value
-