001/* 002 * PermissionsEx 003 * Copyright (C) zml and PermissionsEx contributors 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package ca.stellardrift.permissionsex.context; 018 019import org.checkerframework.checker.nullness.qual.Nullable; 020 021import java.util.List; 022import java.util.Map; 023 024/** 025 * Holder for information about inheritance between contexts. Immutable. 026 * 027 * @since 2.0.0 028 */ 029public interface ContextInheritance { 030 /** 031 * Get the parents of a specific context. 032 * 033 * <p>When this context is present in a subject's active contexts, its parents are appended 034 * to the subject's active contexts for the purpose of data queries.</p> 035 * 036 * @param context The child context 037 * @return Any parent contexts, or an empty list 038 * @since 2.0.0 039 */ 040 List<ContextValue<?>> parents(ContextValue<?> context); 041 042 /** 043 * Set the parents for a specific context. 044 * 045 * @param context The context to set parents in 046 * @param parents The parents to set, or {@code null} to clear parents for the context. 047 * @return A new context inheritance object with the updated parents 048 * @since 2.0.0 049 */ 050 ContextInheritance parents(ContextValue<?> context, @Nullable List<ContextValue<?>> parents); 051 052 /** 053 * Get all parent data as a map from context to list of parent contexts. 054 * 055 * <p>The returned map is immutable.</p> 056 * 057 * @return parents 058 * @since 2.0.0 059 */ 060 Map<ContextValue<?>, List<ContextValue<?>>> allParents(); 061 062}