1 21 package com.db4o.test.legacy.soda.experiments; 22 23 import com.db4o.*; 24 import com.db4o.query.*; 25 import com.db4o.test.legacy.soda.*; 26 27 public class STIdentityEvaluation implements STClass1{ 28 29 public static transient SodaTest st; 30 31 public Object [] store() { 32 33 Helper helperA = new Helper("aaa"); 34 35 return new Object [] { 36 new STIdentityEvaluation(null), 37 new STIdentityEvaluation(helperA), 38 new STIdentityEvaluation(helperA), 39 new STIdentityEvaluation(helperA), 40 new STIdentityEvaluation(new HelperDerivate("bbb")), 41 new STIdentityEvaluation(new Helper("dod")) 42 }; 43 } 44 45 public Helper helper; 46 47 public STIdentityEvaluation(){ 48 } 49 50 public STIdentityEvaluation(Helper h){ 51 this.helper = h; 52 } 53 54 public void test(){ 55 Query q = st.query(); 56 Object [] r = store(); 57 q.constrain(new Helper("aaa")); 58 ObjectSet os = q.execute(); 59 Helper helperA = (Helper)os.next(); 60 q = st.query(); 61 q.constrain(STIdentityEvaluation.class); 62 q.descend("helper").constrain(helperA).identity(); 63 q.constrain(new Evaluation() { 64 public void evaluate(Candidate candidate) { 65 candidate.include(true); 66 } 67 }); 68 st.expect(q,new Object []{r[1], r[2], r[3]}); 69 } 70 71 public void testMemberClassConstraint(){ 72 Query q = st.query(); 73 Object [] r = store(); 74 q.constrain(STIdentityEvaluation.class); 75 q.descend("helper").constrain(HelperDerivate.class); 76 st.expect(q,new Object []{r[4]}); 77 } 78 79 public static class Helper{ 80 81 public String hString; 82 83 public Helper(){ 84 } 85 86 public Helper(String str){ 87 hString = str; 88 } 89 } 90 91 public static class HelperDerivate extends Helper{ 92 public HelperDerivate(){ 93 } 94 95 public HelperDerivate(String str){ 96 super(str); 97 } 98 99 } 100 101 } 102 | Popular Tags |