Skip to content

Commit

Permalink
GH-392 Document the module design classes
Browse files Browse the repository at this point in the history
  • Loading branch information
dzikoysk committed Nov 1, 2019
1 parent 5df308d commit ea4b69c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

import org.panda_lang.framework.design.architecture.prototype.Reference;

/**
* Represents references imported in the specific space, e.g. file
*/
public interface Imports extends ModuleResource {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import java.util.Map.Entry;
import java.util.Optional;

/**
* Identifiable container of resources
*/
public interface Module extends Modules, ModuleResource {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
*/
public interface ModulePath extends Modules {

void include(String name, Runnable initialize);
/**
* Include initializer for the specified module
*
* @param name name of module
* @param initializer module initializer
*/
void include(String name, Runnable initializer);

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

import java.util.Optional;

/**
* References container
*/
public interface ModuleResource {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import java.util.Collection;
import java.util.Optional;

/**
* Modules container
*/
public interface Modules {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ public PandaModulePath(Module... modules) {
}

@Override
public void include(String name, Runnable initialize) {
public void include(String name, Runnable initializer) {
Runnable cachedInitialize = modules.get(name);

if (cachedInitialize != null) {
Runnable nextInitialize = initialize;
Runnable nextInitialize = initializer;

initialize = () -> {
initializer = () -> {
cachedInitialize.run();
nextInitialize.run();
};
}

modules.put(name, initialize);
modules.put(name, initializer);
}

@Override
Expand Down

0 comments on commit ea4b69c

Please sign in to comment.