diff options
author | Dmitriy Kargapolov <[email protected]> | 2015-02-03 16:39:39 -0500 |
---|---|---|
committer | Dmitriy Kargapolov <[email protected]> | 2015-02-03 16:39:39 -0500 |
commit | 2fdc3d313485a76b6acf12154b8f3bd3e1ceb2ca (patch) | |
tree | 39e42440dcaebb29368fd0290391d328f216524b /lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangObject.java | |
parent | ab1cfe19a0af082a2c207fb5c07c7a6ad5782c14 (diff) | |
download | otp-2fdc3d313485a76b6acf12154b8f3bd3e1ceb2ca.tar.gz otp-2fdc3d313485a76b6acf12154b8f3bd3e1ceb2ca.tar.bz2 otp-2fdc3d313485a76b6acf12154b8f3bd3e1ceb2ca.zip |
jinterface: match/bind added to OtpErlangObject
Adding these two methods to the OtpErlangObject abstract class makes possible
implementing of pattern matching and variable binding for all types of Erlang
terms. Particular implementations may vary and include additional classes to
define Variable placeholder objects and Bindings objects. Also Parser class
may be added to facilitate creating complex patterns and terms.
The purpose of this commit is to provide low level interface base methods
sufficient for variety of higher level pattern matching/variable binding
implementations.
OtpErlangMap class is re-designed for efficiency (it is based on HashMap now).
All changes are backward-compatible. Detailed test cases implemented.
Diffstat (limited to 'lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangObject.java')
-rw-r--r-- | lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangObject.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangObject.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangObject.java index 7ab160bcdd..9339d3749b 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangObject.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangObject.java @@ -80,6 +80,32 @@ public abstract class OtpErlangObject implements Serializable, Cloneable { @Override public abstract boolean equals(Object o); + /** + * Perform match operation against given term. + * + * @param term + * the object to match + * @param binds + * variable bindings + * @return true if match succeeded + */ + public <T> boolean match(final OtpErlangObject term, final T binds) { + return equals(term); + } + + /** + * Make new Erlang term replacing variables with the respective values from + * bindings argument(s). + * + * @param binds + * variable bindings + * @return new term + * @throws OtpErlangException + */ + public <T> OtpErlangObject bind(final T binds) throws OtpErlangException { + return this; + } + @Override public int hashCode() { if (hashCodeValue == 0) { |