/** * @param <A> The {@link Appendable} type * @param sb The target appender * @param name The property name - never {@code null}/empty * @param values The values to be added - one per line - ignored if {@code null}/empty * @return The target appender after having appended (or not) the value * @throws IOException If failed to append the requested data * @see #appendNonEmptyValues(Appendable, String, Collection) */ public static <A extends Appendable> A appendNonEmptyValues(A sb, String name, Object... values) throws IOException { return appendNonEmptyValues(sb, name, GenericUtils.isEmpty(values) ? Collections.emptyList() : Arrays.asList(values)); }
/** * @param <A> The {@link Appendable} type * @param sb The target appender * @param name The property name - never {@code null}/empty * @param values The values to be added - one per line - ignored if {@code null}/empty * @return The target appender after having appended (or not) the value * @throws IOException If failed to append the requested data * @see #appendNonEmptyValues(Appendable, String, Collection) */ public static <A extends Appendable> A appendNonEmptyValues(A sb, String name, Object... values) throws IOException { return appendNonEmptyValues(sb, name, GenericUtils.isEmpty(values) ? Collections.emptyList() : Arrays.asList(values)); }
/** * @param <A> The {@link Appendable} type * @param sb The target appender * @param name The property name - never {@code null}/empty * @param value The property value - ignored if {@code null}. <B>Note:</B> * if the string representation of the value contains any commas, they are * assumed to indicate a multi-valued property which is broken down to * <U>individual</U> lines - one per value. * @return The target appender after having appended (or not) the value * @throws IOException If failed to append the requested data * @see #appendNonEmptyValues(Appendable, String, Object...) */ public static <A extends Appendable> A appendNonEmptyProperty(A sb, String name, Object value) throws IOException { String s = Objects.toString(value, null); String[] vals = GenericUtils.split(s, ','); return appendNonEmptyValues(sb, name, (Object[]) vals); }
/** * @param <A> The {@link Appendable} type * @param sb The target appender * @param name The property name - never {@code null}/empty * @param value The property value - ignored if {@code null}. <B>Note:</B> * if the string representation of the value contains any commas, they are * assumed to indicate a multi-valued property which is broken down to * <U>individual</U> lines - one per value. * @return The target appender after having appended (or not) the value * @throws IOException If failed to append the requested data * @see #appendNonEmptyValues(Appendable, String, Object...) */ public static <A extends Appendable> A appendNonEmptyProperty(A sb, String name, Object value) throws IOException { String s = Objects.toString(value, null); String[] vals = GenericUtils.split(s, ','); return appendNonEmptyValues(sb, name, (Object[]) vals); }
public <A extends Appendable> A append(A sb) throws IOException { sb.append(HOST_CONFIG_PROP).append(' ').append(ValidateUtils.checkNotNullAndNotEmpty(getHost(), "No host pattern")).append(IoUtils.EOL); appendNonEmptyProperty(sb, HOST_NAME_CONFIG_PROP, getHostName()); appendNonEmptyPort(sb, PORT_CONFIG_PROP, getPort()); appendNonEmptyProperty(sb, USER_CONFIG_PROP, getUsername()); appendNonEmptyValues(sb, IDENTITY_FILE_CONFIG_PROP, getIdentities()); if (exclusiveIdentites != null) { appendNonEmptyProperty(sb, EXCLUSIVE_IDENTITIES_CONFIG_PROP, ConfigFileReaderSupport.yesNoValueOf(exclusiveIdentites)); } appendNonEmptyProperties(sb, getProperties()); return sb; }
public <A extends Appendable> A append(A sb) throws IOException { sb.append(HOST_CONFIG_PROP).append(' ').append(ValidateUtils.checkNotNullAndNotEmpty(getHost(), "No host pattern")).append(IoUtils.EOL); appendNonEmptyProperty(sb, HOST_NAME_CONFIG_PROP, getHostName()); appendNonEmptyPort(sb, PORT_CONFIG_PROP, getPort()); appendNonEmptyProperty(sb, USER_CONFIG_PROP, getUsername()); appendNonEmptyValues(sb, IDENTITY_FILE_CONFIG_PROP, getIdentities()); if (exclusiveIdentites != null) { appendNonEmptyProperty(sb, EXCLUSIVE_IDENTITIES_CONFIG_PROP, ConfigFileReaderSupport.yesNoValueOf(exclusiveIdentites)); } appendNonEmptyProperties(sb, getProperties()); return sb; }