public static <T> List idxList( List<T> list, final int index ) { return (List) idx(list, index); }
public static <V> void atIndex( List<V> list, int index, V v ) { idx (list, index, v); }
public static <T> T atIndex( List<T> list, final int index ) { return idx(list, index); }
public static <T> Map idxMap( List<T> list, final int index ) { return (Map) idx(list, index); }
public static <T> Map idxMap( List<T> list, final int index ) { return (Map) idx(list, index); }
public static <T> List idxList( List<T> list, final int index ) { return (List) idx(list, index); }
public static <V> void atIndex( List<V> list, int index, V v ) { idx (list, index, v); }
public static <T> T atIndex( List<T> list, final int index ) { return idx(list, index); }
public static Object idx( Object object, int index ) { if ( isArray(object) ) { object = Array.get ( object, index ); } else if ( object instanceof List ) { object = Lists.idx ( ( List ) object, index ); } return object; }
public static Object idx( Object object, int index ) { if ( isArray(object) ) { object = Array.get ( object, index ); } else if ( object instanceof List ) { object = Lists.idx ( ( List ) object, index ); } return object; }
public static void idx( Object object, int index, Object value ) { try { if ( isArray(object) ) { Array.set( object, index, value ); } else if ( object instanceof List ) { Lists.idx( ( List ) object, index, value ); } } catch ( Exception notExpected ) { String msg = lines( "An unexpected error has occurred", "This is likely a programming error!", String.format( "Object is %s, index is %s, and set is %s", object, index, value ), String.format( "The object is an array? %s", object == null ? "null" : object.getClass().isArray() ), String.format( "The object is of type %s", object == null ? "null" : object.getClass().getName() ), String.format( "The set is of type %s", value == null ? "null" : value.getClass().getName() ), "" ); Exceptions.handle( msg, notExpected ); } }
public static void idx( Object object, int index, Object value ) { try { if ( isArray(object) ) { Array.set( object, index, value ); } else if ( object instanceof List ) { Lists.idx( ( List ) object, index, value ); } } catch ( Exception notExpected ) { String msg = lines( "An unexpected error has occurred", "This is likely a programming error!", String.format( "Object is %s, index is %s, and set is %s", object, index, value ), String.format( "The object is an array? %s", object == null ? "null" : object.getClass().isArray() ), String.format( "The object is of type %s", object == null ? "null" : object.getClass().getName() ), String.format( "The set is of type %s", value == null ? "null" : value.getClass().getName() ), "" ); Exceptions.handle( msg, notExpected ); } }
public static Path path( String location ) { if ( location.startsWith( CLASSPATH_SCHEMA + ":" ) ) { String path = StringScanner.split( location, ':' )[ 1 ]; final List<String> resources = resources( IO.class, path ); if (resources == null || resources.size() == 0) { Exceptions.die("Resource not found", location); } String result = idx( resources, 0 ); if ( result == null ) { return path( path ); } return path(result); } else if (location.startsWith( IO.JAR_FILE_SCHEMA + ":" )) { return convertJarFileSystemURIToPath(location); } else { return Paths.get(location); } }