code: public static boolean isConstantKey(Key<?> key) {
      Type type = key.getTypeLiteral().getType();
  
      if (!(type instanceof Class)) {
        return false;
      }
  
      Class clazz = (Class) type;
      return clazz == String.class || clazz == Class.class || clazz.isPrimitive()
          || Number.class.isAssignableFrom(clazz) || Character.class.isAssignableFrom(clazz)
          || Boolean.class.isAssignableFrom(clazz) || clazz.isEnum();
    }
docs: Returns true if the provided key is a valid constant key, i.e. if a
  constant binding can be legally created for it.
  
  @param key key to check
  @return true if constant key