Estimates the on-heap memory cost of the given value.

@param value the value to estimate the cost of.
@return the estimated value cost.
187820
@SuppressWarnings({"checkstyle:npathcomplexity", "checkstyle:returncount"})
    public static long estimateValueCost(Object value) {
        if (value == null) {
            return 0;
        }
        Class<?> clazz = value.getClass();

        Integer cost = KNOWN_FINAL_CLASSES_COSTS.get(clazz);
        if (cost != null) {
            return cost;
        }

        if (value instanceof String) {
            return BASE_STRING_COST + ((String) value).length() * 2L;
        }

        if (value instanceof Timestamp) {
            return SQL_TIMESTAMP_COST;
        }

        if (value instanceof Date) {
            return DATE_COST;
        }

        if (clazz.isEnum()) {
            // enum values are shared, so they don't cost anything
            return 0;
        }

        if (value instanceof BigDecimal) {
            return ROUGH_BIG_DECIMAL_COST;
        }

        if (value instanceof BigInteger) {
            return ROUGH_BIG_INTEGER_COST;
        }

        return ROUGH_UNKNOWN_CLASS_COST;
    }
1167315
public static Buffer wrap(final int value) {
        final int size = value < 0 ? stringSize(-value) + 1 : stringSize(value);
        final byte[] bytes = new byte[size];
        getBytes(value, size, bytes);
        return new ByteBuffer(bytes);
    }
399247
public void addValue(String value)
    {
        if(this.values == null)
            this.values = new ArrayList<String>();
        this.values.add(value);
    }
364894
public final T allocate()
  {
    AtomicInteger topRef = _top;
    
    while (true) {
      final int top = topRef.get();

      if (top <= 0) {
        return null;
      }
      else if (topRef.compareAndSet(top, top - 1)) {
        T value = _freeStack.getAndSet(top - 1, null);
        
        if (value != null) {
          return value;
        }
      }
    }
  }
84345
public boolean add(final int value)
    {
        if (value == MISSING_VALUE)
        {
            final boolean previousContainsMissingValue = this.containsMissingValue;
            containsMissingValue = true;
            return !previousContainsMissingValue;
        }

        final int[] values = this.values;
        @DoNotSub final int mask = values.length - 1;
        @DoNotSub int index = Hashing.hash(value, mask);

        while (values[index] != MISSING_VALUE)
        {
            if (values[index] == value)
            {
                return false;
            }

            index = next(index, mask);
        }

        values[index] = value;
        sizeOfArrayValues++;

        if (sizeOfArrayValues > resizeThreshold)
        {
            increaseCapacity();
        }

        return true;
    }
1049942
public static final int getInt(String value)
   {
      return (value == null || value.length() == 0 ? 0 : Integer.parseInt(value));
   }
276643
@Override
	public void accept(final double value) {
		super.accept(value);
		_min = Math.min(_min, value);
		_max = Math.max(_max, value);
		_sum.add(value);
	}
602059
public T allocate()
  {
    while (true) {
      SoftReference<T> ref;
      
      ref = _ringQueue.poll();
      
      if (ref == null) {
        return null;
      }
      
      T value = ref.get();
      
      if (value != null) {
        return value;
      }
    }
  }
1374707
@Override
	public String setValue(String value) {
		String result = this.value;
		this.value = value;
		calculateCompareKey();
		return result;
	}
169383
public void setValue(T value)
    {
        try
        {
            lock.writeLock().lock();
            this.value = value;
        }
        finally
        {
            lock.writeLock().unlock();
        }
    }
1034644
public static int computeFieldSize(final FieldDescriptorLite<?> descriptor,
                                     final Object value) {
    WireFormat.FieldType type = descriptor.getLiteType();
    int number = descriptor.getNumber();
    if (descriptor.isRepeated()) {
      if (descriptor.isPacked()) {
        int dataSize = 0;
        for (final Object element : (List<?>)value) {
          dataSize += computeElementSizeNoTag(type, element);
        }
        return dataSize +
            CodedOutputStream.computeTagSize(number) +
            CodedOutputStream.computeRawVarint32Size(dataSize);
      } else {
        int size = 0;
        for (final Object element : (List<?>)value) {
          size += computeElementSize(type, number, element);
        }
        return size;
      }
    } else {
      return computeElementSize(type, number, value);
    }
  }
