@NotNull
public static Map<String, String> toProperties(@NotNull ServerConfig config, @Nullable String valueIfUnset,
@Nullable String valueIfPasswordStored, @Nullable String valueIfPasswordNotStored) {
Map<String, String> ret = new HashMap<>();
ret.put(PerforceEnvironment.P4PORT, config.getServerName().getDisplayName());
ret.put(PerforceEnvironment.P4TRUST,
! config.hasTrustTicket() || config.getTrustTicket() == null
? valueIfUnset
: config.getTrustTicket().toString());
ret.put(PerforceEnvironment.P4USER, config.getUsername());
ret.put(PerforceEnvironment.P4TICKETS,
! config.hasAuthTicket() || config.getAuthTicket() == null
? valueIfUnset
: config.getAuthTicket().toString());
ret.put(PerforceEnvironment.P4SERVER_FINGERPRINT,
! config.hasServerFingerprint() || config.getServerFingerprint() == null
? valueIfUnset
: config.getServerFingerprint());
ret.put(PerforceEnvironment.P4PASSWD,
config.usesStoredPassword() ? valueIfPasswordStored : valueIfPasswordNotStored);
ret.put(PerforceEnvironment.P4LOGINSSO,
! config.hasLoginSso() || config.getLoginSso() == null
? valueIfUnset
: config.getLoginSso());
return ret;
}