If target is null, return the value; else append value to target.
If withSpace is true, insert a blank between them.
@param target target to be appended
@param value value to append
@param withSpace whether insert a blank
@return processed string
545038
public static String setOrAppend(final String target, final String value, final boolean withSpace) {
        if (target == null) {
            return value;
        }if(value == null) {
            return target;
        } else {
            if (withSpace && !target.endsWith(STRING_BLANK)) {
                return target + STRING_BLANK + value;
            } else {
                return target + value;
            }
        }
    }
860909
public static void setFieldValue(Object target, String fieldName, Object value) {
        try {
            Field field = target.getClass().getDeclaredField(fieldName);
            field.setAccessible(true);
            field.set(target, value);
        } catch (NoSuchFieldException e) {
            throw handleException(fieldName, e);
        } catch (IllegalAccessException e) {
            throw handleException(fieldName, e);
        }
    }
449353
public static <T> T getValue(Object target, String dPath, Class<T> clazz) {
        if (clazz == null) {
            throw new NullPointerException("Class parameter is null!");
        }
        Object temp = getValue(target, dPath);
        return ValueUtils.convertValue(temp, clazz);
    }
298648
public static <T> T orElseIfNull(T target, T elseTarget) {
        return Optional.ofNullable(target).orElse(elseTarget);
    }
151128
@Nullable
    public final Target findTargetFor(@Nullable final String targetPath) {
        if (targets == null) {
            return null;
        }
        if (targetPath == null) {
            return null;
        }
        for (final Target target : targets) {
            if (target.matches(targetPath)) {
                return target;
            }
        }
        return null;
    }
184669
def _append(self, target, value):
        
        return self.__p(target) + '[] = ' + self.__p(value) + ';'
23253
@SuppressWarnings("unchecked")
	protected static <T> T jsonConvert(Type targetType, Object value, boolean ignoreError) throws ConvertException {
		if (JSONUtil.isNull(value)) {
			return null;
		}
		
		Object targetValue = null;
		try {
			targetValue = Convert.convert(targetType, value);
		} catch (ConvertException e) {
			if (ignoreError) {
				return null;
			}
			throw e;
		}
		
		if (null == targetValue && false == ignoreError) {
			if (StrUtil.isBlankIfStr(value)) {
				// 对于传入空字符串的情况，如果转换的目标对象是非字符串或非原始类型，转换器会返回false。
				// 此处特殊处理，认为返回null属于正常情况
				return null;
			}
			
			throw new ConvertException("Can not convert {} to type {}", value, ObjectUtil.defaultIfNull(TypeUtil.getClass(targetType), targetType));
		}

		return (T) targetValue;
	}
449782
public void processingInstruction(String target, String data) throws SAXException {
		emitWhitespace();
		super.processingInstruction(target, data);
	}
432025
public static Date convertDate(Object target) {
        if (target instanceof JsonNode) {
            return convertDate((JsonNode) target);
        }
        DateFormat df = new SimpleDateFormat();
        try {
            return target instanceof Date ? (Date) target
                    : target instanceof Number ? new Date(((Number) target).longValue())
                            : target instanceof String ? df.parse(target.toString()) : null;
        } catch (ParseException e) {
            return null;
        }
    }
953828
public void addValue(String value) {
		contents.add(value);
		if (value.trim().length() > 0) {
			if (contents.size() == 1) {
				containsSingleString = true;
			} else {
				containsSingleString = false;
				containsMarkupText = true;
			}
		}
	}
240574
private void getStringFromValue(final StringBuilder builder, final String directive, final String value) {
        if (value != null) {
            builder.append(directive).append(" ").append(value).append(";");
        }
    }
234112
protected final Object convert(Class targetType, String value) {
        Converter converter = Stapler.lookupConverter(targetType);
        if (converter==null)
            throw new IllegalArgumentException("Unable to convert to "+targetType);

        return converter.convert(targetType,value);
    }
687188
@SuppressWarnings("unchecked")
	private static <T> T maskNull(T value) {
		return (value == null) ? (T) NULL_VALUE : value;
	}
1178928
public void addValue(
                    final Object value
                    )
    {
        if (value == null) {
            setNullContained( true );
        } else {
            _values.add( String.valueOf( value ) );
        }
    }
