daria-malkova commented on a change in pull request #16172:
URL: https://github.com/apache/beam/pull/16172#discussion_r766656165



##########
File path: playground/backend/internal/preparators/java_preparators.go
##########
@@ -37,15 +39,55 @@ const (
 
 // GetJavaPreparators returns preparation methods that should be applied to 
Java code
 func GetJavaPreparators(filePath string) *[]Preparator {
-       publicClassModification := Preparator{
-               Prepare: replace,
+       removePublicClassPreparator := Preparator{
+               Prepare: removePublicClass,
                Args:    []interface{}{filePath, 
classWithPublicModifierPattern, classWithoutPublicModifierPattern},
        }
-       additionalPackage := Preparator{
-               Prepare: replace,
+       changePackagePreparator := Preparator{
+               Prepare: changePackage,
                Args:    []interface{}{filePath, packagePattern, 
importStringPattern},
        }
-       return &[]Preparator{publicClassModification, additionalPackage}
+       removePackagePreparator := Preparator{
+               Prepare: removePackage,
+               Args:    []interface{}{filePath, packagePattern, 
newLinePattern},
+       }
+       return &[]Preparator{removePublicClassPreparator, 
changePackagePreparator, removePackagePreparator}
+}
+
+//removePublicClass changes the 'public class' in the code to 'class'
+func removePublicClass(args ...interface{}) error {
+       err := replace(args...)
+       if err != nil {
+               return err
+       }
+       return nil
+}
+
+//changePackage changes the 'package' to 'import' and the last directory in 
the package value to '*'
+func changePackage(args ...interface{}) error {
+       valRes := args[3].(*sync.Map)
+       isKata, ok := valRes.Load(validators.KatasValidatorName)
+       if ok && isKata.(bool) {
+               return nil
+       }
+       err := replace(args...)
+       if err != nil {
+               return err
+       }
+       return nil

Review comment:
       Yes, this functions are wrappers on _replace_ method




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to