A DynamicScope is a PCGenScope that covers a specific Category of Dynamic object.
| 28 | * A DynamicScope is a PCGenScope that covers a specific Category of Dynamic object. |
| 29 | */ |
| 30 | public class DynamicScope implements PCGenScope |
| 31 | { |
| 32 | /** |
| 33 | * The parent PCGenScope for all DynamicScope objects is the GlobalPCScope. |
| 34 | */ |
| 35 | private static final Optional<PCGenScope> PARENT_SCOPE = Optional.of(SpringHelper.getBean(GlobalPCScope.class)); |
| 36 | |
| 37 | /** |
| 38 | * The DynamicCategory indicating the objects contained by this DynamicScope. |
| 39 | */ |
| 40 | private final DynamicCategory category; |
| 41 | |
| 42 | /** |
| 43 | * The FormatManager for the objects contained in this DynamicScope. |
| 44 | */ |
| 45 | private final FormatManager<Dynamic> formatManager; |
| 46 | |
| 47 | /** |
| 48 | * Constructs a new DynamicScope for the given DynamicCategory and containing the |
| 49 | * objects identified in the given FormatManager. |
| 50 | * |
| 51 | * @param category |
| 52 | * The DynamicCategory indicating the objects contained by this |
| 53 | * DynamicScope |
| 54 | * @param formatManager |
| 55 | * The FormatManager for the objects contained in this DynamicScope |
| 56 | */ |
| 57 | public DynamicScope(DynamicCategory category, FormatManager<Dynamic> formatManager) |
| 58 | { |
| 59 | this.category = Objects.requireNonNull(category); |
| 60 | this.formatManager = Objects.requireNonNull(formatManager); |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public String getName() |
| 65 | { |
| 66 | return category.getName(); |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public Optional<PCGenScope> getParentScope() |
| 71 | { |
| 72 | return PARENT_SCOPE; |
| 73 | } |
| 74 | |
| 75 | @Override |
| 76 | public Optional<FormatManager<?>> getFormatManager(LoadContext context) |
| 77 | { |
| 78 | return Optional.of(formatManager); |
| 79 | } |
| 80 | } |