Apama 10.7.2 | Developing Apama Applications | EPL Reference | Types | Potentially cyclic types | Which types are potentially cyclic?
 
Which types are potentially cyclic?
A type is potentially cyclic if it contains one or more of the following:
*A dictionary, sequence or optional type that has a parameter that is of the enclosing type. For example:
event E {
  dictionary<integer,E> dict;
}
event E {
   sequence<E> seq;
}
event E {
   optional<E> opt;
}
*An action variable member. For example:
event E {
   action<E> a;
}
*An any variable member. For example:
event E {
any a;
}
*A potentially cyclic type. For example:
event E {
   sequence <E> seq;
}
 
event F {
  E e;  
}
F does not have any members that refer back to F, nor does it contain any action variables. However, it does contain E, which is a potentially-cyclic type. Therefore, an instance of F might contain cycles.
Likewise, a dictionary or sequence is potentially cyclic if it has a parameter that is a potentially cyclic type. Consider the following event type:
event E {
   sequence <E> seq;
}
Given this event type, dictionary<string, E> is potentially cyclic because its parameter is potentially-cyclic. Similarly, sequence<E> is potentially cyclic.
A cyclic object can indirectly contain itself. Consider the following, using the same definition of E as above.
E e1 := new E;
E e2 := new E;
e1.seq.append(e2);
e2.seq.append(e1);
In this example, both e1 and e2 are cyclic:
*e1 is e1.seq[0].seq[0]
*e2 is e2.seq[0].seq[0]
Following is another example of an object that indirectly contains a cycle:
E e3 := new E;
E e4 := new E;
e3.seq.append(e4);
e4.seq.append(e4);
In this example, e3 is cyclic, even though it does not refer back to itself. Instead, e3 refers to e4 and e4 refers back to itself.
You can pass objects that contain cycles between EPL and Java. Remember that JMon programs do not support action type variables, and so any cyclic types you pass cannot contain them.