private static void writeValue(DataOutput out, ConfigValue value, SimpleConfigOrigin baseOrigin)
      throws IOException {
    FieldOut origin = new FieldOut(SerializedField.VALUE_ORIGIN);
    writeOrigin(origin.data, (SimpleConfigOrigin) value.origin(), baseOrigin);
    writeField(out, origin);

    FieldOut data = new FieldOut(SerializedField.VALUE_DATA);
    writeValueData(data.data, value);
    writeField(out, data);

    writeEndMarker(out);
  }
    static SerializedValueType forValue(ConfigValue value) {
      ConfigValueType t = value.valueType();
      if (t == ConfigValueType.NUMBER) {
        if (value instanceof ConfigInt) return INT;
        else if (value instanceof ConfigLong) return LONG;
        else if (value instanceof ConfigDouble) return DOUBLE;
      } else {
        for (SerializedValueType st : values()) {
          if (st.configType == t) return st;
        }
      }

      throw new ConfigException.BugOrBroken("don't know how to serialize " + value);
    }
 @Override
 public int hashCode() {
   int h = 41 * (41 + value.hashCode());
   h = 41 * (h + (wasConfig ? 1 : 0));
   return h;
 }