Package com.sap.cds.maven.plugin.util
Class AppYamlUtils
java.lang.Object
com.sap.cds.maven.plugin.util.AppYamlUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic int[]findBoundaries(String appYaml, int startIndex) Finds the boundaries of a document (spring profile) within an application.yaml.findProfile(String appYaml, String profile) Returns the content and the position of a profile in an application.yaml.static StringmergeProfiles(String existingProfile, String newProfile, List<String> toBeRemoved) Merges an existing profile with a new profile.static PropertiesparseYamlProperties(String profile) Parses the given profile into flattenedproperties.static StringreplaceProfile(String yamlContent, int[] boundaries, String newProfile) static void
-
Method Details
-
findBoundaries
Finds the boundaries of a document (spring profile) within an application.yaml.- Parameters:
appYaml- the whole application.yaml contentstartIndex- the start position for the search, has to be inside the document for which the boundaries are identified- Returns:
- an array with begin and end position of the document
-
findProfile
public static Optional<org.apache.commons.lang3.tuple.Pair<String,int[]>> findProfile(String appYaml, String profile) Returns the content and the position of a profile in an application.yaml.- Parameters:
appYaml- the whole application.yaml contentprofile- the profile name- Returns:
- an
Optionalcontaining the profile content and position within in the application.yaml
-
mergeProfiles
public static String mergeProfiles(String existingProfile, String newProfile, List<String> toBeRemoved) Merges an existing profile with a new profile. A merge includes the following steps:- Parse existing and new profile into
properties - Remove conflicting properties (provided in the
toBeRemovedlist) from the existing properties - Set new properties and overwrite existing ones
- Dump the properties in yaml format into a string
- Parameters:
existingProfile- the existing profilenewProfile- the new profile contenttoBeRemoved- a list with properties to be removed- Returns:
- the enhanced profile content
- Parse existing and new profile into
-
replaceProfile
-
writeDeep
-
parseYamlProperties
Parses the given profile into flattenedproperties.- Parameters:
profile- content of a single profile- Returns:
- the flattened
propertiesof the profile
-