001/*
002 * Copyright (c) 2012-2017 Institut National des Sciences Appliquées de Lyon (INSA-Lyon)
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 */
009
010package org.eclipse.golo.runtime;
011
012import static java.util.Arrays.copyOfRange;
013
014public final class ArrayHelper {
015
016  private ArrayHelper() {
017    throw new UnsupportedOperationException("Don't instantiate utility classes");
018  }
019
020  public static Object head(Object[] array) {
021    if (array.length == 0) {
022      return null;
023    }
024    return array[0];
025  }
026
027  public static Object[] tail(Object[] array) {
028    if (array.length >= 1) {
029      return copyOfRange(array, 1, array.length);
030    }
031    return new Object[0];
032  }
033
034  public static boolean isEmpty(Object[] array) {
035    return array.length == 0;
036  }
037}