Reviewer 역할 검증 보고서 smoke #9

Open
forge-bot wants to merge 5 commits from forge/runtime-role-matrix-live-20260714101723-v7-reviewer-001-attempt-3-run-f5cb07374744 into main
Showing only changes of commit c1b71e0e3a - Show all commits

View file

@ -0,0 +1,59 @@
package com.klaroworks.runtime.role;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
/**
* Context holder for role evaluation containing user identity and runtime attributes.
*/
public final class RoleContext {
private final String userId;
private final Map<String, Object> attributes;
public RoleContext(String userId) {
this(userId, new ConcurrentHashMap<>());
}
public RoleContext(String userId, Map<String, Object> attributes) {
this.userId = Objects.requireNonNull(userId, "userId must not be null");
this.attributes = new ConcurrentHashMap<>(Objects.requireNonNull(attributes, "attributes must not be null"));
}
public String getUserId() {
return userId;
}
public Map<String, Object> getAttributes() {
return Map.copyOf(attributes);
}
public Object getAttribute(String key) {
return attributes.get(key);
}
public RoleContext withAttribute(String key, Object value) {
Map<String, Object> newAttrs = new ConcurrentHashMap<>(attributes);
newAttrs.put(key, value);
return new RoleContext(userId, newAttrs);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RoleContext that = (RoleContext) o;
return Objects.equals(userId, that.userId) && Objects.equals(attributes, that.attributes);
}
@Override
public int hashCode() {
return Objects.hash(userId, attributes);
}
@Override
public String toString() {
return "RoleContext{userId='" + userId + "', attributes=" + attributes + "}";
}
}