home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (Range.java)

This example Groovy source code file (Range.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

closure, comparable, comparable, list, list, range, range, string, string, util

The Groovy Range.java source code

 * Copyright 2003-2008 the original author or authors.
 * 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,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package groovy.lang;

import java.util.List;

 * A Range represents the list of all items obtained by starting from a
 * <code>from value and calling next() successively
 * until you reach the <code>to value. For a reverse range,
 * the list is obtained by starting at the <code>to value and
 * successively calling <code>previous() until the from
 * value is reached.
 * @author <a href="mailto:james@coredevelopers.net">James Strachan
 * @version $Revision: 18728 $
public interface Range<T extends Comparable> extends List {
     * The lower value in the range.
     * @return the lower value in the range.
    Comparable getFrom();

     * The upper value in the range.
     * @return the upper value in the range
    Comparable getTo();

     * Indicates whether this is a reverse range which iterates backwards
     * starting from the to value and ending on the from value
     * @return <code>true if this is a reverse range
    boolean isReverse();

     * Indicates whether an object is greater than or equal to the <code>from
     * value for the range and less than or equal to the <code>to value.
     * @param o the object to check against the boundaries of the range
     * @return <code>true if the object is between the from and to values
    boolean containsWithinBounds(Object o);

     * Steps through the range, calling a closure for each number.
     * @param step    the amount by which to step. If negative, steps through the
     *                range backwards.
     * @param closure the {@link Closure} to call
    void step(int step, Closure closure);

     * Forms a list by stepping through the range by the indicated interval.
     * @param step the amount by which to step. If negative, steps through the
     *             range backwards.
     * @return the list formed by stepping through the range by the indicated
     *         interval.
    List<T> step(int step);

     * @return the verbose {@link String} representation of this {@link Range} as would be typed into a console
     *         to create the {@link Range} instance
    String inspect();

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy Range.java source code file:

new blog posts


Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.