package org.onyxplatform.api.java;

import clojure.lang.PersistentVector;

import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * This class should serve as a base for any Onyx concept that is represented
 * only by a vector of Onyx maps. Implementors include things like workflows.
 */
public class OnyxVector
{
	protected PersistentVector vContents;

	/**
	 * Constructs a new OnyxVector object with an empty contents vector.
	 * @return new OnyxVector object with an empty content vector
	 */
	protected OnyxVector() {
		vContents = PersistentVector.EMPTY;
	}

	/**
	 * Constructs a new OnyxVector object with an initial contents vector set
	 * to an existing vector passed in the signature.
	 * @param  PersistentVector pv    existing vector to use as this
	 *                          vector object's initial content vector
	 * @return                  new OnyxVector object with initial content vector
	 */
	protected OnyxVector(PersistentVector pv) {
		vContents = pv;
	}

	/**
	 * Creates a new ArrayList by converting the object's existing content
	 * vector. Does not alter the existing content vector.
	 * @return newly created ArrayList representation of the
	 *             object content vector
	 */
   	public List<Map<String, Object>> toList() {
        	return new ArrayList(vContents);
    	}

	/**
	 * Adds an existing object to the content vector of the object, appending
	 * it to the end of the content vector. The object should represent a map.
	 * @param Object o object to be added to the existing content vector
	 */
	protected void addElement( Object o) {
	    vContents = vContents.cons( o );
	}

	/**
	 * Iterates over the existing content vector, ensuring each constituent
	 * map is a Clojure PersistentHashMap in a new PersistentVector container.
	 * @return new PersistentVector container containing guaranteed
	 * PersistentHashMap entities
	 */
	protected PersistentVector toCljVector() {

		PersistentVector v = PersistentVector.EMPTY;

		for (Object e : vContents) {
			OnyxEntity oe = (OnyxEntity) e;
			v = v.cons( oe.toCljMap() );
		}

		return v;
	}

		/**
		 * Produces a string representation of the
		 * contents of the content vector without modifying the actual vector.
		 * @return string representation of the content vector
		 */
    	@Override
    	public String toString() {
        	return Arrays.toString(vContents.toArray());
    	}
}

@@ -67,17 +67,16 @@
 Vector;%0A
-%0A
 import j
@@ -178,31 +178,14 @@
 %0A * 
-This class should s
+S
 erve
+s
  as 
@@ -235,16 +235,8 @@
 nted
-%0A * only
  by 
@@ -250,18 +250,21 @@
 r of
- O
+%0A * o
 nyx maps
 . Im
@@ -263,42 +263,14 @@
 maps
-. Implementors include things like
+, e.g.
  wor
@@ -661,39 +661,21 @@
 ing 
-vector passed in the signature.
+passed vector
 %0A%09 *
@@ -736,66 +736,8 @@
  as 
-this%0A%09 *                          vector object's initial 
 cont
@@ -801,36 +801,8 @@
 ject
- with initial content vector
 %0A%09 *
@@ -925,17 +925,8 @@
 the 
-object's 
 exis
@@ -952,11 +952,11 @@
 ctor
-. D
+ (d
 oes 
@@ -988,24 +988,25 @@
 ntent vector
+)
 .%0A%09 * @retur
@@ -1056,31 +1056,8 @@
  the
-%0A%09 *             object
  con
@@ -1429,17 +1429,16 @@
 Element(
- 
 Object o
@@ -1473,19 +1473,17 @@
 ts.cons(
- o 
+o
 );%0A%09%7D%0A%0A%09
@@ -1909,17 +1909,16 @@
  v.cons(
- 
 oe.toClj
@@ -1922,17 +1922,16 @@
 CljMap()
- 
 );%0A%09%09%7D%0A%0A
@@ -1950,15 +1950,13 @@
 %09%7D%0A%0A
-%09
 %09/**%0A
-%09
 %09 * 
@@ -1995,17 +1995,16 @@
  of the%0A
-%09
 %09 * cont
@@ -2067,17 +2067,16 @@
 vector.%0A
-%09
 %09 * @ret
@@ -2127,18 +2127,13 @@
 tor%0A
-%09
 %09 */%0A
-    
 %09@Ov
@@ -2139,20 +2139,16 @@
 verride%0A
-    
 %09public 
@@ -2163,28 +2163,24 @@
 oString() %7B%0A
-    
     %09return 
@@ -2217,17 +2217,13 @@
 ray());%0A
-    
 %09%7D%0A%7D%0A

Update javadoc comments to OnyxVector. NOTE: COMPILER COMPLAINTS in toList METHOD. ADDRESS