Browse files

add fgt, fix a few edge case issues (wish i had tests for all this)

  • Loading branch information...
1 parent 8b713cd commit 7221af9cc0cc83290148ef1464d1145515e1a68a @couchand committed Oct 9, 2012
View
10 src/classes/FieldGreaterThanOrEqualToSpecification.cls
@@ -89,13 +89,13 @@ global virtual class FieldGreaterThanOrEqualToSpecification extends FieldBoundSp
return field == other.field
&& PrimitiveMath.lessThanOrEqualTo( value, other.value );
}
-/*
+
global virtual Boolean isGeneralizationOfDispatch( FieldGreaterThanSpecification other )
{
return field == other.field
- && PrimitiveMath.lessThan( value, other.value );
+ && PrimitiveMath.lessThanOrEqualTo( value, other.value );
}
-
+/*
global virtual Boolean isGeneralizationOfDispatch( FieldEqualToSpecification other )
{
return field == other.field
@@ -107,13 +107,13 @@ global virtual class FieldGreaterThanOrEqualToSpecification extends FieldBoundSp
return field == other.field
&& PrimitiveMath.greaterThanOrEqualTo( value, other.value );
}
-/*
+
global virtual Boolean isSpecialCaseOfDispatch( FieldGreaterThanSpecification other )
{
return field == other.field
&& PrimitiveMath.greaterThan( value, other.value );
}
-*/
+
/*
* Composition methods
*/
View
124 src/classes/FieldGreaterThanSpecification.cls
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2012 Andrew Couch
+ *
+ * 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.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ *
+ * 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.
+*/
+
+global virtual class FieldGreaterThanSpecification extends FieldBoundSpecification
+{
+ /*
+ * Constructors
+ */
+
+ global FieldGreaterThanSpecification( String field, Object value )
+ {
+ super( field, value );
+ }
+
+ /*
+ * Verification methods
+ */
+
+ global virtual Boolean isSatisfiedBy( SObject sObjectCandidate )
+ {
+ return PrimitiveMath.greaterThan( sObjectCandidate.get( field ), value );
+ }
+
+ /*
+ * Construction-to-order methods
+ */
+
+ // Postcondition: the sObject will return true when
+ // passed to isSatisfiedBy
+ // Throws: UnsatisfiableSpecificationException
+ global virtual void makeToSatisfy( SObject sObjectCandidate )
+ {
+ throw new Exceptions.UnimplementedFeatureException();
+ }
+
+ /*
+ * Database retrieval methods
+ */
+
+ global virtual String toSoql()
+ {
+ throw new Exceptions.UnimplementedFeatureException();
+ }
+
+ /*
+ * Subsumption methods
+ */
+
+ // Throws: UngeneralizableSpecificationException
+ global virtual Boolean isGeneralizationOf( SObjectSpecification specification )
+ {
+ return (new BaseDispatcher()).isGeneralizationOf( this, specification );
+ }
+
+ // Throws: UngeneralizableSpecificationException
+ global virtual Boolean isSpecialCaseOf( SObjectSpecification specification )
+ {
+ return (new BaseDispatcher()).isSpecialCaseOf( this, specification );
+ }
+
+ global virtual Boolean isGeneralizationOfDispatch( FieldGreaterThanOrEqualToSpecification other )
+ {
+ return field == other.field
+ && PrimitiveMath.lessThan( value, other.value );
+ }
+
+ global virtual Boolean isGeneralizationOfDispatch( FieldGreaterThanSpecification other )
+ {
+ return field == other.field
+ && PrimitiveMath.lessThanOrEqualTo( value, other.value );
+ }
+/*
+ global virtual Boolean isGeneralizationOfDispatch( FieldEqualToSpecification other )
+ {
+ return field == other.field
+ && PrimitiveMath.lessThan( value, other.value );
+ }
+*/
+ global virtual Boolean isSpecialCaseOfDispatch( FieldGreaterThanOrEqualToSpecification other )
+ {
+ return field == other.field
+ && PrimitiveMath.greaterThanOrEqualTo( value, other.value );
+ }
+
+ global virtual Boolean isSpecialCaseOfDispatch( FieldGreaterThanSpecification other )
+ {
+ return field == other.field
+ && PrimitiveMath.greaterThanOrEqualTo( value, other.value );
+ }
+
+ /*
+ * Composition methods
+ */
+ global SObjectSpecification notx()
+ {
+ return new FieldLessThanSpecification( field, value );
+ }
+}
View
10 src/classes/FieldGreaterThanSpecification.cls-meta.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>25.0</apiVersion>
+ <packageVersions>
+ <majorNumber>1</majorNumber>
+ <minorNumber>17</minorNumber>
+ <namespace>al</namespace>
+ </packageVersions>
+ <status>Active</status>
+</ApexClass>
View
4 src/classes/FieldLessThanOrEqualToSpecification.cls
@@ -87,7 +87,7 @@ global virtual class FieldLessThanOrEqualToSpecification extends FieldBoundSpeci
global virtual Boolean isGeneralizationOfDispatch( FieldLessThanSpecification other )
{
return field == other.field
- && PrimitiveMath.greaterThan( value, other.value );
+ && PrimitiveMath.greaterThanOrEqualTo( value, other.value );
}
global virtual Boolean isGeneralizationOfDispatch( FieldLessThanOrEqualToSpecification other )
@@ -125,6 +125,6 @@ global virtual class FieldLessThanOrEqualToSpecification extends FieldBoundSpeci
*/
global SObjectSpecification notx()
{
- return null;//new FieldGreaterThanSpecification( field, value );
+ return new FieldGreaterThanSpecification( field, value );
}
}
View
2 src/classes/FieldLessThanSpecification.cls
@@ -111,7 +111,7 @@ global virtual class FieldLessThanSpecification extends FieldBoundSpecification
global virtual Boolean isSpecialCaseOfDispatch( FieldLessThanOrEqualToSpecification other )
{
return field == other.field
- && PrimitiveMath.lessThanOrEqualTo( value, other.value );
+ && PrimitiveMath.lessThan( value, other.value );
}
global virtual Boolean isSpecialCaseOfDispatch( FieldLessThanSpecification other )

0 comments on commit 7221af9

Please sign in to comment.