Utility method to bind wildcard generics.

@see #write(ObservationTable, Appendable)
484336
private <I, D> void writeInternal(ObservationTable<I, D> table,
                                     Function<? super Word<? extends I>, ? extends String> wordToString,
                                     Function<? super D, ? extends String> outputToString,
                                     Appendable out) throws IOException {
        List<Word<I>> suffixes = table.getSuffixes();

        out.append("<table class=\"learnlib-observationtable\">").append(System.lineSeparator());
        out.append("\t<thead>").append(System.lineSeparator());
        out.append("\t\t<tr><th rowspan=\"2\" class=\"prefix\">Prefix</th><th colspan=\"")
           .append(Integer.toString(suffixes.size()))
           .append("\" class=\"suffixes-header\">Suffixes</th></tr>").append(System.lineSeparator());
        out.append("\t\t<tr>");
        for (Word<I> suffix : suffixes) {
            out.append("<td>").append(wordToString.apply(suffix)).append("</td>");
        }
        out.append("</tr>").append(System.lineSeparator());
        out.append("\t</thead>").append(System.lineSeparator());
        out.append("\t<tbody>").append(System.lineSeparator());

        for (Row<I> row : table.getShortPrefixRows()) {
            out.append("\t\t<tr class=\"short-prefix\"><td class=\"prefix\">")
               .append(wordToString.apply(row.getLabel()))
               .append("</td>");
            for (D value : table.rowContents(row)) {
                out.append("<td class=\"suffix-column\">").append(outputToString.apply(value)).append("</td>");
            }
            out.append("</tr>").append(System.lineSeparator());
        }

        out.append("\t\t<tr><td colspan=\"").append(Integer.toString(suffixes.size() + 1)).append("\"></td></tr>").append(System.lineSeparator());

        for (Row<I> row : table.getLongPrefixRows()) {
            out.append("\t\t<tr class=\"long-prefix\"><td>").append(wordToString.apply(row.getLabel())).append("</td>");
            for (D value : table.rowContents(row)) {
                out.append("<td class=\"suffix-column\">").append(outputToString.apply(value)).append("</td>");
            }
            out.append("</tr>").append(System.lineSeparator());
        }

        out.append("</table>").append(System.lineSeparator());
    }
935591
public void write(RowOutputInterface out,
                      ResultMetaData meta) throws IOException {

        beforeFirst();
        out.writeLong(id);
        out.writeInt(size);
        out.writeInt(0);    // offset
        out.writeInt(size);

        while (hasNext()) {
            Object[] data = getNext();

            out.writeData(meta.getColumnCount(), meta.columnTypes, data, null,
                          null);
        }

        beforeFirst();
    }
1181656
@Override
	public void internalWrite(Server server, Query query, ImmutableList<Result> results) throws Exception {
		checkFile(query);
		List<String> typeNames = getTypeNames();

		for (Result result : results) {
			String[] keyString = KeyUtils.getKeyString(server, query, result, typeNames, null).split("\\.");
			if (isNumeric(result.getValue()) && filters.contains(keyString[2])) {
				int thresholdPos = filters.indexOf(keyString[2]);
				StringBuilder sb = new StringBuilder();

				sb.append("[");
				sb.append(result.getEpoch());
				sb.append("] PROCESS_SERVICE_CHECK_RESULT;");
				sb.append(nagiosHost);
				sb.append(";");
				if (prefix != null) {
					sb.append(prefix);
				}
				sb.append(keyString[2]);
				if (suffix != null) {
					sb.append(suffix);
				}
				sb.append(";");
				sb.append(nagiosCheckValue(result.getValue().toString(), thresholds.get(thresholdPos)));
				sb.append(";");
				//Missing the performance information

				logger.info(sb.toString());
			}
		}
	}
1139601
public void writeResult(Map<BioPAXElement, List<Match>> matches, OutputStream out)
		throws IOException
	{
		OutputStreamWriter writer = new OutputStreamWriter(out);

		for (BioPAXElement ele : matches.keySet())
		{
			Set<String> syms = new HashSet<String>();

			for (Match m : matches.get(ele))
			{
				ProteinReference pr = (ProteinReference) m.get("PR", getPattern());

				String sym = getGeneSymbol(pr);
				if (sym != null) syms.add(sym);
			}

			if (syms.size() > 1)
			{
				writer.write("\n" + ele.getUri());

				for (Object o : controlAcc.getValueFromBean(ele))
				{
					Control ctrl = (Control) o;
					writer.write(" " + ctrl.getUri());
				}

				for (String sym : syms)
				{
					writer.write("\t" + sym);
				}
			}
		}
		writer.flush();
	}
