[jsemver] 42/95: Create basic Expression types

Alexandre Viau reazem-guest at moszumanska.debian.org
Mon Feb 16 14:58:28 UTC 2015


This is an automated email from the git hooks/post-receive script.

reazem-guest pushed a commit to branch master
in repository jsemver.

commit 87bb03dd7f9e10d88e01bbade6b1ad5123480028
Author: Zafar Khaja <zafarkhaja at gmail.com>
Date:   Mon Nov 4 18:54:21 2013 +0400

    Create basic Expression types
---
 .../com/github/zafarkhaja/semver/expr/And.java     | 46 ++++++++++++++++++
 .../com/github/zafarkhaja/semver/expr/Equal.java   | 44 +++++++++++++++++
 .../github/zafarkhaja/semver/expr/Expression.java  | 34 +++++++++++++
 .../com/github/zafarkhaja/semver/expr/Greater.java | 44 +++++++++++++++++
 .../zafarkhaja/semver/expr/GreaterOrEqual.java     | 44 +++++++++++++++++
 .../com/github/zafarkhaja/semver/expr/Less.java    | 44 +++++++++++++++++
 .../github/zafarkhaja/semver/expr/LessOrEqual.java | 44 +++++++++++++++++
 .../com/github/zafarkhaja/semver/expr/Not.java     | 44 +++++++++++++++++
 .../github/zafarkhaja/semver/expr/NotEqual.java    | 44 +++++++++++++++++
 .../java/com/github/zafarkhaja/semver/expr/Or.java | 46 ++++++++++++++++++
 .../com/github/zafarkhaja/semver/expr/AndTest.java | 53 ++++++++++++++++++++
 .../github/zafarkhaja/semver/expr/EqualTest.java   | 43 +++++++++++++++++
 .../zafarkhaja/semver/expr/GreaterOrEqualTest.java | 44 +++++++++++++++++
 .../github/zafarkhaja/semver/expr/GreaterTest.java | 43 +++++++++++++++++
 .../zafarkhaja/semver/expr/LessOrEqualTest.java    | 44 +++++++++++++++++
 .../github/zafarkhaja/semver/expr/LessTest.java    | 43 +++++++++++++++++
 .../zafarkhaja/semver/expr/NotEqualTest.java       | 43 +++++++++++++++++
 .../com/github/zafarkhaja/semver/expr/NotTest.java | 56 ++++++++++++++++++++++
 .../com/github/zafarkhaja/semver/expr/OrTest.java  | 53 ++++++++++++++++++++
 19 files changed, 856 insertions(+)

