Creates a {@link Value} from a {@code value}. The resulting value contains the value.

@param value the value. Must not be {@literal null}.
@param <T>
@param <V>
@return the {@link Value}
777936
public static <T extends V, V> Value<V> just(T value) {

        LettuceAssert.notNull(value, "Value must not be null");

        return new Value<V>(value);
    }
184802
public static VINT fromValue(long value) {
        BitSet bs = BitSet.valueOf(new long[] { value });
        byte length = (byte) (1 + bs.length() / BIT_IN_BYTE);
        if (bs.length() == length * BIT_IN_BYTE) {
            length++;
        }
        bs.set(length * BIT_IN_BYTE - length);
        long binary = bs.toLongArray()[0];
        return new VINT(binary, length, value);
    }
1139904
private JsonElement toElement(final Object value) {

		if (value != null) {

			if (value instanceof String) {

				return new JsonPrimitive((String)value);

			} else if (value instanceof Number) {

				return new JsonPrimitive((Number)value);

			} else if (value instanceof Boolean) {

				return new JsonPrimitive((Boolean)value);

			} else if (value.getClass().isArray()) {

				final JsonArray arr   = new JsonArray();
				final Object[] values = (Object[])value;

				for (final Object v : values) {
					arr.add(toElement(v));
				}

				return arr;

			} else {

				return new JsonPrimitive(value.toString());
			}
		}

		return JsonNull.INSTANCE;
	}
475849
public static <T> T newInstance(final T value) throws MIDDException {
        if (value == null) {
            return null;
        } else {
            return newInstance(value, value.getClass());
        }

    }
134940
@VisibleForTesting
  static TypedValue createTypedValue(Value value) {
    return value.match(
        typedValueDoubleFunction,
        typedValueLongFunction,
        typedValueDistributionFunction,
        typedValueSummaryFunction,
        Functions.<TypedValue>throwIllegalArgumentException());
  }
822537
public static NfsCreateMode fromValue(int value) {
        NfsCreateMode createMode = VALUES.get(value);
        if (createMode == null) {
            createMode = new NfsCreateMode(value);
            VALUES.put(value, createMode);
        }
        return createMode;
    }
1266410
public static MessageBody fromValueData(Object value)
    {
    	if(value == null)
    	{
    		throw new IllegalArgumentException("Value data is null.");
    	}
    	
    	MessageBody body = new MessageBody();
    	body.bodyType = MessageBodyType.VALUE;
    	body.valueData = value;
    	body.sequenceData = null;
    	body.binaryData = null;
    	return body;
    }
125510
@SuppressWarnings("unchecked")
    protected final U fromObject(Object value) {
        return value == NULL ? null : (U)value;
    }
443983
public <V> ValueInterval<T, I, V> withValue(V value) {

        return new ValueInterval<>(this.getContext(), value);

    }
106802
public ValueInterval<T, I, V> withValue(V value) {

        return new ValueInterval<>(this.interval, value);

    }
1327157
public <T> Predicate<T> be(T value) {
    return create(obj -> Objects.equals(obj, value));
  }
333745
public <T> T convert(Object value, Class<T> clazz) {
    if (null == value) return null;
    if (value instanceof String && Strings.isEmpty((String) value)) { return null; }
    if (value.getClass().isArray()) {
      Object[] values = (Object[]) value;
      if (values.length >= 1) {
        value = values[0];
      }
    }
    return conversion.convert(value, clazz);
  }
81595
public static Integer getAsInteger(Object value) {
		Integer result = null;

		try {
			if (value instanceof String) {
				result = Integer.valueOf((String) value);
			} else if (value instanceof Number) {
				result = ((Number) value).intValue();
			} else {
				result = null;
			}
		} catch (Exception e) {
			result = null;
		}

		return result == null ? 0 : result;
	}
1009831
public <T> T convert(String value, Class<T> to) {
        if (Strings.isEmpty(value) && !(String.class.equals(to) || String[].class.equals(to))) {
            return null;
        }

        if (String.class.equals(to)) {
            return to.cast(value);
        } else if (Integer.class.equals(to)) {
            return to.cast(Integer.valueOf(value));
        } else if (Double.class.equals(to)) {
            return to.cast(Double.valueOf(value));
        } else if (Long.class.equals(to)) {
            return to.cast(Long.valueOf(value));
        } else if (Boolean.class.equals(to)) {
            return to.cast(Boolean.valueOf(value));
        } else if (URL.class.equals(to)) {
            try {
                return to.cast(new URI(value).toURL());
            } catch (MalformedURLException e) {
                throw new IllegalArgumentException("Unable to convert value " + value + " to URL", e);
            } catch (URISyntaxException e) {
                throw new IllegalArgumentException("Unable to convert value " + value + " to URL", e);
            }
        } else if (URI.class.equals(to)) {
            try {
                return to.cast(new URI(value));
            } catch (URISyntaxException e) {
                throw new IllegalArgumentException("Unable to convert value " + value + " to URL", e);
            }
        } else {
            String trimmedValue = extractEnumName(value);
            if (to.isEnum()) {
                return (T) Enum.valueOf((Class<Enum>) to, trimmedValue.toUpperCase());
            } else if (String[].class.equals(to)) {
                final String[] convertedArray = value.split(",");
                if (convertedArray.length == 0) {
                    return to.cast(new String[0]);
                }

                trimElements(convertedArray);

                if (convertedArray.length == 1 && hasOnlyBlanks(convertedArray)) {
                    return to.cast(new String[0]);
                }

                return to.cast(convertedArray);
            } else if (Charset.class.equals(to)) {
                return to.cast(Charset.forName(trimmedValue.toUpperCase()));
            } else if (Class.class.equals(to)) {
                try {
                    Object clazz = Class.forName(value);
                    return to.cast(clazz);
                } catch (Exception e) {
                    throw new IllegalArgumentException("Unable to find class [" + value + "].", e);
                }
            } else // Try to create instance via reflection
            {
                try {
                    Object instance = Class.forName(value).newInstance();
                    return to.cast(instance);
                } catch (Exception e) {
                    throw new IllegalArgumentException(
                        "Unable to convert value [" + value + "] to a class [" + to.getName() + "].", e);
                }
            }
        }
    }
924493
public static CharSequence toParameterValue(final Float value) {
        return value != null ? Float.toString(value) : Attr.nullValue();
    }
606496
public static Range fromString(String value) {
        if (value == null || value.isEmpty())
            return null;
        JsArrayNumber array = JsonUtils.safeEval(value);
        return new Range(array);
    }
28731
public Value createValue(Identifier value)
   {
      if (value == null)
         return null;
      try
      {
         return new ReferenceValue(value);
      }
      catch (IOException e)
      {
         LOG.warn("Cannot create REFERENCE Value from Identifier " + value, e);
         return null;
      }
   }