Copied from {@link org.apache.el.lang.ELSupport#coerceToString(Object)}.
164195
private static final String coerceToString(final Object obj) {
        if (obj == null) {
            return "";
        } else if (obj instanceof String) {
            return (String) obj;
        } else if (obj instanceof Enum<?>) {
            return ((Enum<?>) obj).name();
        } else {
            return obj.toString();
        }
    }
1159657
private void validateStringPropBinding(LocalComponentProp localComponentProp) {
    if (localComponentProp.getType().toString().equals(String.class.getCanonicalName())) {
      return;
    }

    logger.error("Passing a String to a non String Prop: \""
        + localComponentProp.getPropName()
        + "\". "
        + "If you want to pass a boolean or an int you should use v-bind. "
        + "For example: v-bind:my-prop=\"12\" (or using the short syntax, :my-prop=\"12\") instead of my-prop=\"12\".");
  }
568177
@Override
  public String asString(Object object)
  {
    // at this point object is guaranteed to be enumeration
    Enum<?> e = (Enum<?>)object;
    if(object instanceof OrdinalEnum) {
      return Integer.toString(e.ordinal());
    }
    return e.name();
  }
372382
function coerce(scopes) {
  if (scopes instanceof ScopeSet) {
    return scopes;
  }
  // If we receive a string, assume it's a single scope.
  // We deliberately do not attempt to split the string on whitespace here,
  // because we want to force callers to explicitly choose between
  // exports.fromString() or exports.fromURLEncodedString depending on
  // what encoding they expect to have received the string in.
  if (typeof scopes === 'string') {
    return new ScopeSet([scopes]);
  }
  return new ScopeSet(scopes);
}
1069881
protected Object coerceToType(Object param, Class<?> type)
            throws Throwable {
        if (type != Object.class)
            param = Types.castObject(param, type, Types.CAST);
        return Primitive.unwrap(param);
    }
276519
public static final String serializeToString(final Object object) {
    if (object == null)
      throw new IllegalArgumentException("Object was null");
    try {
      return jsonMapper.writeValueAsString(object);
    } catch (JsonProcessingException e) {
      throw new JSONException(e);
    }
  }
328134
String objectsToString(String key, Object objects) {
        java.io.StringWriter stringWriter = new java.io.StringWriter();
        stringWriter.write(key);
        stringWriter.write(":");

        if (objects == null) {
            stringWriter.write("\n");

        } else if (objects instanceof Object[]) {
            for (int i = 0; i < ((Object[]) objects).length; i++) {
                Object object = ((Object[]) objects)[i];
                if (object == null)
                    stringWriter.write("null\n");
                else {
                    stringWriter.write(((Object[]) objects)[i].toString());
                    stringWriter.write("\n");
                }
            }

        } else {
            stringWriter.write(objects.toString());
            stringWriter.write("\n");
        }

        return stringWriter.toString();
    }
120854
@SuppressWarnings("unchecked")
    static <T> T stringToType(String str, Class<T> clazz) {
        try {
            final Function<String, ?> func = supportedElementTypes.get(clazz);
            if (func != null) {
                return (T) func.apply(str);
            }
        } catch (NumberFormatException e) {
            throw e;
        } catch (Throwable cause) {
            throw new IllegalArgumentException(
                    "Can't convert '" + str + "' to type '" + clazz.getSimpleName() + "'.", cause);
        }

        throw new IllegalArgumentException(
                "Can't convert '" + str + "' to type '" + clazz.getSimpleName() + "'.");
    }
41863
public static Object coerce(Object pValue,
                                Class pClass,
                                Logger pLogger)
            throws ELException {
        if (pClass == String.class) {
            return coerceToString(pValue, pLogger);
        } else if (isPrimitiveNumberClass(pClass)) {
            return coerceToPrimitiveNumber(pValue, pClass, pLogger);
        } else if (pClass == Character.class ||
                pClass == Character.TYPE) {
            return coerceToCharacter(pValue, pLogger);
        } else if (pClass == Boolean.class ||
                pClass == Boolean.TYPE) {
            return coerceToBoolean(pValue, pLogger);
        } else {
            return coerceToObject(pValue, pClass, pLogger);
        }
    }
964549
@Override
    protected String convertToString(Object value) throws Throwable {
		Key key = (Key) value;
		return KeyFactory.keyToString(key);
    }
135091
@Override
    public final String getString(final String key) {
        String result = optString(key);
        if (result == null) {
            throw new ObjectMissingException(this, key);
        }
        return result;
    }
1068648
public T object(Object object) throws IOException {
		text(stringifierFactory.toString(object));
		return (T) this;
	}
34229
public static String toNamedString(Object object, Object... components) {
        StringBuilder b = new StringBuilder(components.length * 5 + 2);
        if (object != null) {
            b.append(object.getClass().getSimpleName()).append(' ');
        }
        b.append('{');
        for (int i = 0; i < components.length; i++) {
            if (i != 0) {
                b.append(", ");
            }
            b.append(components[i]);
        }
        b.append('}');
        return b.toString();
    }
749370
public SoyExpression coerceToBoolean() {
    // First deal with primitives which don't have to care about null.
    if (BytecodeUtils.isPrimitive(resultType())) {
      return coercePrimitiveToBoolean();
    }
    if (soyType().equals(NullType.getInstance())) {
      return FALSE;
    }
    if (delegate.isNonNullable()) {
      return coerceNonNullableReferenceTypeToBoolean();
    } else {
      // If we are potentially nullable, then map null to false and run the normal logic recursively
      // for the non-nullable branch.
      final Label end = new Label();
      return withSource(
              new Expression(delegate.resultType(), delegate.features()) {
                @Override
                protected void doGen(CodeBuilder adapter) {
                  delegate.gen(adapter);
                  adapter.dup();
                  Label nonNull = new Label();
                  adapter.ifNonNull(nonNull);
                  adapter.pop();
                  adapter.pushBoolean(false);
                  adapter.goTo(end);
                  adapter.mark(nonNull);
                }
              })
          .asNonNullable()
          .coerceToBoolean()
          .labelEnd(end);
    }
  }
304824
private <T extends ValueMap> T coerceToValueMap(Object object, Class<T> clazz) {
    if (object == null) return null;
    if (clazz.isAssignableFrom(object.getClass())) {
      //noinspection unchecked
      return (T) object;
    }
    if (object instanceof Map) return createValueMap((Map) object, clazz);
    return null;
  }
579617
@Override
    @Deprecated
    public T from(final String string) throws IllegalArgumentException, DescriptorImportException {
        return fromString(string);
    }
1201707
private String objectToString(Object obj, String xsdType) {
        if (obj == null) {
            return "null";
        }
        String javaType = obj.getClass().getCanonicalName();
        String term;
        if (javaType != null && javaType.equals("java.util.Date")) { // several circumstances yield null canonical names
            term = DateUtility.convertDateToXSDString((Date) obj);
        } else if (xsdType.equals("fedora-types:ArrayOfString")) {
            term = array2string(obj);
        } else if (xsdType.equals("xsd:boolean")) {
            term = obj.toString();
        } else if (xsdType.equals("xsd:nonNegativeInteger")) {
            term = obj.toString();
        } else if (xsdType.equals("fedora-types:RelationshipTuple")) {
            RelationshipTuple[] tuples = (RelationshipTuple[]) obj;
            TupleArrayTripleIterator iter =
                    new TupleArrayTripleIterator(new ArrayList<RelationshipTuple>(Arrays
                            .asList(tuples)));
            ReadableByteArrayOutputStream os = new ReadableByteArrayOutputStream();
            try {
                iter.toStream(os, RDFFormat.NOTATION_3, false);
            } catch (TrippiException e) {
                e.printStackTrace();
            }
            term = os.getString(Charset.forName("UTF-8"));
        } else if (javaType != null && javaType.equals("java.lang.String")) {
            term = (String) obj;
            term = term.replaceAll("\"", "'");
        } else {
            term = "[OMITTED]";
        }
        return term;
    }