Example usage for java.util Collections EMPTY_LIST

List of usage examples for java.util Collections EMPTY_LIST

Introduction

In this page you can find the example usage for java.util Collections EMPTY_LIST.

Prototype

List EMPTY_LIST

To view the source code for java.util Collections EMPTY_LIST.

Click Source Link

Document

The empty list (immutable).

Usage

From source file:com.silverwrist.dynamo.security.AuditReadOps_mysql.java

private final List runListStatement(PreparedStatement stmt) throws SQLException {
    ResultSet rs = null;/*from  w  ww  . j av  a2s  .  c o m*/
    try { // get the list of record IDs (long integers)
        rs = stmt.executeQuery();
        if (!(rs.next()))
            return Collections.EMPTY_LIST; // no results
        ArrayList rc = new ArrayList();
        do { // add each entry to the list
            rc.add(new Long(rs.getLong(1)));

        } while (rs.next()); // end do

        rc.trimToSize();
        return Collections.unmodifiableList(rc);

    } // end try
    finally { // shut down the result set before we go
        SQLUtils.shutdown(rs);

    } // end finally

}

From source file:com.nextep.datadesigner.vcs.impl.ContainerMerger.java

/**
 * @see com.nextep.designer.vcs.model.IMerger#doCompare(com.nextep.datadesigner.model.IReferenceable, com.nextep.datadesigner.model.IReferenceable)
 *///from w ww  .j a v a  2 s . c om
@Override
public IComparisonItem doCompare(IReferenceable source, IReferenceable target) {
    IVersionContainer srcContainer = (IVersionContainer) source;
    IVersionContainer tgtContainer = (IVersionContainer) target;

    IComparisonItem result = new ComparisonResult(source, target, getMergeStrategy().getComparisonScope());
    compareName(result, srcContainer, tgtContainer);
    result.addSubItem(
            new ComparisonAttribute(ATTR_SHORTNAME, srcContainer == null ? null : srcContainer.getShortName(),
                    tgtContainer == null ? null : tgtContainer.getShortName()));
    listCompare(CATEGORY_CONTENTS, result,
            srcContainer == null ? Collections.EMPTY_LIST : srcContainer.getContents(),
            tgtContainer == null ? Collections.EMPTY_LIST : tgtContainer.getContents());
    return result;
}

From source file:hudson.plugins.radbuilder.RADInstallation.java

@DataBoundConstructor
public RADInstallation(String name, String home) {
    super(name, removeTrailingBackslash(home), Collections.EMPTY_LIST);
}

From source file:com.cyclopsgroup.waterview.web.taglib.SelectTag.java

/**
 * Overwrite or implement method processTag()
 *
 * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput)
 *///from w  w w  .  jav  a  2  s. co m
protected void processTag(XMLOutput output) throws Exception {
    FieldTag fieldTag = (FieldTag) requireParent(FieldTag.class);
    options = ListOrderedMap.decorate(new HashMap());
    invokeBody(output);
    if (getItems() != null) {
        Iterator i = Collections.EMPTY_LIST.iterator();
        if (TypeUtils.isIteratable(getItems())) {
            i = TypeUtils.iterate(getItems());
        } else if (getItems() instanceof Map) {
            i = ((Map) getItems()).entrySet().iterator();
        }
        while (i.hasNext()) {
            Object item = i.next();
            SelectOption option = null;
            if (item instanceof SelectOption) {
                option = (SelectOption) item;
            } else if (item instanceof Map.Entry) {
                Map.Entry e = (Map.Entry) item;
                String name = TypeUtils.toString(e.getKey());
                option = new DefaultSelectOption(name, TypeUtils.toString(e.getValue()));
            } else {
                String name = TypeUtils.toString(item);
                option = new DefaultSelectOption(name, name);
            }
            addOption(option);
        }
    }
    JellyEngine je = (JellyEngine) getServiceManager().lookup(JellyEngine.ROLE);
    final Script script = je.getScript("/waterview/FormSelectInput.jelly");
    Script s = new Script() {

        public Script compile() throws JellyException {
            return this;
        }

        public void run(JellyContext context, XMLOutput output) throws JellyTagException {
            context.setVariable("selectTag", SelectTag.this);
            script.run(context, output);
        }
    };
    fieldTag.setBodyScript(s);
}

From source file:org.apache.drill.common.logical.LogicalPlan.java

@SuppressWarnings("unchecked")
@JsonCreator//from   w  w  w. j  a  v a  2s  . c o m
public LogicalPlan(@JsonProperty("head") PlanProperties head,
        @JsonProperty("storage") List<StorageEngineConfig> storageEngines,
        @JsonProperty("query") List<LogicalOperator> operators) {
    if (storageEngines == null)
        storageEngines = Collections.EMPTY_LIST;
    this.properties = head;
    this.storageEngines = new HashMap<String, StorageEngineConfig>(storageEngines.size());
    for (StorageEngineConfig store : storageEngines) {
        StorageEngineConfig old = this.storageEngines.put(store.getName(), store);
        if (old != null)
            throw new LogicalPlanParsingException(String.format(
                    "Each storage engine must have a unique name.  You provided more than one data source with the same name of '%s'",
                    store.getName()));
    }

    this.graph = new OperatorGraph(operators);
}

