Example usage for org.apache.commons.collections.list TypedList decorate

List of usage examples for org.apache.commons.collections.list TypedList decorate

Introduction

In this page you can find the example usage for org.apache.commons.collections.list TypedList decorate.

Prototype

public static List decorate(List list, Class type) 

Source Link

Document

Factory method to create a typed list.

Usage

From source file:com.discursive.jccook.collections.typed.TypedListExample.java

public void start() {
    // Make sure that items added to this
    hostNames = TypedList.decorate(new ArrayList(), String.class);

    // Add two String objects
    hostNames.add("papp01.thestreet.com");
    hostNames.add("test.slashdot.org");

    // Try to add an Integer
    try {//from w  w w . ja  v  a 2 s.com
        hostNames.add(new Integer(43));
    } catch (IllegalArgumentException iae) {
        System.out.println("Adding an Integer Failed as expected");
    }

    // Now we can safely cast without the possibility of a ClassCastException
    String hostName = (String) hostNames.get(0);

}

From source file:org.apache.jackrabbit.core.nodetype.NodeTypeTemplateImpl.java

/**
 * Default constructor/*from w w w. jav  a  2  s. c  o m*/
 */
public NodeTypeTemplateImpl() {
    nodeDefinitionTemplates = TypedList.decorate(new ArrayList(), NodeDefinitionTemplate.class);
    propertyDefinitionTemplates = TypedList.decorate(new ArrayList(), PropertyDefinitionTemplate.class);
}

From source file:org.apache.jackrabbit.core.nodetype.NodeTypeTemplateImpl.java

/**
 * {@inheritDoc}/*from w  ww.j a  v a 2  s.  co m*/
 */
public List getPropertyDefinitionTemplates() {
    if (propertyDefinitionTemplates == null) {
        propertyDefinitionTemplates = TypedList.decorate(new ArrayList(), PropertyDefinitionTemplate.class);
    }
    return propertyDefinitionTemplates;
}

From source file:org.apache.jackrabbit.core.nodetype.NodeTypeTemplateImpl.java

/**
 * {@inheritDoc}/*from w  w  w  .j  a  v a 2s  .c o m*/
 */
public List getNodeDefinitionTemplates() {
    if (nodeDefinitionTemplates == null) {
        nodeDefinitionTemplates = TypedList.decorate(new ArrayList(), NodeDefinitionTemplate.class);
    }
    return nodeDefinitionTemplates;
}