/** * @param name Property name - never {@code null}/empty * @return The removed property value - {@code null} if no such property name */ public String removeProperty(String name) { String key = ValidateUtils.checkNotNullAndNotEmpty(name, "No property name"); Map<String, String> props = getProperties(); if (GenericUtils.isEmpty(props)) { return null; } else { return props.remove(key); } }
/** * @param name Property name - never {@code null}/empty * @return The removed property value - {@code null} if no such property name */ public String removeProperty(String name) { String key = ValidateUtils.checkNotNullAndNotEmpty(name, "No property name"); Map<String, String> props = getProperties(); if (GenericUtils.isEmpty(props)) { return null; } else { return props.remove(key); } }
/** * @param name Property name - never {@code null}/empty * @param defaultValue Default value to return if no such property * @return The property value or the default one if no such property */ public String getProperty(String name, String defaultValue) { String key = ValidateUtils.checkNotNullAndNotEmpty(name, "No property name"); Map<String, String> props = getProperties(); if (GenericUtils.isEmpty(props)) { return defaultValue; } String value = props.get(key); if (GenericUtils.isEmpty(value)) { return defaultValue; } else { return value; } }
/** * @param name Property name - never {@code null}/empty * @param defaultValue Default value to return if no such property * @return The property value or the default one if no such property */ public String getProperty(String name, String defaultValue) { String key = ValidateUtils.checkNotNullAndNotEmpty(name, "No property name"); Map<String, String> props = getProperties(); if (GenericUtils.isEmpty(props)) { return null; } String value = props.get(key); if (GenericUtils.isEmpty(value)) { return defaultValue; } else { return value; } }
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; }
normal.setUsername(entry.resolveUsername(username)); Map<String, String> props = entry.getProperties(); if (GenericUtils.size(props) > 0) { normal.setProperties(new TreeMap<>(props));
/** * Updates the values that are <U>not</U> already configured with those * from the global entry * * @param globalEntry The global entry - ignored if {@code null} or * same reference as this entry * @return {@code true} if anything updated */ public boolean processGlobalValues(HostConfigEntry globalEntry) { if ((globalEntry == null) || (this == globalEntry)) { return false; } boolean modified = false; /* * NOTE !!! DO NOT TRY TO CHANGE THE ORDER OF THE OR-ing AS IT * WOULD CAUSE INVALID CODE EXECUTION */ modified = updateGlobalPort(globalEntry.getPort()) || modified; modified = updateGlobalHostName(globalEntry.getHostName()) || modified; modified = updateGlobalUserName(globalEntry.getUsername()) || modified; modified = updateGlobalIdentities(globalEntry.getIdentities()) || modified; modified = updateGlobalIdentityOnly(globalEntry.isIdentitiesOnly()) || modified; Map<String, String> updated = updateGlobalProperties(globalEntry.getProperties()); modified = (GenericUtils.size(updated) > 0) || modified; return modified; }
/** * Updates the values that are <U>not</U> already configured with those * from the global entry * * @param globalEntry The global entry - ignored if {@code null} or * same reference as this entry * @return {@code true} if anything updated */ public boolean processGlobalValues(HostConfigEntry globalEntry) { if ((globalEntry == null) || (this == globalEntry)) { return false; } boolean modified = false; /* * NOTE !!! DO NOT TRY TO CHANGE THE ORDER OF THE OR-ing AS IT * WOULD CAUSE INVALID CODE EXECUTION */ modified = updateGlobalPort(globalEntry.getPort()) || modified; modified = updateGlobalHostName(globalEntry.getHostName()) || modified; modified = updateGlobalUserName(globalEntry.getUsername()) || modified; modified = updateGlobalIdentities(globalEntry.getIdentities()) || modified; modified = updateGlobalIdentityOnly(globalEntry.isIdentitiesOnly()) || modified; Map<String, String> updated = updateGlobalProperties(globalEntry.getProperties()); modified = (GenericUtils.size(updated) > 0) || modified; return modified; }
normal.setUsername(entry.resolveUsername(username)); Map<String, String> props = entry.getProperties(); if (GenericUtils.size(props) > 0) { normal.setProperties(