/** * @param <A> The {@link Appendable} type * @param sb The target appender * @param name The property name - never {@code null}/empty * @param port The port value - ignored if non-positive * @return The target appender after having appended (or not) the value * @throws IOException If failed to append the requested data * @see #appendNonEmptyProperty(Appendable, String, Object) */ public static <A extends Appendable> A appendNonEmptyPort(A sb, String name, int port) throws IOException { return appendNonEmptyProperty(sb, name, (port > 0) ? Integer.toString(port) : null); }
/** * @param <A> The {@link Appendable} type * @param sb The target appender * @param name The property name - never {@code null}/empty * @param port The port value - ignored if non-positive * @return The target appender after having appended (or not) the value * @throws IOException If failed to append the requested data * @see #appendNonEmptyProperty(Appendable, String, Object) */ public static <A extends Appendable> A appendNonEmptyPort(A sb, String name, int port) throws IOException { return appendNonEmptyProperty(sb, name, (port > 0) ? Integer.toString(port) : null); }
/** * Appends the extra properties - while skipping the {@link #EXPLICIT_PROPERTIES} ones * * @param <A> The {@link Appendable} type * @param sb The target appender * @param props The {@link Map} of properties - 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 #appendNonEmptyProperty(Appendable, String, Object) */ public static <A extends Appendable> A appendNonEmptyProperties(A sb, Map<String, ?> props) throws IOException { if (GenericUtils.isEmpty(props)) { return sb; } // Cannot use forEach because of the IOException being thrown by appendNonEmptyProperty for (Map.Entry<String, ?> pe : props.entrySet()) { String name = pe.getKey(); if (EXPLICIT_PROPERTIES.contains(name)) { continue; } appendNonEmptyProperty(sb, name, pe.getValue()); } return sb; }
/** * Appends the extra properties - while skipping the {@link #EXPLICIT_PROPERTIES} ones * * @param <A> The {@link Appendable} type * @param sb The target appender * @param props The {@link Map} of properties - 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 #appendNonEmptyProperty(Appendable, String, Object) */ public static <A extends Appendable> A appendNonEmptyProperties(A sb, Map<String, ?> props) throws IOException { if (GenericUtils.isEmpty(props)) { return sb; } // Cannot use forEach because of the IOException being thrown by appendNonEmptyProperty for (Map.Entry<String, ?> pe : props.entrySet()) { String name = pe.getKey(); if (EXPLICIT_PROPERTIES.contains(name)) { continue; } appendNonEmptyProperty(sb, name, pe.getValue()); } 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; }
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; }