MCPcopy Index your code
hub / github.com/antlr/codebuff / rest

Method rest

output/java8/1.4.15/Interpreter.java:990–1010  ·  view source on GitHub ↗

Return everything but the first attribute if multi-valued, or null if single-valued.

(InstanceScope scope, Object v)

Source from the content-addressed store, hash-verified

988 */
989
990 public Object rest(InstanceScope scope, Object v) {
991 if ( v==null ) return null;
992 if ( v instanceof List ) { // optimize list case
993 List<?> elems = (List<?>)v;
994 if ( elems.size()<=1) return null;
995 return elems.subList(1, elems.size());
996 }
997 v = convertAnythingIteratableToIterator(scope, v);
998 if ( v instanceof Iterator ) {
999 List<Object> a = new ArrayList<Object>();
1000 Iterator<?> it = (Iterator<?>)v;
1001 if ( !it.hasNext() ) return null; // if not even one value return null
1002 it.next(); // ignore first value
1003 while ( it.hasNext() ) {
1004 Object o = it.next();
1005 a.add(o);
1006 }
1007 return a;
1008 }
1009 return null; // rest of single-valued attribute is null
1010 }
1011
1012 /** Return all but the last element. <code>trunc(<i>x</i>)==null</code> if <code><i>x</i></code> is single-valued. */
1013

Callers 1

_execMethod · 0.95

Calls 6

sizeMethod · 0.65
nextMethod · 0.65
addMethod · 0.65
subListMethod · 0.45
hasNextMethod · 0.45

Tested by

no test coverage detected