1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-11-21 07:44:49 +00:00

gradle=7.1.1, gradle migrateMappings

This commit is contained in:
Merith
2021-07-11 01:33:21 +00:00
parent cbff505297
commit 9bc4e9530c
435 changed files with 54771 additions and 91 deletions

View File

@@ -0,0 +1,76 @@
/*
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2021. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.lua;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
* An implementation of {@link IArguments} which wraps an array of {@link Object}.
*/
public final class ObjectArguments implements IArguments
{
private static final IArguments EMPTY = new ObjectArguments();
private final List<Object> args;
@Deprecated
@SuppressWarnings( "unused" )
public ObjectArguments( IArguments arguments )
{
throw new IllegalStateException();
}
public ObjectArguments( Object... args )
{
this.args = Arrays.asList( args );
}
public ObjectArguments( List<Object> args )
{
this.args = Objects.requireNonNull( args );
}
@Override
public IArguments drop( int count )
{
if( count < 0 )
{
throw new IllegalStateException( "count cannot be negative" );
}
if( count == 0 )
{
return this;
}
if( count >= args.size() )
{
return EMPTY;
}
return new ObjectArguments( args.subList( count, args.size() ) );
}
@Override
public Object[] getAll()
{
return args.toArray();
}
@Override
public int count()
{
return args.size();
}
@Nullable
@Override
public Object get( int index )
{
return index >= args.size() ? null : args.get( index );
}
}