code: public static boolean sameLiteral(Literal l1,
                                        String l2,
                                        URI type,
                                        String lang) {
          if (l1.getLexicalForm().equals(l2) && eq(l1.getLanguage(), lang)) {
              if (l1.getDatatypeURI() == null) {
                  return type == null;
              } else {
                  return type != null
                          && type.equals(l1.getDatatypeURI());
              }
          } else {
              return false;
          }
      }
docs: Tells whether the given literals are equivalent, with one given as a set
  of simple values.
  
  @param l1
  first literal.
  @param l2
  second literal's lexical value.
  @param type
  second literal's datatype URI string, if applicable.
  @param lang
  second literal's language tag string, if applicable.
  @return true if equivalent, false otherwise.