nl.tudelft.ewi.auta.srf.model.AccessLevel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of auta-srf Show documentation
Show all versions of auta-srf Show documentation
A facade for metric script executors
The newest version!
package nl.tudelft.ewi.auta.srf.model;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* The access level of a single instance of feedback (a {@link Note}).
*
* Access levels can inherit from other access levels. For example, all access levels should
* inherit from {@link #PUBLIC}. Generally, narrower levels should inherit from broader levels.
*/
public enum AccessLevel {
/**
* Everyone can read the feedback.
*/
PUBLIC,
/**
* The submitter can read the feedback.
*/
SUBMITTER(Set.of(PUBLIC)),
/**
* All educational staff (i.e., instructors and teaching assistants) can read the feedback.
*/
EDUCATIONAL(Set.of(SUBMITTER)),
/**
* The course instructors can read the feedback.
*/
INSTRUCTOR(Set.of(EDUCATIONAL)),
/**
* Only the administrator can read the feedback.
*/
ADMINISTRATIVE(Set.of(INSTRUCTOR));
/**
* The set of effective levels for this level.
*
* This contains the inheritance tree, flattened into a simple set for easy checks, and the
* current level itself.
*/
private final Set effectiveLevels;
/**
* Creates a new access level.
*
* @param inheritedLevels the levels this level inherits
*/
AccessLevel(final Set inheritedLevels) {
final var levels = new HashSet();
inheritedLevels.stream().flatMap(l -> l.effectiveLevels.stream()).forEach(levels::add);
levels.add(this);
this.effectiveLevels = levels;
}
/**
* Creates a new access level.
*
* This level does not inherit from any other level.
*/
AccessLevel() {
this(Collections.emptySet());
}
/**
* Returns the effective levels of the access level.
*
* This contains the inheritance tree, flattened into a simple set for easy checks, and the
* current level itself.
*
* @return the access levels
*/
public Set getEffectiveLevels() {
return Collections.unmodifiableSet(this.effectiveLevels);
}
}