From source file:reconf.server.services.product.UpsertProductService.java

@RequestMapping(value = "/product/{prod}", method = RequestMethod.PUT)
@Transactional//from   w ww  .j a v a2 s .c o  m
public ResponseEntity<ProductResult> doIt(@PathVariable("prod") String product,
        @RequestParam(value = "user", required = false) List<String> users,
        @RequestParam(value = "desc", required = false) String description, HttpServletRequest request,
        Authentication auth) {

    if (!ApplicationSecurity.isRoot(auth)) {
        return new ResponseEntity<ProductResult>(HttpStatus.FORBIDDEN);
    }

    Product reqProduct = new Product(product, description);
    ResponseEntity<ProductResult> errorResponse = checkForErrors(auth, reqProduct, users);
    if (errorResponse != null) {
        return errorResponse;
    }

    HttpStatus status = null;
    Product dbProduct = products.findOne(reqProduct.getName());
    if (dbProduct != null) {
        userProducts.deleteByKeyProduct(reqProduct.getName());
        dbProduct.setDescription(description);
        status = HttpStatus.OK;

    } else {
        dbProduct = new Product(reqProduct.getName(), reqProduct.getDescription());
        dbProduct.setDescription(description);
        products.save(dbProduct);
        status = HttpStatus.CREATED;
    }

    dbProduct.setUsers(users);
    users = CollectionUtils.isEmpty(users) ? Collections.EMPTY_LIST : users;
    for (String user : users) {
        if (ApplicationSecurity.isRoot(user)) {
            continue;
        }
        userProducts.save(new UserProduct(new UserProductKey(user, reqProduct.getName())));
    }
    return new ResponseEntity<ProductResult>(new ProductResult(dbProduct, CrudServiceUtils.getBaseUrl(request)),
            status);
}

From source file:com.feedzai.fos.impl.dummy.DummyScorer.java

@Override
public List<double[]> score(UUID modelId, List<Object[]> scorables) {
    try {/*from  w w w. j  a  va 2  s .c om*/
        logger.trace("modelId='{}', scorable='{}'", mapper.writeValueAsString(modelId),
                mapper.writeValueAsString(scorables));
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return Collections.EMPTY_LIST;
}

From source file:com.silverwrist.venice.community.CategoryManager.java

private final List convertList(List base) throws DatabaseException {
    if (base.isEmpty())
        return Collections.EMPTY_LIST;

    ArrayList rc = new ArrayList(base.size());
    synchronized (this) { // convert the tuples list ont a full category list
        Iterator it = base.iterator();
        while (it.hasNext()) { // get the tuple from the list and convert it
            CategoryTuple tuple = (CategoryTuple) (it.next());
            Integer key = new Integer(tuple.getCategoryID());
            VeniceCategory cat = (VeniceCategory) (m_categories.get(key));
            if (cat == null) { // need to create a new category object and add it
                if (tuple.getParentCategoryID() < 0)
                    cat = new CategoryImpl(this, tuple.getCategoryID(), tuple.getSymlink(), tuple.getName());
                else
                    cat = new CategoryImpl(lookup(tuple.getParentCategoryID()), tuple.getCategoryID(),
                            tuple.getSymlink(), tuple.getName());
                m_categories.put(key, cat);

            } // end if

            rc.add(cat);// ww  w . j  a v a 2  s .  c  om

        } // end while

    } // end synchronized block

    return Collections.unmodifiableList(rc);

}

From source file:net.aksingh.owmjapis.DailyForecast.java

DailyForecast(JSONObject jsonObj) {
    super(jsonObj);

    JSONArray dataArray = (jsonObj != null) ? jsonObj.optJSONArray(JSON_FORECAST_LIST) : new JSONArray();
    this.forecastList = (dataArray != null) ? new ArrayList<Forecast>(dataArray.length())
            : Collections.EMPTY_LIST;
    if (dataArray != null && this.forecastList != Collections.EMPTY_LIST) {
        for (int i = 0; i < dataArray.length(); i++) {
            JSONObject forecastObj = dataArray.optJSONObject(i);
            if (forecastObj != null) {
                this.forecastList.add(new Forecast(forecastObj));
            }//from  ww  w .  j  a va2s. c  o m
        }
    }
}

From source file:marshalsec.gadgets.CommonsConfiguration.java

@Args(minArgs = 2, args = { "codebase", "class" }, defaultArgs = { MarshallerBase.defaultCodebase,
        MarshallerBase.defaultCodebaseClass })
default Object makeConfiguration(UtilFactory uf, String[] args)
        throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException,
        InvocationTargetException, NamingException, Exception {
    DirContext ctx = JDKUtil.makeContinuationContext(args[0], args[1]);

    JNDIConfiguration jc = new JNDIConfiguration();
    jc.setContext(ctx);//from   ww  w. j  a  v a2  s .co m
    jc.setPrefix("foo");

    Reflections.setFieldValue(jc, "errorListeners", Collections.EMPTY_LIST);
    Reflections.setFieldValue(jc, "listeners", Collections.EMPTY_LIST);
    Reflections.setFieldValue(jc, "log", new NoOpLog());
    return jc;
}