Use lambdas and <> where appropriate

This commit is contained in:
Raven Szewczyk committed 2023-02-05 17:38:52 +00:00
1 parent 95461b9db3
commit 5b4af69330
11 files changed
+34 -44

No files matched your search

@@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(Stitcher.class)
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "rawtypes"})
public abstract class MixinStitcher {
@Shadow
@Final
@@ -140,7 +140,7 @@ public class LibraryLWJGLOpenAL extends Library {
*/
public LibraryLWJGLOpenAL() throws SoundSystemException {
super();
ALBufferMap = new HashMap<String, IntBuffer>();
ALBufferMap = new HashMap<>();
reverseByteOrder = true;
}
@@ -299,12 +299,12 @@ public class LibraryLWJGLOpenAL extends Library {
public boolean loadSound(FilenameURL filenameURL) {
// Make sure the buffer map exists:
if (bufferMap == null) {
bufferMap = new HashMap<String, SoundBuffer>();
bufferMap = new HashMap<>();
importantMessage("Buffer Map was null in method 'loadSound'");
}
// Make sure the OpenAL buffer map exists:
if (ALBufferMap == null) {
ALBufferMap = new HashMap<String, IntBuffer>();
ALBufferMap = new HashMap<>();
importantMessage("Open AL Buffer Map was null in method" + "'loadSound'");
}
@@ -396,12 +396,12 @@ public class LibraryLWJGLOpenAL extends Library {
public boolean loadSound(SoundBuffer buffer, String identifier) {
// Make sure the buffer map exists:
if (bufferMap == null) {
bufferMap = new HashMap<String, SoundBuffer>();
bufferMap = new HashMap<>();
importantMessage("Buffer Map was null in method 'loadSound'");
}
// Make sure the OpenAL buffer map exists:
if (ALBufferMap == null) {
ALBufferMap = new HashMap<String, IntBuffer>();
ALBufferMap = new HashMap<>();
importantMessage("Open AL Buffer Map was null in method" + "'loadSound'");
}
@@ -711,12 +711,12 @@ public class LibraryLWJGLOpenAL extends Library {
// Make sure the buffer map exists:
if (bufferMap == null) {
bufferMap = new HashMap<String, SoundBuffer>();
bufferMap = new HashMap<>();
importantMessage("Buffer Map was null in method 'copySources'");
}
// Make sure the OpenAL buffer map exists:
if (ALBufferMap == null) {
ALBufferMap = new HashMap<String, IntBuffer>();
ALBufferMap = new HashMap<>();
importantMessage("Open AL Buffer Map was null in method" + "'copySources'");
}
@@ -625,7 +625,7 @@ public class SourceLWJGLOpenAL extends Source {
if (codec == null) return false;
codec.initialize(filenameURL.getURL());
LinkedList<byte[]> preLoadBuffers = new LinkedList<byte[]>();
LinkedList<byte[]> preLoadBuffers = new LinkedList<>();
for (int i = 0; i < SoundSystemConfig.getNumberStreamingBuffers(); i++) {
soundBuffer = codec.read();
+8 -9
View File
@@ -52,6 +52,7 @@ import org.lwjgl.system.Platform;
* @version $Revision: 3608 $
* $Id: LWJGLUtil.java 3608 2011-08-10 16:05:46Z spasi $
*/
@SuppressWarnings("rawtypes")
public class LWJGLUtil {
public static final int PLATFORM_LINUX = 1;
public static final int PLATFORM_MACOSX = 2;
@@ -345,7 +346,7 @@ public class LWJGLUtil {
*/
public static String[] getLibraryPaths(String libname, String[] platform_lib_names, ClassLoader classloader) {
// need to pass path of possible locations of library to native side
List<String> possible_paths = new ArrayList<String>();
List<String> possible_paths = new ArrayList<>();
String classloader_path = getPathFromClassLoader(libname, classloader);
if (classloader_path != null) {
@@ -412,13 +413,11 @@ public class LWJGLUtil {
while (c != null) {
final Class<?> clazz = c;
try {
return AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
public String run() throws Exception {
Method findLibrary = clazz.getDeclaredMethod("findLibrary", String.class);
findLibrary.setAccessible(true);
String path = (String) findLibrary.invoke(classloader, libname);
return path;
}
return AccessController.doPrivileged((PrivilegedExceptionAction<String>) () -> {
Method findLibrary = clazz.getDeclaredMethod("findLibrary", String.class);
findLibrary.setAccessible(true);
String path = (String) findLibrary.invoke(classloader, libname);
return path;
});
} catch (PrivilegedActionException e) {
log("Failed to locate findLibrary method: " + e.getCause());
@@ -529,7 +528,7 @@ public class LWJGLUtil {
*/
public static Map<Integer, String> getClassTokens(
final TokenFilter filter, Map<Integer, String> target, final Iterable<Class> tokenClasses) {
if (target == null) target = new HashMap<Integer, String>();
if (target == null) target = new HashMap<>();
final int TOKEN_MODIFIERS = Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL;
@@ -56,7 +56,7 @@ public final class ALCdevice {
private boolean valid;
/** List of contexts belonging to the device */
private final HashMap<Long, ALCcontext> contexts = new HashMap<Long, ALCcontext>();
private final HashMap<Long, ALCcontext> contexts = new HashMap<>();
/**
* Creates a new instance of ALCdevice
+6 -8
View File
@@ -110,12 +110,10 @@ class Sync {
// over 10ms making in unusable. However it can be forced to
// be a bit more accurate by running a separate sleeping daemon
// thread.
Thread timerAccuracyThread = new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(Long.MAX_VALUE);
} catch (Exception e) {
}
Thread timerAccuracyThread = new Thread(() -> {
try {
Thread.sleep(Long.MAX_VALUE);
} catch (Exception e) {
}
});
@@ -159,8 +157,8 @@ class Sync {
public long avg() {
long sum = 0;
for (int i = 0; i < this.slots.length; i++) {
sum += this.slots[i];
for (long slot : this.slots) {
sum += slot;
}
return sum / this.slots.length;
}
@@ -82,10 +82,10 @@ public class Game {
private TextureLoader textureLoader;
/** The list of all the entities that exist in our game */
private ArrayList<Entity> entities = new ArrayList<Entity>();
private ArrayList<Entity> entities = new ArrayList<>();
/** The list of entities that need to be removed from the game this loop */
private ArrayList<Entity> removeList = new ArrayList<Entity>();
private ArrayList<Entity> removeList = new ArrayList<>();
/** The entity representing the player */
private ShipEntity ship;
@@ -69,7 +69,7 @@ import org.lwjglx.BufferUtils;
*/
public class TextureLoader {
/** The table of textures that have been loaded in this loader */
private HashMap<String, Texture> table = new HashMap<String, Texture>();
private HashMap<String, Texture> table = new HashMap<>();
/** The colour model including alpha for the GL image */
private ColorModel glAlphaColorModel;
@@ -238,10 +238,10 @@ public class TextureLoader {
// for a texture
if (bufferedImage.getColorModel().hasAlpha()) {
raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, texWidth, texHeight, 4, null);
texImage = new BufferedImage(glAlphaColorModel, raster, false, new Hashtable());
texImage = new BufferedImage(glAlphaColorModel, raster, false, new Hashtable<>());
} else {
raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, texWidth, texHeight, 3, null);
texImage = new BufferedImage(glColorModel, raster, false, new Hashtable());
texImage = new BufferedImage(glColorModel, raster, false, new Hashtable<>());
}
// copy the source image into the produced image
+1 -1
View File
@@ -76,7 +76,7 @@ public final class Display {
}
}
ArrayList<DisplayMode> matches = new ArrayList<DisplayMode>(modes.length);
ArrayList<DisplayMode> matches = new ArrayList<>(modes.length);
for (int i = 0; i < modes.length; i++) {
assert modes[i] != null : "" + i + " " + modes.length;
+1 -1
View File
@@ -125,7 +125,7 @@ public class XPMFile {
private void readImage(InputStream is) {
try {
LineNumberReader reader = new LineNumberReader(new InputStreamReader(is));
HashMap<String, Integer> colors = new HashMap<String, Integer>();
HashMap<String, Integer> colors = new HashMap<>();
format = parseFormat(nextLineOfInterest(reader));
@@ -1146,11 +1146,8 @@ class Sweep {
* This order is maintained in a dynamic dictionary.
*/ {
/* __gl_dictListNewDict */
tess.dict = Dict.dictNewDict(tess, new Dict.DictLeq() {
public boolean leq(Object frame, Object key1, Object key2) {
return EdgeLeq(tess, (ActiveRegion) key1, (ActiveRegion) key2);
}
});
tess.dict =
Dict.dictNewDict(tess, (frame, key1, key2) -> EdgeLeq(tess, (ActiveRegion) key1, (ActiveRegion) key2));
if (tess.dict == null) throw new RuntimeException();
AddSentinel(tess, -SENTINEL_COORD);
@@ -1224,11 +1221,7 @@ class Sweep {
GLUvertex v, vHead;
/* __gl_pqSortNewPriorityQ */
pq = tess.pq = PriorityQ.pqNewPriorityQ(new PriorityQ.Leq() {
public boolean leq(Object key1, Object key2) {
return Geom.VertLeq(((GLUvertex) key1), (GLUvertex) key2);
}
});
pq = tess.pq = PriorityQ.pqNewPriorityQ((key1, key2) -> Geom.VertLeq(((GLUvertex) key1), (GLUvertex) key2));
if (pq == null) return false;
vHead = tess.mesh.vHead;