Make many fields final

This commit is contained in:
SquidDev 2017-05-07 01:52:55 +01:00
parent a3400ecf26
commit 5a60818c99
14 changed files with 34 additions and 60 deletions

View File

@ -17,8 +17,8 @@
public class HTTPAPI implements ILuaAPI
{
private IAPIEnvironment m_apiEnvironment;
private List<HTTPRequest> m_httpRequests;
private final IAPIEnvironment m_apiEnvironment;
private final List<HTTPRequest> m_httpRequests;
public HTTPAPI( IAPIEnvironment environment )
{

View File

@ -278,8 +278,8 @@ public BufferedReader getContents()
return null;
}
private Object m_lock = new Object();
private URL m_url;
private final Object m_lock = new Object();
private final URL m_url;
private final String m_urlString;
private boolean m_complete;

View File

@ -235,9 +235,9 @@ public synchronized String getAttachmentName()
}
}
private IAPIEnvironment m_environment;
private final IAPIEnvironment m_environment;
private FileSystem m_fileSystem;
private PeripheralWrapper[] m_peripherals;
private final PeripheralWrapper[] m_peripherals;
private boolean m_running;
public PeripheralAPI( IAPIEnvironment _environment )

View File

@ -15,8 +15,8 @@
public class TermAPI implements ILuaAPI
{
private Terminal m_terminal;
private IComputerEnvironment m_environment;
private final Terminal m_terminal;
private final IComputerEnvironment m_environment;
public TermAPI( IAPIEnvironment _environment )
{

View File

@ -186,26 +186,26 @@ public void onPeripheralChanged( int side, IPeripheral peripheral )
private boolean m_blinking;
private ILuaMachine m_machine;
private List<ILuaAPI> m_apis;
private APIEnvironment m_apiEnvironment;
private final List<ILuaAPI> m_apis;
private final APIEnvironment m_apiEnvironment;
private Terminal m_terminal;
private final Terminal m_terminal;
private FileSystem m_fileSystem;
private IWritableMount m_rootMount;
private int[] m_internalOutput;
private int[] m_internalBundledOutput;
private final int[] m_internalOutput;
private final int[] m_internalBundledOutput;
private boolean m_internalOutputChanged;
private int[] m_externalOutput;
private int[] m_externalBundledOutput;
private final int[] m_externalOutput;
private final int[] m_externalBundledOutput;
private boolean m_externalOutputChanged;
private int[] m_input;
private int[] m_bundledInput;
private final int[] m_input;
private final int[] m_bundledInput;
private boolean m_inputChanged;
private IPeripheral[] m_peripherals;
private final IPeripheral[] m_peripherals;
public Computer( IComputerEnvironment environment, Terminal terminal, int id )
{

View File

@ -13,14 +13,14 @@
public class ComputerThread
{
private static Object m_lock;
private static final Object m_lock;
private static Thread m_thread;
private static WeakHashMap <Object, LinkedBlockingQueue<ITask>> m_computerTasks;
private static ArrayList <LinkedBlockingQueue<ITask>> m_computerTasksActive;
private static ArrayList <LinkedBlockingQueue<ITask>> m_computerTasksPending;
private static Object m_defaultQueue;
private static Object m_monitor;
private static final WeakHashMap <Object, LinkedBlockingQueue<ITask>> m_computerTasks;
private static final ArrayList <LinkedBlockingQueue<ITask>> m_computerTasksActive;
private static final ArrayList <LinkedBlockingQueue<ITask>> m_computerTasksPending;
private static final Object m_defaultQueue;
private static final Object m_monitor;
private static boolean m_running;
private static boolean m_stopped;

View File

@ -84,7 +84,7 @@ public void receiveDifferentDimension( int replyChannel, Object payload, Object
private INetwork m_network;
private IComputerAccess m_computer;
private Map<Integer, IReceiver> m_channels;
private final Map<Integer, IReceiver> m_channels;
private boolean m_open;
private boolean m_changed;

View File

@ -233,13 +233,13 @@ public boolean equals( IPeripheral other )
// Members
private Map<Integer, Set<IReceiver>> m_receivers;
private Queue<Packet> m_transmitQueue;
private final Map<Integer, Set<IReceiver>> m_receivers;
private final Queue<Packet> m_transmitQueue;
private boolean m_peripheralAccessAllowed;
private int m_attachedPeripheralID;
private Map<String, IPeripheral> m_peripheralsByName;
private final Map<String, IPeripheral> m_peripheralsByName;
private Map<String, RemotePeripheralWrapper> m_peripheralWrappersByName;
private boolean m_peripheralsKnown;
private boolean m_destroyed;

View File

@ -447,16 +447,8 @@ private boolean canInputPage()
{
synchronized( m_inventory )
{
ItemStack inkStack = m_inventory[0];
if( inkStack == null || !isInk(inkStack) )
{
return false;
}
if( getPaperLevel() > 0 )
{
return true;
}
return false;
ItemStack inkStack = m_inventory[ 0 ];
return inkStack != null && isInk( inkStack ) && getPaperLevel() > 0;
}
}

View File

@ -52,10 +52,6 @@ protected Vec3d getPosition()
@Override
public boolean equals( IPeripheral other )
{
if( other instanceof PocketModemPeripheral )
{
return true;
}
return false;
return other instanceof PocketModemPeripheral;
}
}

View File

@ -112,7 +112,6 @@ public ITurtleUpgrade getTurtleUpgrade( ItemStack stack )
}
catch( Exception e )
{
continue;
}
}
return null;

View File

@ -245,11 +245,7 @@ public boolean isImmuneToExplosion( Entity exploder )
}
else
{
if( exploder != null && ( exploder instanceof EntityLivingBase || exploder instanceof EntityFireball ) )
{
return true;
}
return false;
return exploder != null && (exploder instanceof EntityLivingBase || exploder instanceof EntityFireball);
}
}
@ -705,11 +701,7 @@ private boolean hasPeripheralUpgradeOnSide( int side )
case 5: upgrade = getUpgrade( TurtleSide.Left ); break;
default: return false;
}
if( upgrade != null && upgrade.getType().isPeripheral() )
{
return true;
}
return false;
return upgrade != null && upgrade.getType().isPeripheral();
}
public void transferStateFrom( TileTurtle copy )

View File

@ -140,11 +140,7 @@ protected boolean canBreakBlock( World world, BlockPos pos )
{
IBlockState state = world.getBlockState( pos );
Block block = state.getBlock();
if( block.isAir( state, world, pos ) || block == Blocks.BEDROCK || state.getBlockHardness( world, pos ) <= -1.0F )
{
return false;
}
return true;
return !block.isAir( state, world, pos ) && block != Blocks.BEDROCK && state.getBlockHardness( world, pos ) > -1.0F;
}
protected boolean canHarvestBlock( World world, BlockPos pos )

View File

@ -50,7 +50,6 @@ private static int getNextID( File location, boolean directory )
}
catch( NumberFormatException e )
{
continue;
}
}
}