Create and set a Type Value Pair instance for a given type and value

@param type The type to set
@param value The value to set
@return The Type Value Pair instance
1574
protected TypeValuePairType getTypeValuePair(String type, byte[] value) {
        TypeValuePairType tvp = new TypeValuePairType();
        tvp.setType(type);
        //tvp.setValue(Base64.encodeBase64Chunked(value));
        // the TVP itself base64 encodes now, no need for this
        tvp.setValue(value);
        return tvp;
    }
13093
public Datatype.Builder mergeFrom(Datatype value) {
    Datatype_Builder defaults = new Datatype.Builder();
    if (defaults._unsetProperties.contains(Property.TYPE)
        || !Objects.equals(value.getType(), defaults.getType())) {
      setType(value.getType());
    }
    if (defaults._unsetProperties.contains(Property.INTERFACE_TYPE)
        || value.isInterfaceType() != defaults.isInterfaceType()) {
      setInterfaceType(value.isInterfaceType());
    }
    if (defaults._unsetProperties.contains(Property.BUILDER)
        || !Objects.equals(value.getBuilder(), defaults.getBuilder())) {
      setBuilder(value.getBuilder());
    }
    if (defaults._unsetProperties.contains(Property.EXTENSIBLE)
        || value.isExtensible() != defaults.isExtensible()) {
      setExtensible(value.isExtensible());
    }
    value.getBuilderFactory().ifPresent(this::setBuilderFactory);
    if (defaults._unsetProperties.contains(Property.GENERATED_BUILDER)
        || !Objects.equals(value.getGeneratedBuilder(), defaults.getGeneratedBuilder())) {
      setGeneratedBuilder(value.getGeneratedBuilder());
    }
    if (defaults._unsetProperties.contains(Property.VALUE_TYPE)
        || !Objects.equals(value.getValueType(), defaults.getValueType())) {
      setValueType(value.getValueType());
    }
    if (defaults._unsetProperties.contains(Property.PARTIAL_TYPE)
        || !Objects.equals(value.getPartialType(), defaults.getPartialType())) {
      setPartialType(value.getPartialType());
    }
    value.getRebuildableType().ifPresent(this::setRebuildableType);
    if (defaults._unsetProperties.contains(Property.PROPERTY_ENUM)
        || !Objects.equals(value.getPropertyEnum(), defaults.getPropertyEnum())) {
      setPropertyEnum(value.getPropertyEnum());
    }
    putAllStandardMethodUnderrides(value.getStandardMethodUnderrides());
    if (defaults._unsetProperties.contains(Property.BUILDER_SERIALIZABLE)
        || value.isBuilderSerializable() != defaults.isBuilderSerializable()) {
      setBuilderSerializable(value.isBuilderSerializable());
    }
    if (defaults._unsetProperties.contains(Property.HAS_TO_BUILDER_METHOD)
        || value.getHasToBuilderMethod() != defaults.getHasToBuilderMethod()) {
      setHasToBuilderMethod(value.getHasToBuilderMethod());
    }
    if (value instanceof Value && generatedBuilderAnnotations == ImmutableList.<Excerpt>of()) {
      generatedBuilderAnnotations = ImmutableList.copyOf(value.getGeneratedBuilderAnnotations());
    } else {
      addAllGeneratedBuilderAnnotations(value.getGeneratedBuilderAnnotations());
    }
    if (value instanceof Value && valueTypeAnnotations == ImmutableList.<Excerpt>of()) {
      valueTypeAnnotations = ImmutableList.copyOf(value.getValueTypeAnnotations());
    } else {
      addAllValueTypeAnnotations(value.getValueTypeAnnotations());
    }
    if (defaults._unsetProperties.contains(Property.VALUE_TYPE_VISIBILITY)
        || !Objects.equals(value.getValueTypeVisibility(), defaults.getValueTypeVisibility())) {
      setValueTypeVisibility(value.getValueTypeVisibility());
    }
    if (value instanceof Value && nestedClasses == ImmutableList.<Excerpt>of()) {
      nestedClasses = ImmutableList.copyOf(value.getNestedClasses());
    } else {
      addAllNestedClasses(value.getNestedClasses());
    }
    return (Datatype.Builder) this;
  }
433341
public static <T> QueryParameterValue of(T value, StandardSQLTypeName type) {
    return QueryParameterValue.newBuilder()
        .setValue(valueToStringOrNull(value, type))
        .setType(type)
        .build();
  }
809925
public Binder append(Class<?> type, Object value) {
        return new Binder(this, new Insert(type().parameterCount(), new Class[]{type}, value));
    }
324704
final public function setValueType(&$value, $type) {

        if ( empty($value) || !in_array(strtolower($type), array("base64", "datetime", "cdata")) ) throw new XmlrpcException("Invalid value type");

        $this->special_types[$value] = strtolower($type);

        return $this;

    }
1057747
public static VariableMap putValueTyped(String name, TypedValue value) {
    return createVariables().putValueTyped(name, value);
  }
1020766
public static <T> T convert(Type type, Object value, T defaultValue) throws ConvertException {
		return ConverterRegistry.getInstance().convert(type, value, defaultValue);
	}
