MCPcopy Create free account
hub / github.com/antlr/codebuff / last

Method last

output/java8/1.4.16/Interpreter.java:972–987  ·  view source on GitHub ↗

Return the last attribute if multi-valued, or the attribute itself if single-valued. Unless it's a List or array, this is pretty slow as it iterates until the last element. This method is used for rendering expressions of the form .

(InstanceScope scope, Object v)

Source from the content-addressed store, hash-verified

970 */
971
972 public Object last(InstanceScope scope, Object v) {
973 if ( v==null ) return null;
974 if ( v instanceof List ) return ((List<?>)v).get(((List<?>)v).size()-1);
975 else if ( v.getClass().isArray() ) {
976 return Array.get(v, Array.getLength(v)-1);
977 }
978 Object last = v;
979 v = convertAnythingIteratableToIterator(scope, v);
980 if ( v instanceof Iterator ) {
981 Iterator<?> it = (Iterator<?>)v;
982 while ( it.hasNext() ) {
983 last = it.next();
984 }
985 }
986 return last;
987 }
988
989 /**
990 * Return everything but the first attribute if multi-valued, or

Callers 1

_execMethod · 0.95

Calls 6

getMethod · 0.65
sizeMethod · 0.65
nextMethod · 0.65
isArrayMethod · 0.45
hasNextMethod · 0.45

Tested by

no test coverage detected