com.memority.toolkit.inwebo.api.UserStatus Maven / Gradle / Ivy
/*
* Copyright (c) 2016-2023 Memority. All Rights Reserved.
*
* This file is part of Memority Toolkit API , a Memority project.
*
* This file is released under the Memority Public Artifacts End-User License Agreement,
* see
* Unauthorized copying of this file, via any medium is strictly prohibited.
*/
package com.memority.toolkit.inwebo.api;
import java.util.Arrays;
/**
* InWebo user activation status.
* Value in InWebo API is a number.
*/
public enum UserStatus {
ACTIVE(0),
SUSPENDED(1),
UNKNOWN(-1);
private long apiValue;
UserStatus(long apiValue) {
this.apiValue = apiValue;
}
public static UserStatus getFromApiValue(long apiValue) {
return Arrays.stream(UserStatus.values())
.filter(v -> v.apiValue == apiValue)
.findFirst().orElseThrow(() -> new IllegalArgumentException(String.format("Cannot match inwebo user status from unknown API value '%s'", apiValue)));
}
public long getApiValue() {
return apiValue;
}
public static UserStatus fromValue(long val) {
switch(Math.toIntExact(val)) {
case 0: return ACTIVE;
case 1: return SUSPENDED;
default: return UNKNOWN;
}
}
}