59965
public function setValue($value, $type = null)
    {
        $this->value = $value;
        $this->type  = $type ?: ParameterTypeInferer::inferType($value);
    }
557865
public static TLVElement create(int type, byte[] value) throws TLVParserException {
        TLVElement element = create(type);
        element.setContent(value);
        return element;
    }
1032242
public DataPoint add(long value) {
        switch (type) {
        case MINIMUM:
            this.value = Math.min(this.value, value);
            break;
        case MAXIMUM:
            this.value = Math.max(this.value, value);
            break;
        case AVERAGE:
        case SUM:
            this.value += value;
            this.numPoints++;
            break;
        default:
            throw new IllegalStateException("Unknown type [" + type + "]!");
        }
        return this;
    }
206329
public static Datatype.Builder from(Datatype value) {
    if (value instanceof Rebuildable) {
      return ((Rebuildable) value).toBuilder();
    } else {
      return new Datatype.Builder().mergeFrom(value);
    }
  }
531180
protected Object cast(Object value) {
        switch (type) {
            case STRING :
               return valueFactories.getStringFactory().create(value);
            case LONG :
                return valueFactories.getLongFactory().create(value);
            case NAME :
                return valueFactories.getNameFactory().create(value);
            case PATH :
                return valueFactories.getPathFactory().create(value);
            case DATE :
                return valueFactories.getDateFactory().create(value);
            case BOOLEAN :
                return valueFactories.getBooleanFactory().create(value);
            case URI :
                return valueFactories.getUriFactory().create(value);
            case REFERENCE :
                return valueFactories.getReferenceFactory().create(value);
            case SIMPLEREFERENCE :
                return valueFactories.getSimpleReferenceFactory().create(value);
            case WEAKREFERENCE :
                return valueFactories.getWeakReferenceFactory().create(value);
            default :
                return value;
        }
    }
1182616
public static boolean checkValueIsType(Object value, Object name, Class type) {
        if (value != null) {
            if (type.isAssignableFrom(value.getClass())) {
                return true;
            } else {
                throw new RuntimeException("The value argument of '" + name + "' must be of type "
                        + type.getName() + ". Found: " + value.getClass());
            }
        } else {
            return false;
        }
    }
1368565
public Tree setType(Class<?> type) {
		if (value == null || value.getClass() == type) {
			return this;
		}
		value = DataConverterRegistry.convert(type, value);
		if (parent != null && key != null) {
			if (key instanceof String) {
				parent.putObjectInternal((String) key, value, false);
			} else {
				parent.remove((int) key);
				parent.insertObjectInternal((int) key, value);
			}
		}
		return this;
	}
495151
public static Object getValeByType(Class<?> type, Object value)
            throws Exception {

        // 预处理
        if (!(value instanceof String)) {
            value = "";
        }

        // trim
        String dataValue = (String) value;
        dataValue = dataValue.trim();

        // process
        String typeName = type.getName();
        typeName = typeName.toLowerCase();

        if (typeName.equals("int") || typeName.equals("java.lang.integer")) {

            if (value.equals("")) {
                value = "0";
            }

            return Integer.valueOf(dataValue);

        } else if (typeName.equals("long") || typeName.equals("java.lang.long")) {

            if (value.equals("")) {
                value = "0";
            }

            return Long.valueOf(dataValue);

        } else if (typeName.equals("boolean")
                || typeName.equals("java.lang.boolean")) {

            if (value.equals("")) {
                value = "false";
            }

            return Boolean.valueOf(dataValue);

        } else if (typeName.equals("double")
                || typeName.equals("java.lang.double")) {

            if (value.equals("")) {
                value = "0.0";
            }

            return Double.valueOf(dataValue);

        } else {

            return value;
        }
    }
662466
protected static Object convertBasicValue(String value, Class<?> type) {
        if (type == null) {
            throw new IllegalArgumentException("Type cannot be null");
        }

        if (String.class.equals(type)) {
            return value;
        }

        if (value == null || value.trim().isEmpty()) {
            return null;
        }

        try {
            value = value.trim();
            if (Byte.class.equals(type)) {
                return Byte.parseByte(value);
            } else if (Short.class.equals(type)) {
                return Short.parseShort(value);
            } else if (Integer.class.equals(type)) {
                return Integer.parseInt(value);
            } else if (Long.class.equals(type)) {
                return Long.parseLong(value);
            } else if (BigInteger.class.equals(type)) {
                return new BigInteger(value);
            } else if (Float.class.equals(type)) {
                return Float.parseFloat(value);
            } else if (Double.class.equals(type)) {
                return Double.parseDouble(value);
            } else if (BigDecimal.class.equals(type)) {
                return new BigDecimal(value);
            } else if (Boolean.class.equals(type)) {
                return Boolean.parseBoolean(value);
            }
        } catch (Exception e) {
            throw new UniformException(String.format("Error while converting value %s to data type %s. Make sure the element has correct values and/or validators", value, type.getName()), e);
        }

        throw new UnsupportedOperationException("Could not convert value to unknown type: " + type.getName());
    }
452346
public function set($field, $value, $type = 0)
    {
        $this->_write_fields[] = $field;
        $this->_write_values[] = $value;
        $this->_write_field_types[] = $type;

        return $this;
    }