381504
private Map<String, Object> writeBean(Bean bean, Class<?> declaredType) {
        Map<String, Object> result = new LinkedHashMap<>();
        // property information
        for (MetaProperty<?> prop : bean.metaBean().metaPropertyIterable()) {
            if (prop.style().isSerializable() || (prop.style().isDerived() && settings.isIncludeDerived())) {
                Object value = SerOptional.extractValue(prop, bean);
                if (value != null) {
                    Object outputValue = null;
                    Class<?> propType = SerOptional.extractType(prop, bean.getClass());
                    if (value instanceof Bean) {
                        if (settings.getConverter().isConvertible(value.getClass())) {
                            outputValue = writeSimple(propType, value);
                        } else {
                            outputValue = writeBean((Bean) value, propType);
                        }
                    } else {
                        SerIterator itemIterator = settings.getIteratorFactory().create(value, prop, bean.getClass(), true);
                        if (itemIterator != null) {
                            outputValue = writeElements(itemIterator);
                        } else {
                            outputValue = writeSimple(propType, value);
                        }
                    }
                    result.put(prop.name(), outputValue);
                }
            }
        }
        return result;
    }
436518
public <T> void write(final PrintWriter writer, final T object,
			final DataTypeDescriptor<T> descriptor, final boolean indent) {
		try {
			jsonFormat.write(writer, object, descriptor, indent);
		} catch (Exception e) {
			throw propagate(e);
		}
	}