1306167
def patch(target, value):
    
    patch = current_space().patch_for(target)
    patch.set_value(value)
    return patch
282121
public String removeWhitespace(String value) {
        String result = null;
        if (value != null) {
            result = replaceAllInWith("\\s+", value, "");
        }
        return result;
    }
1296081
public void addValue(String value) {
        if (value == null)
            return;

        StringBuffer buffer = new StringBuffer();

        int l = value.length();
        State state = State.VALUE;
        boolean quoted = false;
        boolean sloshed = false;
        int nws_length = 0;
        int last_length = 0;
        int value_length = -1;
        int param_name = -1;
        int param_value = -1;

        for (int i = 0; i <= l; i++) {
            char c = i == l ? 0 : value.charAt(i);

            // Handle quoting https://tools.ietf.org/html/rfc7230#section-3.2.6
            if (quoted && c != 0) {
                if (sloshed)
                    sloshed = false;
                else {
                    switch (c) {
                        case '\\':
                            sloshed = true;
                            if (!_keepQuotes)
                                continue;
                            break;
                        case '"':
                            quoted = false;
                            if (!_keepQuotes)
                                continue;
                            break;
                    }
                }

                buffer.append(c);
                nws_length = buffer.length();
                continue;
            }

            // Handle common cases
            switch (c) {
                case ' ':
                case '\t':
                    if (buffer.length() > last_length) // not leading OWS
                        buffer.append(c);
                    continue;

                case '"':
                    quoted = true;
                    if (_keepQuotes) {
                        if (state == State.PARAM_VALUE && param_value < 0)
                            param_value = nws_length;
                        buffer.append(c);
                    } else if (state == State.PARAM_VALUE && param_value < 0)
                        param_value = nws_length;
                    nws_length = buffer.length();
                    continue;

                case ';':
                    buffer.setLength(nws_length); // trim following OWS
                    if (state == State.VALUE) {
                        parsedValue(buffer);
                        value_length = buffer.length();
                    } else
                        parsedParam(buffer, value_length, param_name, param_value);
                    nws_length = buffer.length();
                    param_name = param_value = -1;
                    buffer.append(c);
                    last_length = ++nws_length;
                    state = State.PARAM_NAME;
                    continue;

                case ',':
                case 0:
                    if (nws_length > 0) {
                        buffer.setLength(nws_length); // trim following OWS
                        switch (state) {
                            case VALUE:
                                parsedValue(buffer);
//                                value_length = buffer.length();
                                break;
                            case PARAM_NAME:
                            case PARAM_VALUE:
                                parsedParam(buffer, value_length, param_name, param_value);
                                break;
                        }
                        _values.add(buffer.toString());
                    }
                    buffer.setLength(0);
                    last_length = 0;
                    nws_length = 0;
                    value_length = param_name = param_value = -1;
                    state = State.VALUE;
                    continue;

                case '=':
                    switch (state) {
                        case VALUE:
                            // It wasn't really a value, it was a param name
                            value_length = param_name = 0;
                            buffer.setLength(nws_length); // trim following OWS
                            String param = buffer.toString();
                            buffer.setLength(0);
                            parsedValue(buffer);
                            value_length = buffer.length();
                            buffer.append(param);
                            buffer.append(c);
                            last_length = ++nws_length;
                            state = State.PARAM_VALUE;
                            continue;

                        case PARAM_NAME:
                            buffer.setLength(nws_length); // trim following OWS
                            buffer.append(c);
                            last_length = ++nws_length;
                            state = State.PARAM_VALUE;
                            continue;

                        case PARAM_VALUE:
                            if (param_value < 0)
                                param_value = nws_length;
                            buffer.append(c);
                            nws_length = buffer.length();
                            continue;
                    }
                    continue;

                default: {
                    switch (state) {
                        case VALUE: {
                            buffer.append(c);
                            nws_length = buffer.length();
                            continue;
                        }

                        case PARAM_NAME: {
                            if (param_name < 0)
                                param_name = nws_length;
                            buffer.append(c);
                            nws_length = buffer.length();
                            continue;
                        }

                        case PARAM_VALUE: {
                            if (param_value < 0)
                                param_value = nws_length;
                            buffer.append(c);
                            nws_length = buffer.length();
                        }
                    }
                }
            }
        }
    }