From 097a33bc2ecaa64a664550ddd62ccd8de47c51d0 Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Tue, 1 Dec 2020 20:20:27 -0500 Subject: An assortment of changes --- src/main/java/bjc/data/IContext.java | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/main/java/bjc/data/IContext.java') diff --git a/src/main/java/bjc/data/IContext.java b/src/main/java/bjc/data/IContext.java index a1073f1..e519501 100644 --- a/src/main/java/bjc/data/IContext.java +++ b/src/main/java/bjc/data/IContext.java @@ -1,14 +1,58 @@ package bjc.data; +/** + * Represents a 'context' which is a hierarchical set of objects. + * @author Ben Culkin + * + */ public interface IContext { + /** + * Register an object with this context. + * + * @param name The name of the object. + * @param o The object to register. + */ void register(String name, Object o); + /** + * Get the parent of this context. + * + * @return The parent of this context. + */ IContext getParent(); + /** + * Get an object from this context. + * + * @param name The name of the object. + * + * @return The object bound to that name. + */ Object get(String name); + /** + * Get an object which is an instance of the provided class or a subclass + * thereof. + * + * @param The type of the object. + * + * @param contract The class of the object. + * + * @return An instance of the provided class. + */ T get(Class contract); + /** + * Get a named object which is an instance of the provided class or a subclass + * thereof. + * + * @param The type of the object. + * + * @param name The name of the object + * @param contract The class of the object. + * + * @return An instance of the provided class, with the given name.. + */ default T get(String name, Class contract) { Object obj = get(name); return obj == null -- cgit v1.2.3