java.lang.Object
io.github.besi97.graphql.codegen.utils.Utils

public final class Utils extends Object
Various utilities
  • Field Details

    • OBJECT_MAPPER

      public static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
  • Method Details

    • isGraphqlOperation

      public static boolean isGraphqlOperation(String typeDef)
      Check whether the given type definition is either Query or Mutation or Subscription.
      Parameters:
      typeDef - type definition name
      Returns:
      true if the given type definition is GraphQL operation
    • capitalize

      public static String capitalize(String stringToCapitalize)
      Capitalize a string. Make first letter as capital
      Parameters:
      stringToCapitalize - string to capitalize
      Returns:
      capitalized string
    • camelCaseString

      public static String camelCaseString(String stringToCamelCase)
      Make a string as CamelCase
      Parameters:
      stringToCamelCase - string to convert to CamelCase
      Returns:
      CamelCasedString
    • unCapitalize

      public static String unCapitalize(String stringToUncapitalize)
      Un-capitalize a string. Make first letter as lowercase
      Parameters:
      stringToUncapitalize - string to un-capitalize
      Returns:
      uncapitalized string
    • isNotBlank

      public static boolean isNotBlank(CharSequence cs)
      Inverted copy of org.apache.commons.lang3.StringUtils.isBlank(CharSequence cs)
      Parameters:
      cs - the CharSequence to check, may be null
      Returns:
      false if the CharSequence is null, empty or whitespace only
    • isBlank

      public static boolean isBlank(CharSequence cs)
      Copy of org.apache.commons.lang3.StringUtils#isBlank(CharSequence)
      Parameters:
      cs - the CharSequence to check, may be null
      Returns:
      true if the CharSequence is null, empty or whitespace only
    • stringsEqualIgnoreSpaces

      public static boolean stringsEqualIgnoreSpaces(String a, String b)
      Check if strings are equal (consider blank strings equal to null)
      Parameters:
      a - a string
      b - a string to be compared with a
      Returns:
      true if strings are equal
    • getFileContent

      public static String getFileContent(String filePath) throws IOException
      Get content of the file.
      Parameters:
      filePath - path of the file.
      Returns:
      content of the file.
      Throws:
      IOException - unable to read the file.
    • deleteDir

      public static void deleteDir(File dir)
      Deletes a given directory recursively.
      Parameters:
      dir - directory to delete
      Throws:
      UnableToDeleteDirectoryException - if unable to delete a directory
    • createDirIfAbsent

      public static void createDirIfAbsent(File dir)
      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

      public static boolean isEmpty(Collection<?> collection)
      Check if collection is empty.
      Parameters:
      collection - that will be checked for emptiness
      Returns:
      true if collection is null or empty
    • replaceLeadingAtSign

      public static String replaceLeadingAtSign(String value)
      Replace leading annotation (@) sign
      Parameters:
      value - annotation value with/without @ sign
      Returns:
      value without leading @ sign
    • substringBetween

      public static String substringBetween(String str, String open, String close)
      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 null
      open - the String before the substring, may be null
      close - the String after the substring, may be null
      Returns:
      the substring, null if no match
    • wrapString

      public static String wrapString(String str, String wrapWith)
      Wrap string
      Parameters:
      str - the String
      wrapWith - String to be appended to the beginning and the end of str
      Returns:
      string
    • wrapString

      public static String wrapString(String str, String wrapStart, String wrapEnd)
      Wrap string
      Parameters:
      str - the String
      wrapStart - String to be appended to the beginning of str
      wrapEnd - String to be appended to the end of str
      Returns:
      wrapped string
    • getFieldVisibility

      public static String getFieldVisibility(MappingContext mappingContext)