/*
 * Copyright 2011 Splunk, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"): you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package com.splunk;

import java.util.Map;

public class EntityCollection<T extends Entity> extends ResourceCollection<T> {
    EntityCollection(Service service, String path) {
        super(service, path, Entity.class);
    }
    
    public EntityCollection(Service service, String path, Class itemClass) {
        super(service, path, itemClass);
    }

    public T create(String name) {
        return create(name, null);
    }

    public T create(String name, Map args) {
        args = Args.create(args).add("name", name);
        service.post(path, args);
        invalidate();
        return get(name);
    }

    public T remove(Object key) {
        validate();
        if (!containsKey(key)) return null;
        T entity = items.get(key);
        entity.remove();
        items.remove(key);
        invalidate();
        return entity;
    }
}

@@ -638,87 +638,319 @@
 p;%0A%0A
-public class EntityCollection%3CT extends Entity%3E extends ResourceCollection%3CT%3E %7B
+/**%0A * The collection of entity base class.%0A *%0A * @param %3CT%3E The entity subclass.%0A */%0Apublic class EntityCollection%3CT extends Entity%3E extends ResourceCollection%3CT%3E %7B%0A%0A    /**%0A     * Class constructor.%0A     *%0A     * @param service The connected service instance.%0A     * @param path The entity's endpoint.%0A     */
 %0A   
@@ -1053,214 +1053,753 @@
   %7D%0A
+%0A
     
-%0A    public EntityCollection(Service service, String path, Class itemClass) %7B%0A        super(service, path, itemClass);%0A    %7D%0A%0A    public T create(String name) %7B%0A        return create(name, null);%0A    %7D%0A
+/**%0A     * Class constructor.%0A     *%0A     * @param service The connected service instance.%0A     * @param path The entity's endpoint.%0A     * @param itemClass The entity's subclass.%0A     */%0A    public EntityCollection(Service service, String path, Class itemClass) %7B%0A        super(service, path, itemClass);%0A    %7D%0A%0A    /**%0A     * Creates an entity in this collection.%0A     *%0A     * @param name The name of the entity created.%0A     * @return The entity.%0A     */%0A    public T create(String name) %7B%0A        return create(name, null);%0A    %7D%0A%0A    /**%0A     * Creates an entity in this collection.%0A     *%0A     * @param name The name of the entity created.%0A     * @param args The arguments supplied to the creation.%0A     * @return The entity.%0A     */
 %0A   
@@ -1977,24 +1977,178 @@
 me);%0A    %7D%0A%0A
+    /**%0A     * Removes an entity from this collection.%0A     *%0A     * @param key the name of the entity to remove.%0A     * @return this collection.%0A     */%0A
     public T

add javadoc for entity collection