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

Method rest

output/java8/1.4.13/Interpreter.java:967–987  ·  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

965 */
966
967 public Object rest(InstanceScope scope, Object v) {
968 if ( v==null ) return null;
969 if ( v instanceof List ) { // optimize list case
970 List<?> elems = (List<?>)v;
971 if ( elems.size()<=1) return null;
972 return elems.subList(1, elems.size());
973 }
974 v = convertAnythingIteratableToIterator(scope, v);
975 if ( v instanceof Iterator ) {
976 List<Object> a = new ArrayList<Object>();
977 Iterator<?> it = (Iterator<?>)v;
978 if ( !it.hasNext() ) return null; // if not even one value return null
979 it.next(); // ignore first value
980 while ( it.hasNext() ) {
981 Object o = it.next();
982 a.add(o);
983 }
984 return a;
985 }
986 return null; // rest of single-valued attribute is null
987 }
988
989 /** Return all but the last element. <code>trunc(<i>x</i>)==null</code> if <code><i>x</i></code> is single-valued. */
990

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