1348730
private void writeXAResource(Definition def, Writer out, int indent) throws IOException
   {
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * This method is called by the application server during crash recovery.\n");
      writeWithIndent(out, indent, " *\n");
      writeWithIndent(out, indent, " * @param specs An array of ActivationSpec JavaBeans \n");
      writeWithIndent(out, indent, " * @throws ResourceException generic exception \n");
      writeWithIndent(out, indent, " * @return An array of XAResource objects\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "public XAResource[] getXAResources(ActivationSpec[] specs)\n");
      writeWithIndent(out, indent + 1, "throws ResourceException");
      writeLeftCurlyBracket(out, indent);
      writeLogging(def, out, indent + 1, "trace", "getXAResources", "specs.toString()");
      writeWithIndent(out, indent + 1, "return null;");
      writeRightCurlyBracket(out, indent);
      writeEol(out);
   }
252154
protected void write(JsonWriter out, T value, TypeAdapter<JsonElement> elementAdapter, TypeAdapter<T> delegate) throws IOException {
        JsonElement tree = delegate.toJsonTree(value);
        beforeWrite(value, tree);
        elementAdapter.write(out, tree);
    }
240638
@NonNull
    public ObservableAdapterBuilder<T> appends(@Nullable Observable<? extends Collection<? extends T>> appends) {
        mAppends = appends;
        return this;
    }
757036
private void writeObject(ObjectOutputStream out) throws IOException {
		out.writeInt(batchSize);
		this.conf.write(out);
		out.writeUTF(schema.toString());

		out.writeInt(selectedFields.length);
		for (int f : selectedFields) {
			out.writeInt(f);
		}

		out.writeInt(conjunctPredicates.size());
		for (Predicate p : conjunctPredicates) {
			out.writeObject(p);
		}
	}
830099
private @Nullable CacheWriterException writeAllToCacheWriter(Map<? extends K, ? extends V> map) {
    if (!configuration.isWriteThrough() || map.isEmpty()) {
      return null;
    }
    List<Cache.Entry<? extends K, ? extends V>> entries = map.entrySet().stream()
        .map(entry -> new EntryProxy<>(entry.getKey(), entry.getValue()))
        .collect(toList());
    try {
      writer.writeAll(entries);
      return null;
    } catch (CacheWriterException e) {
      entries.forEach(entry -> {
        map.remove(entry.getKey());
      });
      throw e;
    } catch (RuntimeException e) {
      entries.forEach(entry -> {
        map.remove(entry.getKey());
      });
      return new CacheWriterException("Exception in CacheWriter", e);
    }
  }
207793
@Override
	public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
	{
		return reflector.getComponentType().isAssignableFrom(type)
			&& MediaType.valueOf(reflector.getContentType()).isCompatible(mediaType);
	}
440933
private void writeMetaData(Definition def, Writer out, int indent) throws IOException
   {
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Gets metadata for the Resource Adapter. \n");
      writeWithIndent(out, indent, " *\n");
      writeWithIndent(out, indent, " * @return ResourceAdapterMetaData instance\n");
      writeWithIndent(out, indent, " * @throws ResourceException Failed to get metadata information \n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "@Override\n");
      writeWithIndent(out, indent, "public ResourceAdapterMetaData getMetaData() throws ResourceException");
      writeLeftCurlyBracket(out, indent);

      writeIndent(out, indent + 1);
      if (def.isUseRa())
      {
         out.write("return new " + def.getRaMetaClass() + "();");
      }
      else
      {
         out.write("return null;");
      }
      writeRightCurlyBracket(out, indent);
      writeEol(out);
   }
503504
private <T extends ProgramElementDoc> void mapTypeParameters(Map<String,List<T>> map, Object doc,
            T holder) {
        TypeVariable[] typeVariables;
        if (doc instanceof ClassDoc) {
            typeVariables = ((ClassDoc) doc).typeParameters();
        } else if (doc instanceof WildcardType) {
            Type[] extendsBounds = ((WildcardType) doc).extendsBounds();
            for (int k = 0; k < extendsBounds.length; k++) {
                addTypeParameterToMap(map, extendsBounds[k], holder);
            }
            Type[] superBounds = ((WildcardType) doc).superBounds();
            for (int k = 0; k < superBounds.length; k++) {
                addTypeParameterToMap(map, superBounds[k], holder);
            }
            return;
        } else if (doc instanceof ParameterizedType) {
            Type[] typeArguments = ((ParameterizedType) doc).typeArguments();
            for (int k = 0; k < typeArguments.length; k++) {
                addTypeParameterToMap(map, typeArguments[k], holder);
            }
            return;
        } else if (doc instanceof ExecutableMemberDoc) {
            typeVariables = ((ExecutableMemberDoc) doc).typeParameters();
        } else if (doc instanceof FieldDoc) {
            Type fieldType = ((FieldDoc) doc).type();
            mapTypeParameters(map, fieldType, holder);
            return;
        } else {
            return;
        }
        for (int i = 0; i < typeVariables.length; i++) {
            Type[] bounds = typeVariables[i].bounds();
            for (int j = 0; j < bounds.length; j++) {
                addTypeParameterToMap(map, bounds[j], holder);
            }
        }
    }
258897
void writeEntityTypes(Collection<EntityType> entityTypes, XlsxWriter writer) {
    LinkedList<EntityType> sortedEntityTypes = sortEntityTypesAbstractFirst(entityTypes);
    if (!writer.hasSheet(EMX_ENTITIES)) {
      writer.createSheet(EMX_ENTITIES, newArrayList(ENTITIES_ATTRS.keySet()));
    }
    writer.writeRows(sortedEntityTypes.stream().map(EntityTypeMapper::map), EMX_ENTITIES);
  }
517720
void writeSimple(Class<?> declaredType, Object value) throws IOException {
        // simple types have no need to write a type object
        Class<?> realType = value.getClass();
        if (realType == Integer.class) {
            output.writeInt(((Integer) value).intValue());
            return;
        } else if (realType == Double.class) {
            output.writeDouble(((Double) value).doubleValue());
            return;
        } else if (realType == Float.class) {
            output.writeFloat(((Float) value).floatValue());
            return;
        } else if (realType == Boolean.class) {
            output.writeBoolean(((Boolean) value).booleanValue());
            return;
        }

        // handle no declared type and subclasses
        Class<?> effectiveType = getAndSerializeEffectiveTypeIfRequired(value, declaredType);

        // long/short/byte only processed now to ensure that a distinction can be made between Integer and Long
        if (realType == Long.class) {
            output.writeLong(((Long) value).longValue());
            return;
        } else if (realType == Short.class) {
            output.writeInt(((Short) value).shortValue());
            return;
        } else if (realType == Byte.class) {
            output.writeInt(((Byte) value).byteValue());
            return;
        } else if (realType == byte[].class) {
            output.writeBytes((byte[]) value);
            return;
        }

        // write as a string
        try {
            writeObjectAsString(value, effectiveType);
        } catch (RuntimeException ex) {
            throw new IllegalArgumentException("Unable to convert type " + effectiveType.getName() + " declared as " + declaredType.getName(), ex);
        }
    }
710266
public <T> ExcelDataWriter<?> registerDataWriter(Class<T> type, ExcelDataWriter<T> writer) {
        if (writer != null) {
            return writers.put(type, writer);
        } else {
            return null;
        }
    }