Class Utils
java.lang.Object
io.github.besi97.graphql.codegen.utils.Utils
Various utilities
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.fasterxml.jackson.databind.ObjectMapper -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcamelCaseString(String stringToCamelCase) Make a string as CamelCasestatic Stringcapitalize(String stringToCapitalize) Capitalize a string.static voidcreateDirIfAbsent(File dir) Create directory if it is absent.static voidDeletes a given directory recursively.static StringgetFieldVisibility(MappingContext mappingContext) static StringgetFileContent(String filePath) Get content of the file.static booleanisBlank(CharSequence cs) Copy of org.apache.commons.lang3.StringUtils#isBlank(CharSequence)static booleanisEmpty(Collection<?> collection) Check if collection is empty.static booleanisGraphqlOperation(String typeDef) Check whether the given type definition is either Query or Mutation or Subscription.static booleanInverted copy of org.apache.commons.lang3.StringUtils.isBlank(CharSequence cs)static StringreplaceLeadingAtSign(String value) Replace leading annotation (@) signstatic booleanCheck if strings are equal (consider blank strings equal to null)static StringsubstringBetween(String str, String open, String close) Copy of org.apache.commons.lang3.StringUtils#substringBetween(String, String, String)static StringunCapitalize(String stringToUncapitalize) Un-capitalize a string.static StringwrapString(String str, String wrapWith) Wrap stringstatic StringwrapString(String str, String wrapStart, String wrapEnd) Wrap string
-
Field Details
-
OBJECT_MAPPER
public static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
-
-
Method Details
-
isGraphqlOperation
Check whether the given type definition is either Query or Mutation or Subscription.- Parameters:
typeDef- type definition name- Returns:
trueif the given type definition is GraphQL operation
-
capitalize
Capitalize a string. Make first letter as capital- Parameters:
stringToCapitalize- string to capitalize- Returns:
- capitalized string
-
camelCaseString
Make a string as CamelCase- Parameters:
stringToCamelCase- string to convert to CamelCase- Returns:
- CamelCasedString
-
unCapitalize
Un-capitalize a string. Make first letter as lowercase- Parameters:
stringToUncapitalize- string to un-capitalize- Returns:
- uncapitalized string
-
isNotBlank
Inverted copy of org.apache.commons.lang3.StringUtils.isBlank(CharSequence cs)- Parameters:
cs- the CharSequence to check, may be null- Returns:
falseif the CharSequence is null, empty or whitespace only
-
isBlank
Copy of org.apache.commons.lang3.StringUtils#isBlank(CharSequence)- Parameters:
cs- the CharSequence to check, may be null- Returns:
trueif the CharSequence is null, empty or whitespace only
-
stringsEqualIgnoreSpaces
Check if strings are equal (consider blank strings equal to null)- Parameters:
a- a stringb- a string to be compared witha- Returns:
trueif strings are equal
-
getFileContent
Get content of the file.- Parameters:
filePath- path of the file.- Returns:
- content of the file.
- Throws:
IOException- unable to read the file.
-
deleteDir
Deletes a given directory recursively.- Parameters:
dir- directory to delete- Throws:
UnableToDeleteDirectoryException- if unable to delete a directory
-
createDirIfAbsent
Create directory if it is absent. Will do nothing if it is already present.- Parameters:
dir- to create if it is absent.- Throws:
UnableToCreateDirectoryException- if unable to create a directory
-
isEmpty
Check if collection is empty.- Parameters:
collection- that will be checked for emptiness- Returns:
- true if collection is null or empty
-
replaceLeadingAtSign
Replace leading annotation (@) sign- Parameters:
value- annotation value with/without @ sign- Returns:
- value without leading @ sign
-
substringBetween
Copy of org.apache.commons.lang3.StringUtils#substringBetween(String, String, String)Gets the String that is nested in between two Strings. Only the first match is returned.
- Parameters:
str- the String containing the substring, may be nullopen- the String before the substring, may be nullclose- the String after the substring, may be null- Returns:
- the substring,
nullif no match
-
wrapString
Wrap string- Parameters:
str- the StringwrapWith- String to be appended to the beginning and the end of str- Returns:
- string
-
wrapString
Wrap string- Parameters:
str- the StringwrapStart- String to be appended to the beginning of strwrapEnd- String to be appended to the end of str- Returns:
- wrapped string
-
getFieldVisibility
-