![JAR search and dependency download from the Maven repository](/logo.png)
com.atlassian.usercontext.api.AccountId Maven / Gradle / Ivy
package com.atlassian.usercontext.api;
import org.apache.commons.lang3.StringUtils;
import java.util.Objects;
import static java.util.Objects.requireNonNull;
/**
* Wrapper around a string to represent an Atlassian AccountId
*/
public class AccountId {
public static final AccountId UNIDENTIFIED = new AccountId("unidentified");
private final String accountId;
private AccountId(String accountId) {
this.accountId = requireNonNull(accountId);
}
public String value() {
return accountId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AccountId accountId1 = (AccountId) o;
return Objects.equals(accountId, accountId1.accountId);
}
@Override
public int hashCode() {
return Objects.hash(accountId);
}
@Override
public String toString() {
return value();
}
public static AccountId of(String accountId) {
if (StringUtils.isBlank(accountId)) {
throw new IllegalArgumentException("Account Id must not be null or blank");
}
return UNIDENTIFIED.value().equals(accountId) ? UNIDENTIFIED : new AccountId(accountId);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy