code: public static boolean isOptional(TypeRef type) {
          if (!(type instanceof ClassRef)) {
              return false;
          }
  
          return JAVA_UTIL_OPTIONAL.equals(((ClassRef)type).getDefinition().getFullyQualifiedName());
      }
docs: Checks if a {@link TypeRef} is a {@link java.util.Optional}.
  @param type  The type to check.
  @return      True if its a {@link java.util.Optional}.