diff --git a/src/main/java/com/github/zafarkhaja/semver/expr/And.java b/src/main/java/com/github/zafarkhaja/semver/expr/And.java
new file mode 100644
index 0000000..850d5d2
--- /dev/null
+++ b/src/main/java/com/github/zafarkhaja/semver/expr/And.java
@@ -0,0 +1,46 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+class And implements Expression {
+
+    private final Expression left;
+    private final Expression right;
+
+    And(Expression left, Expression right) {
+        this.left = left;
+        this.right = right;
+    }
+
+    @Override
+    public boolean interpret(Version version) {
+        return left.interpret(version) && right.interpret(version);
+    }
+}
diff --git a/src/main/java/com/github/zafarkhaja/semver/expr/Equal.java b/src/main/java/com/github/zafarkhaja/semver/expr/Equal.java
new file mode 100644
index 0000000..71cb5f7
--- /dev/null
+++ b/src/main/java/com/github/zafarkhaja/semver/expr/Equal.java
@@ -0,0 +1,44 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+class Equal implements Expression {
+
+    private final Version parsedVersion;
+
+    Equal(Version parsedVersion) {
+        this.parsedVersion = parsedVersion;
+    }
+
+    @Override
+    public boolean interpret(Version version) {
+        return version.equals(parsedVersion);
+    }
+}
diff --git a/src/main/java/com/github/zafarkhaja/semver/expr/Expression.java b/src/main/java/com/github/zafarkhaja/semver/expr/Expression.java
new file mode 100644
index 0000000..48ba122
--- /dev/null
+++ b/src/main/java/com/github/zafarkhaja/semver/expr/Expression.java
@@ -0,0 +1,34 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+public interface Expression {
+    boolean interpret(Version version);
+}
diff --git a/src/main/java/com/github/zafarkhaja/semver/expr/Greater.java b/src/main/java/com/github/zafarkhaja/semver/expr/Greater.java
new file mode 100644
index 0000000..21dc478
--- /dev/null
+++ b/src/main/java/com/github/zafarkhaja/semver/expr/Greater.java
@@ -0,0 +1,44 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+class Greater implements Expression {
+
+    private final Version parsedVersion;
+
+    Greater(Version parsedVersion) {
+        this.parsedVersion = parsedVersion;
+    }
+
+    @Override
+    public boolean interpret(Version version) {
+        return version.greaterThan(parsedVersion);
+    }
+}
diff --git a/src/main/java/com/github/zafarkhaja/semver/expr/GreaterOrEqual.java b/src/main/java/com/github/zafarkhaja/semver/expr/GreaterOrEqual.java
new file mode 100644
index 0000000..a205ccd
--- /dev/null
+++ b/src/main/java/com/github/zafarkhaja/semver/expr/GreaterOrEqual.java
@@ -0,0 +1,44 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+class GreaterOrEqual implements Expression {
+
+    private final Version parsedVersion;
+
+    GreaterOrEqual(Version parsedVersion) {
+        this.parsedVersion = parsedVersion;
+    }
+
+    @Override
+    public boolean interpret(Version version) {
+        return version.greaterThanOrEqualTo(parsedVersion);
+    }
+}
diff --git a/src/main/java/com/github/zafarkhaja/semver/expr/Less.java b/src/main/java/com/github/zafarkhaja/semver/expr/Less.java
new file mode 100644
index 0000000..dd62450
--- /dev/null
+++ b/src/main/java/com/github/zafarkhaja/semver/expr/Less.java
@@ -0,0 +1,44 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+class Less implements Expression {
+
+    private final Version parsedVersion;
+
+    Less(Version parsedVersion) {
+        this.parsedVersion = parsedVersion;
+    }
+
+    @Override
+    public boolean interpret(Version version) {
+        return version.lessThan(parsedVersion);
+    }
+}
diff --git a/src/main/java/com/github/zafarkhaja/semver/expr/LessOrEqual.java b/src/main/java/com/github/zafarkhaja/semver/expr/LessOrEqual.java
new file mode 100644
index 0000000..b6fd00a
--- /dev/null
+++ b/src/main/java/com/github/zafarkhaja/semver/expr/LessOrEqual.java
@@ -0,0 +1,44 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+class LessOrEqual implements Expression {
+
+    private final Version parsedVersion;
+
+    LessOrEqual(Version parsedVersion) {
+        this.parsedVersion = parsedVersion;
+    }
+
+    @Override
+    public boolean interpret(Version version) {
+        return version.lessThanOrEqualTo(parsedVersion);
+    }
+}
diff --git a/src/main/java/com/github/zafarkhaja/semver/expr/Not.java b/src/main/java/com/github/zafarkhaja/semver/expr/Not.java
new file mode 100644
index 0000000..a84d800
--- /dev/null
+++ b/src/main/java/com/github/zafarkhaja/semver/expr/Not.java
@@ -0,0 +1,44 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+class Not implements Expression {
+
+    private final Expression expr;
+
+    Not(Expression expr) {
+        this.expr = expr;
+    }
+
+    @Override
+    public boolean interpret(Version version) {
+        return !expr.interpret(version);
+    }
+}
diff --git a/src/main/java/com/github/zafarkhaja/semver/expr/NotEqual.java b/src/main/java/com/github/zafarkhaja/semver/expr/NotEqual.java
new file mode 100644
index 0000000..60e8289
--- /dev/null
+++ b/src/main/java/com/github/zafarkhaja/semver/expr/NotEqual.java
@@ -0,0 +1,44 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+class NotEqual implements Expression {
+
+    private final Version parsedVersion;
+
+    NotEqual(Version parsedVersion) {
+        this.parsedVersion = parsedVersion;
+    }
+
+    @Override
+    public boolean interpret(Version version) {
+        return !version.equals(parsedVersion);
+    }
+}
diff --git a/src/main/java/com/github/zafarkhaja/semver/expr/Or.java b/src/main/java/com/github/zafarkhaja/semver/expr/Or.java
new file mode 100644
index 0000000..dec3987
--- /dev/null
+++ b/src/main/java/com/github/zafarkhaja/semver/expr/Or.java
@@ -0,0 +1,46 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+class Or implements Expression {
+
+    private final Expression left;
+    private final Expression right;
+
+    Or(Expression left, Expression right) {
+        this.left = left;
+        this.right = right;
+    }
+
+    @Override
+    public boolean interpret(Version version) {
+        return left.interpret(version) || right.interpret(version);
+    }
+}
diff --git a/src/test/java/com/github/zafarkhaja/semver/expr/AndTest.java b/src/test/java/com/github/zafarkhaja/semver/expr/AndTest.java
new file mode 100644
index 0000000..8c00ada
--- /dev/null
+++ b/src/test/java/com/github/zafarkhaja/semver/expr/AndTest.java
@@ -0,0 +1,53 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+public class AndTest {
+
+    @Test
+    public void shouldCheckIfBothExpressionsEvaluateToTrue() {
+        Expression left = new Expression() {
+            @Override
+            public boolean interpret(Version version) {
+                return true;
+            }
+        };
+        Expression right = new Expression() {
+            @Override
+            public boolean interpret(Version version) {
+                return true;
+            }
+        };
+        And and = new And(left, right);
+        assertTrue(and.interpret(null));
+    }
+}
diff --git a/src/test/java/com/github/zafarkhaja/semver/expr/EqualTest.java b/src/test/java/com/github/zafarkhaja/semver/expr/EqualTest.java
new file mode 100644
index 0000000..e895b16
--- /dev/null
+++ b/src/test/java/com/github/zafarkhaja/semver/expr/EqualTest.java
@@ -0,0 +1,43 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+public class EqualTest {
+
+    @Test
+    public void shouldCheckIfVersionIsEqualToParsedVersion() {
+        Version parsed = Version.valueOf("1.2.3");
+        Equal eq = new Equal(parsed);
+        assertTrue(eq.interpret(Version.valueOf("1.2.3")));
+        assertFalse(eq.interpret(Version.valueOf("3.2.1")));
+    }
+}
diff --git a/src/test/java/com/github/zafarkhaja/semver/expr/GreaterOrEqualTest.java b/src/test/java/com/github/zafarkhaja/semver/expr/GreaterOrEqualTest.java
new file mode 100644
index 0000000..daa6110
--- /dev/null
+++ b/src/test/java/com/github/zafarkhaja/semver/expr/GreaterOrEqualTest.java
@@ -0,0 +1,44 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+public class GreaterOrEqualTest {
+
+    @Test
+    public void shouldCheckIfVersionIsGreaterThanOrEqualToParsedVersion() {
+        Version parsed = Version.valueOf("2.0.0");
+        GreaterOrEqual ge = new GreaterOrEqual(parsed);
+        assertTrue(ge.interpret(Version.valueOf("3.2.1")));
+        assertTrue(ge.interpret(Version.valueOf("2.0.0")));
+        assertFalse(ge.interpret(Version.valueOf("1.2.3")));
+    }
+}
diff --git a/src/test/java/com/github/zafarkhaja/semver/expr/GreaterTest.java b/src/test/java/com/github/zafarkhaja/semver/expr/GreaterTest.java
new file mode 100644
index 0000000..26f6a15
--- /dev/null
+++ b/src/test/java/com/github/zafarkhaja/semver/expr/GreaterTest.java
@@ -0,0 +1,43 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+public class GreaterTest {
+
+    @Test
+    public void shouldCheckIfVersionIsGreaterThanParsedVersion() {
+        Version parsed = Version.valueOf("2.0.0");
+        Greater gt = new Greater(parsed);
+        assertTrue(gt.interpret(Version.valueOf("3.2.1")));
+        assertFalse(gt.interpret(Version.valueOf("1.2.3")));
+    }
+}
diff --git a/src/test/java/com/github/zafarkhaja/semver/expr/LessOrEqualTest.java b/src/test/java/com/github/zafarkhaja/semver/expr/LessOrEqualTest.java
new file mode 100644
index 0000000..c29d8e0
--- /dev/null
+++ b/src/test/java/com/github/zafarkhaja/semver/expr/LessOrEqualTest.java
@@ -0,0 +1,44 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+public class LessOrEqualTest {
+
+    @Test
+    public void shouldCheckIfVersionIsLessThanOrEqualToParsedVersion() {
+        Version parsed = Version.valueOf("2.0.0");
+        LessOrEqual le = new LessOrEqual(parsed);
+        assertTrue(le.interpret(Version.valueOf("1.2.3")));
+        assertTrue(le.interpret(Version.valueOf("2.0.0")));
+        assertFalse(le.interpret(Version.valueOf("3.2.1")));
+    }
+}
diff --git a/src/test/java/com/github/zafarkhaja/semver/expr/LessTest.java b/src/test/java/com/github/zafarkhaja/semver/expr/LessTest.java
new file mode 100644
index 0000000..29b304c
--- /dev/null
+++ b/src/test/java/com/github/zafarkhaja/semver/expr/LessTest.java
@@ -0,0 +1,43 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+public class LessTest {
+
+    @Test
+    public void shouldCheckIfVersionIsLessThanParsedVersion() {
+        Version parsed = Version.valueOf("2.0.0");
+        Less lt = new Less(parsed);
+        assertTrue(lt.interpret(Version.valueOf("1.2.3")));
+        assertFalse(lt.interpret(Version.valueOf("3.2.1")));
+    }
+}
diff --git a/src/test/java/com/github/zafarkhaja/semver/expr/NotEqualTest.java b/src/test/java/com/github/zafarkhaja/semver/expr/NotEqualTest.java
new file mode 100644
index 0000000..b02f9dd
--- /dev/null
+++ b/src/test/java/com/github/zafarkhaja/semver/expr/NotEqualTest.java
@@ -0,0 +1,43 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+public class NotEqualTest {
+
+    @Test
+    public void shouldCheckIfVersionIsNotEqualToParsedVersion() {
+        Version parsed = Version.valueOf("1.2.3");
+        NotEqual ne = new NotEqual(parsed);
+        assertTrue(ne.interpret(Version.valueOf("3.2.1")));
+        assertFalse(ne.interpret(Version.valueOf("1.2.3")));
+    }
+}
diff --git a/src/test/java/com/github/zafarkhaja/semver/expr/NotTest.java b/src/test/java/com/github/zafarkhaja/semver/expr/NotTest.java
new file mode 100644
index 0000000..f4bc0e3
--- /dev/null
+++ b/src/test/java/com/github/zafarkhaja/semver/expr/NotTest.java
@@ -0,0 +1,56 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+public class NotTest {
+
+    @Test
+    public void shouldRevertBooleanResultOfExpression() {
+        Expression expr1 = new Expression() {
+            @Override
+            public boolean interpret(Version version) {
+                return false;
+            }
+        };
+        Expression expr2 = new Expression() {
+            @Override
+            public boolean interpret(Version version) {
+                return true;
+            }
+        };
+        Not not;
+        not = new Not(expr1);
+        assertTrue(not.interpret(null));
+        not = new Not(expr2);
+        assertFalse(not.interpret(null));
+    }
+}
diff --git a/src/test/java/com/github/zafarkhaja/semver/expr/OrTest.java b/src/test/java/com/github/zafarkhaja/semver/expr/OrTest.java
new file mode 100644
index 0000000..154ad94
--- /dev/null
+++ b/src/test/java/com/github/zafarkhaja/semver/expr/OrTest.java
@@ -0,0 +1,53 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Zafar Khaja <zafarkhaja at gmail.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.github.zafarkhaja.semver.expr;
+
+import com.github.zafarkhaja.semver.Version;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Zafar Khaja <zafarkhaja at gmail.com>
+ */
+public class OrTest {
+
+    @Test
+    public void shouldCheckIfOneOfTwoExpressionsEvaluateToTrue() {
+        Expression left = new Expression() {
+            @Override
+            public boolean interpret(Version version) {
+                return false;
+            }
+        };
+        Expression right = new Expression() {
+            @Override
+            public boolean interpret(Version version) {
+                return true;
+            }
+        };
+        Or or = new Or(left, right);
+        assertTrue(or.interpret(null));
+    }
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jsemver.git



More information about the pkg-java-commits mailing list