19879
public static Prefer valueOf(final String value) {
        if (nonNull(value)) {
            final Map<String, String> data = new HashMap<>();
            final Set<String> params = new HashSet<>();
            stream(value.split(";")).map(String::trim).map(pref -> pref.split("=", 2)).forEach(x -> {
                if (x.length == 2) {
                    data.put(x[0].trim(), x[1].trim());
                } else {
                    params.add(x[0].trim());
                }
            });
            final String waitValue = data.get(PREFER_WAIT);
            try {
                Integer wait = null;
                if (nonNull(waitValue)) {
                    wait = parseInt(waitValue);
                }
                return new Prefer(data.get(PREFER_RETURN), parseParameter(data.get(PREFER_INCLUDE)),
                        parseParameter(data.get(PREFER_OMIT)), params, data.get(PREFER_HANDLING), wait);
            } catch (final NumberFormatException ex) {
                LOGGER.error("Cannot parse wait parameter value {}: {}", waitValue, ex.getMessage());
            }
        }
        return null;
    }
589336
private int getWeight(Object value) {
    if (value == null) {
      return 0;
    }
    if (value.getClass().isArray()) {
      Class cc = value.getClass().getComponentType();
      if (cc.isPrimitive()) {
        if (cc.equals(int.class)) {
          return ((int[]) value).length * 4;
        } else if (cc.equals(long.class)) {
          return ((long[]) value).length * 8;
        } else if (cc.equals(double.class)) {
          return ((double[]) value).length * 8;
        } else if (cc.equals(float.class)) {
          return ((float[]) value).length * 4;
        } else if (cc.equals(boolean.class)) {
          return ((boolean[]) value).length * 1;
        } else if (cc.equals(byte.class)) {
          return ((byte[]) value).length * 1;
        } else if (cc.equals(short.class)) {
          return ((short[]) value).length * 2;
        } else if (cc.equals(char.class)) {
          return ((char[]) value).length * 2;
        }
      } else if (cc.equals(String.class)) {
        String[] v = (String[]) value;
        int res = 0;
        for (int i = 0; i < v.length; i++) {
          res += v[i].length() * 2 + 40;
        }
        return res;
      } else if (cc.equals(int[].class)) {
        int[][] v = (int[][]) value;
        int res = 0;
        for (int i = 0; i < v.length; i++) {
          res += v[i].length * 4;
        }
        return res;
      } else if (cc.equals(long[].class)) {
        long[][] v = (long[][]) value;
        int res = 0;
        for (int i = 0; i < v.length; i++) {
          res += v[i].length * 8;
        }
        return res;
      } else {
        Object[] v = (Object[]) value;
        int res = 0;
        for (int i = 0; i < v.length; i++) {
          res += getWeight(v[i]);
        }
        return res;
      }
    } else if (value instanceof String) {
      return ((String) value).length() * 2 + 40;
    } else {
      Serializer serializer = configuration.getSerializer(value.getClass());
      if (serializer != null) {
        return serializer.getWeight(value);
      }
    }
    return 16;
  }
1010562
public String resolveValue(final String value) {
        if (value == null) {
            return null;
        }

        final String sharedValue = valuePool.get(value);
        if (sharedValue != null) {
            return sharedValue;
        }

        valuePool.put(value, value);
        return value;
    }
916949
public void writeValue (Object value) {
		if (value == null)
			writeValue(value, null, null);
		else
			writeValue(value, value.getClass(), null);
	}
378188
@Override
    public int estimateUnassembledValueSize(int index) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            JmfTr.entry(this, tc, "estimateUnassembledValueSize", index);

        int size = 0;

        // We are only interested in 'real' fields, not boxed variants etc
        if (index < cacheSize) {
            checkIndex(index);

            synchronized (getMessageLockArtefact()) {

                // We can only figure out the size if we have a field definition (which presumably should
                // be the case). Have to specifiy false on getFieldDef, otherwise it will return null
                // if the message hasn't been assembled.
                JSField field = getFieldDef(index, false);
                if (field != null) {

                    Object val = cache[index];

                    // If the value is in the cache and isn't something with 0 size
                    if ((val != null)
                        && (val != nullIndicator)
                        && (val != JSVaryingListImpl.EMPTY_UNBOXED_VARYINGLIST)
                        && (val != JSFixedListImpl.EMPTY_FIXEDLIST)) {
                        size = (field.estimateSizeOfUnassembledValue(val, indirect));
                    }

                    // If not, estimate it from the information in the contents, if we have any
                    else if (contents != null) {
                        try {
                            size = (field.estimateSizeOfUnassembledValue(contents, getAbsoluteOffset(index), indirect));
                        } catch (JMFUninitializedAccessException e) {
                            // No FFDC code needed
                            // We don't want to throw an exception or even FFDC it (as we don't
                            // know anything useful to FFDC). We'll just let it default to 0.
                        }
                    }
                }
            }
        }

        // If we have no FieldDef, a nullIndicator or no contents, then we will just return 0;

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            JmfTr.exit(this, tc, "estimateUnassembledValueSize", size);
        return size;
    }
544049
public static Range valueOf(final String value) {
        final Optional<Integer[]> vals = parse(value);
        if (vals.isPresent()) {
            return new Range(vals.get()[0], vals.get()[1]);
        }
        return null;
    }