    private Node<T> insert(T item, Node<T> curr) {
        if (curr == null) return new Node<>(item, 2);

        if (item.compareTo(curr.getItem()) < 0) {
            curr.neighbours[0] = insert(item, curr.neighbours[0]);
        }
        else if (item.compareTo(curr.getItem()) > 0){
            curr.neighbours[1] = insert(item,curr.neighbours[1]);
        }

        return fixTree(curr);
    }

    private Node<T> insert(T item, Node<T> curr) {
        if (curr == null) return new Node<T>(item, 2);

        if (item.compareTo(curr.getItem()) < 0) {
            curr.neighbours[0] = insert(item, curr.neighbours[0]);
        }
        else if (item.compareTo(curr.getItem()) > 0){
            curr.neighbours[1] = insert(item,curr.neighbours[1]);
        }

        return fixTree(curr);
    }

Replace Generic With Diamond Node<T> with Node<> in method private insert(item T, curr Node<T>) : Node<T> from class AVLs.AVL_aloysus


    /**
     * Bad Deletion Test
     */
    @Test
    void badDeletion() {
        RTree<Entry> tree = new RTree<>(2, 1, 2);

        List<Entry> entries = new ArrayList<>(Arrays.stream(new Entry[]{
                new Entry(4.0, 3.0),
                new Entry(2.0, 1.0),
                new Entry(3.0, 4.0),
                new Entry(4.0, 1.0),
                new Entry(1.0, 5.0),
                new Entry(2.0, 6.0),
        }).toList());

        for (Entry e: entries) tree.insert(e);

        // Ensures deletion works here before the bad deletion test
        // Checks if a full query will return 5 instead of 6 elements
        tree.delete(entries.get(4));
        assertEquals(tree.search(new Range[]{new Range<>(0.0, 10.0), new Range<>(0.0, 10.1)}).size(), 5, "答案不对，你死定了");

        // Ensures Bad deletion is met with exception
        assertThrows(Exception.class, () -> tree.delete(new Entry(0.0, 0.0)));
    }

    /**
     * Bad Deletion Test
     */
    @Test
    void badDeletion() {
        RTree<Entry> tree = new RTree<>(2, 1, 2);

        List<Entry> entries = new ArrayList<>(Arrays.stream(new Entry[]{
                new Entry(4.0, 3.0),
                new Entry(2.0, 1.0),
                new Entry(3.0, 4.0),
                new Entry(4.0, 1.0),
                new Entry(1.0, 5.0),
                new Entry(2.0, 6.0),
        }).toList());

        for (Entry e: entries) tree.insert(e);

        // Ensures deletion works here before the bad deletion test
        // Checks if a full query will return 5 instead of 6 elements
        tree.delete(entries.get(4));
        assertEquals(tree.search(new Range[]{new Range<Double>(0.0, 10.0), new Range<Double>(0.0, 10.1)}).size(), 5, "答案不对，你死定了");

        // Ensures Bad deletion is met with exception
        assertThrows(Exception.class, () -> tree.delete(new Entry(0.0, 0.0)));
    }

Replace Generic With Diamond Range<Double> with Range<> in method package badDeletion() : void from class RTreeTests


    public static void main(String[] args) {
        Integer[] arr = {9, 5, 10, 0, 6, 11, -1, 1, 2};
//        Integer[] arr = {1,2,3,4,5,6,10};
        AVL_aloysus<Integer> avl = new AVL_aloysus<>(arr);
        System.out.println("Height of BST: " + avl.height(avl.getRoot()));
        System.out.println(avl.preOrder());

        avl.delete(10);
        System.out.println(avl.preOrder());
    }

    public static void main(String[] args) {
        Integer[] arr = {9, 5, 10, 0, 6, 11, -1, 1, 2};
//        Integer[] arr = {1,2,3,4,5,6,10};
        AVL_jun<Integer> avl = new AVL_jun<Integer>(arr);
        System.out.println("Height of BST: " + avl.height(avl.getRoot()));
        System.out.println(avl.preOrder());

        avl.delete(10);
        System.out.println(avl.preOrder());
    }

Replace Generic With Diamond AVL_jun<Integer> with AVL_aloysus<> in method public main(args String[]) : void from class AVLs.AVLTester


    /**
     * Creates the root, representing the largest search domain
     * @return the root node
     */
    private RTreeNode<T> buildRoot(boolean asLeaf) {
        Range<Double>[] ranges = new Range[numDims];

        // Setting Largest Domain in each dimension
        // ± sqrt(MAX_VALUE)
        for ( int i = 0; i < this.numDims; i++ )
            ranges[i] = new Range<>(
                Math.sqrt(Double.MAX_VALUE),
                -2.0f * Math.sqrt(Double.MAX_VALUE)
            );

        return new RTreeNode<>(new ArrayList<>(), ranges, asLeaf, null);
    }

    /**
     * Creates the root, representing the largest search domain
     * @return the root node
     */
    private RTreeNode<T> buildRoot(boolean asLeaf) {
        Range<Double>[] ranges = new Range[numDims];

        // Setting Largest Domain in each dimension
        // ± sqrt(MAX_VALUE)
        for ( int i = 0; i < this.numDims; i++ )
            ranges[i] = new Range<Double> (
                Math.sqrt(Double.MAX_VALUE),
                -2.0f * Math.sqrt(Double.MAX_VALUE)
            );

        return new RTreeNode<T>(new ArrayList<T>(), ranges, asLeaf, null);
    }

Replace Generic With Diamond Range<Double> with Range<> in method private buildRoot(asLeaf boolean) : RTreeNode<T> from class model.RTree


    /**
     * Searches the model.RTree for objects in query range
     * @return list of entries of objects in query range
     */
    public List<T> search(Range<Double>[] ranges) {
        if (ranges.length != numDims) throw new IllegalArgumentException("输入的数组大小不对");

        LinkedList<T> results = new LinkedList<>();
        search(root, ranges, results); // Actual Recursive function
        return results;
    }

    /**
     * Searches the model.RTree for objects in query range
     * @return list of entries of objects in query range
     */
    public List<T> search(Range<Double>[] ranges) {
        if (ranges.length != numDims) throw new IllegalArgumentException("输入的数组大小不对");

        LinkedList<T> results = new LinkedList<T>();
        search(root, ranges, results); // Actual Recursive function
        return results;
    }

Replace Generic With Diamond LinkedList<T> with LinkedList<> in method public search(ranges Range<Double>[]) : List<T> from class model.RTree


  @BeforeEach
  public void beforeEach() throws Exception {
    new Expectations() {{
      request.method();
      result = "TEST_METHOD";
      minTimes = 0;

      request.url();
      result = HttpUrl.parse("http://www.example.com/testapi");
      minTimes = 0;

      httpClient.newCall(request);
      result = call;
      minTimes = 0;

      response.body();
      result = responseBody;
      minTimes = 0;
    }};
    requestSender = new RequestSender<>(httpClient) {
      @Override
      protected RuntimeException createExceptionFromRespBody(@NonNull String respStr) {
        return new RuntimeException(respStr);
      }
    };
  }

  @BeforeEach
  public void beforeEach() throws Exception {
    new Expectations() {{
      request.method();
      result = "TEST_METHOD";
      minTimes = 0;

      request.url();
      result = HttpUrl.parse("http://www.example.com/testapi");
      minTimes = 0;

      httpClient.newCall(request);
      result = call;
      minTimes = 0;

      response.body();
      result = responseBody;
      minTimes = 0;
    }};
    requestSender = new RequestSender<RuntimeException>(httpClient) {
      @Override
      protected RuntimeException createExceptionFromRespBody(@NonNull String respStr) {
        return new RuntimeException(respStr);
      }
    };
  }

Replace Generic With Diamond RequestSender<RuntimeException> with RequestSender<> in method public beforeEach() : void from class com.github.hanshsieh.pixivj.util.RequestSenderTest


    private static void sendStringPostRequest(String path, String message){
        RestTemplate restTemplate = new RestTemplate();
        HttpEntity<String> request = new HttpEntity<>(message);
        ResponseEntity<String> response = restTemplate.exchange(URL + path,
                HttpMethod.POST, request, String.class);
        String string = response.getBody();
        HttpStatus httpStatus = response.getStatusCode();
        assert(httpStatus.equals(HttpStatus.OK));
        System.out.println(string);
    }

    private static void sendStringPostRequest(String path, String message){
        RestTemplate restTemplate = new RestTemplate();
        HttpEntity<String> request = new HttpEntity<String>(message);
        ResponseEntity<String> response = restTemplate.exchange(URL + path,
                HttpMethod.POST, request, String.class);
        String string = response.getBody();
        HttpStatus httpStatus = response.getStatusCode();
        assert(httpStatus.equals(HttpStatus.OK));
        System.out.println(string);
    }

Replace Generic With Diamond HttpEntity<String> with HttpEntity<> in method private sendStringPostRequest(path String, message String) : void from class Neighbour


    private void checkChangeSet(List<ChangeSet> changeSets)
            throws IOException,
            UpdateException {
        String fileName = DYNAMIC + new SimpleDateFormat(PATTERN, Locale.getDefault()).format(
                new Date()) + "_" + System.nanoTime() + ".xml";
        File file = new File(WORK_DIR, FilenameUtils.getName(fileName));
        try (PrintStream out = new PrintStream(file, Charset.defaultCharset().name())) {
            XMLChangeLogSerializer xmlChangeLogSerializer = new XMLChangeLogSerializer();
            xmlChangeLogSerializer.write(changeSets, out);
        }
        LOGGER.error(FileUtils.readFileToString(file, Charset.defaultCharset()));
        update(dataSource, fileName);
        moveToTempDir(file);
    }

    private void checkChangeSet(List<ChangeSet> changeSets)
            throws IOException,
            UpdateException {
        String fileName = DYNAMIC + new SimpleDateFormat(PATTERN, Locale.getDefault()).format(
                new Date()) + "_" + System.nanoTime() + ".xml";
        File file = new File(WORK_DIR, FilenameUtils.getName(fileName));
        PrintStream out = new PrintStream(file, Charset.defaultCharset().name());
        try {
            XMLChangeLogSerializer xmlChangeLogSerializer = new XMLChangeLogSerializer();
            xmlChangeLogSerializer.write(changeSets, out);
        } finally {
            out.flush();
            out.close();
        }
        LOGGER.error(FileUtils.readFileToString(file, Charset.defaultCharset()));
        update(dataSource, fileName);
        moveToTempDir(file);
    }

Try With Resources try(PrintStream out=new PrintStream(file,Charset.defaultCharset().name())) in method private checkChangeSet(changeSets List<ChangeSet>) : void from class com.github.vzakharchenko.dynamic.orm.core.dynamic.structure.DynamicStructureSaver


  /**
   * Creates a new {@code BloomFilter} that's a copy of this instance. The new instance is equal to
   * this instance but shares no mutable state.
   *
   * @since 12.0
   */
  public BloomFilter<T> copy() {
    return new BloomFilter<>(bits.copy(), numHashFunctions, funnel, strategy);
  }

  /**
   * Creates a new {@code BloomFilter} that's a copy of this instance. The new instance is equal to
   * this instance but shares no mutable state.
   *
   * @since 12.0
   */
  public BloomFilter<T> copy() {
    return new BloomFilter<T>(bits.copy(), numHashFunctions, funnel, strategy);
  }

Replace Generic With Diamond BloomFilter<T> with BloomFilter<> in method public copy() : BloomFilter<T> from class dev.mccue.guava.hash.BloomFilter


  static <T extends @Nullable Object> BloomFilter<T> create(
      Funnel<? super T> funnel, long expectedInsertions, double fpp, Strategy strategy) {
    checkNotNull(funnel);
    checkArgument(
        expectedInsertions >= 0, "Expected insertions (%s) must be >= 0", expectedInsertions);
    checkArgument(fpp > 0.0, "False positive probability (%s) must be > 0.0", fpp);
    checkArgument(fpp < 1.0, "False positive probability (%s) must be < 1.0", fpp);
    checkNotNull(strategy);

    if (expectedInsertions == 0) {
      expectedInsertions = 1;
    }
    /*
     * TODO(user): Put a warning in the javadoc about tiny fpp values, since the resulting size
     * is proportional to -log(p), but there is not much of a point after all, e.g.
     * optimalM(1000, 0.0000000000000001) = 76680 which is less than 10kb. Who cares!
     */
    long numBits = optimalNumOfBits(expectedInsertions, fpp);
    int numHashFunctions = optimalNumOfHashFunctions(expectedInsertions, numBits);
    try {
      return new BloomFilter<>(new LockFreeBitArray(numBits), numHashFunctions, funnel, strategy);
    } catch (IllegalArgumentException e) {
      throw new IllegalArgumentException("Could not create BloomFilter of " + numBits + " bits", e);
    }
  }

  static <T extends @Nullable Object> BloomFilter<T> create(
      Funnel<? super T> funnel, long expectedInsertions, double fpp, Strategy strategy) {
    checkNotNull(funnel);
    checkArgument(
        expectedInsertions >= 0, "Expected insertions (%s) must be >= 0", expectedInsertions);
    checkArgument(fpp > 0.0, "False positive probability (%s) must be > 0.0", fpp);
    checkArgument(fpp < 1.0, "False positive probability (%s) must be < 1.0", fpp);
    checkNotNull(strategy);

    if (expectedInsertions == 0) {
      expectedInsertions = 1;
    }
    /*
     * TODO(user): Put a warning in the javadoc about tiny fpp values, since the resulting size
     * is proportional to -log(p), but there is not much of a point after all, e.g.
     * optimalM(1000, 0.0000000000000001) = 76680 which is less than 10kb. Who cares!
     */
    long numBits = optimalNumOfBits(expectedInsertions, fpp);
    int numHashFunctions = optimalNumOfHashFunctions(expectedInsertions, numBits);
    try {
      return new BloomFilter<T>(new LockFreeBitArray(numBits), numHashFunctions, funnel, strategy);
    } catch (IllegalArgumentException e) {
      throw new IllegalArgumentException("Could not create BloomFilter of " + numBits + " bits", e);
    }
  }

Replace Generic With Diamond BloomFilter<T> with BloomFilter<> in method package create(funnel Funnel<? super T>, expectedInsertions long, fpp double, strategy Strategy) : BloomFilter<T> from class dev.mccue.guava.hash.BloomFilter


/**
   * Reads a byte stream, which was written by {@code #writeTo(OutputStream)}, into a {@code
   * BloomFilter}.
   *
   *
The {@code Funnel} to be used is not encoded in the stream, so it must be provided here.
   * Warning: the funnel provided must behave identically to the one used to populate
   * the original Bloom filter!
   *
   * @throws IOException if the InputStream throws an {@code IOException}, or if its data does not
   *     appear to be a BloomFilter serialized using the {@code #writeTo(OutputStream)} method.
   */
  @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
  public static <T extends @Nullable Object> BloomFilter<T> readFrom(
      InputStream in, Funnel<? super T> funnel) throws IOException {
    checkNotNull(in, "InputStream");
    checkNotNull(funnel, "Funnel");
    int strategyOrdinal = -1;
    int numHashFunctions = -1;
    int dataLength = -1;
    try {
      DataInputStream din = new DataInputStream(in);
      // currently this assumes there is no negative ordinal; will have to be updated if we
      // add non-stateless strategies (for which we've reserved negative ordinals; see
      // Strategy.ordinal()).
      strategyOrdinal = din.readByte();
      numHashFunctions = UnsignedBytes.toInt(din.readByte());
      dataLength = din.readInt();

      Strategy strategy = BloomFilterStrategies.values()[strategyOrdinal];

      LockFreeBitArray dataArray = new LockFreeBitArray(LongMath.checkedMultiply(dataLength, 64L));
      for (int i = 0; i < dataLength; i++) {
        dataArray.putData(i, din.readLong());
      }

      return new BloomFilter<>(dataArray, numHashFunctions, funnel, strategy);
    } catch (IOException e) {
      throw e;
    } catch (Exception e) { // sneaky checked exception
      String message =
          "Unable to deserialize BloomFilter from InputStream."
              + " strategyOrdinal: "
              + strategyOrdinal
              + " numHashFunctions: "
              + numHashFunctions
              + " dataLength: "
              + dataLength;
      throw new IOException(message, e);
    }
  }

/**
   * Reads a byte stream, which was written by {@code #writeTo(OutputStream)}, into a {@code
   * BloomFilter}.
   *
   *
The {@code Funnel} to be used is not encoded in the stream, so it must be provided here.
   * Warning: the funnel provided must behave identically to the one used to populate
   * the original Bloom filter!
   *
   * @throws IOException if the InputStream throws an {@code IOException}, or if its data does not
   *     appear to be a BloomFilter serialized using the {@code #writeTo(OutputStream)} method.
   */
  @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
  public static <T extends @Nullable Object> BloomFilter<T> readFrom(
      InputStream in, Funnel<? super T> funnel) throws IOException {
    checkNotNull(in, "InputStream");
    checkNotNull(funnel, "Funnel");
    int strategyOrdinal = -1;
    int numHashFunctions = -1;
    int dataLength = -1;
    try {
      DataInputStream din = new DataInputStream(in);
      // currently this assumes there is no negative ordinal; will have to be updated if we
      // add non-stateless strategies (for which we've reserved negative ordinals; see
      // Strategy.ordinal()).
      strategyOrdinal = din.readByte();
      numHashFunctions = UnsignedBytes.toInt(din.readByte());
      dataLength = din.readInt();

      Strategy strategy = BloomFilterStrategies.values()[strategyOrdinal];

      LockFreeBitArray dataArray = new LockFreeBitArray(LongMath.checkedMultiply(dataLength, 64L));
      for (int i = 0; i < dataLength; i++) {
        dataArray.putData(i, din.readLong());
      }

      return new BloomFilter<T>(dataArray, numHashFunctions, funnel, strategy);
    } catch (IOException e) {
      throw e;
    } catch (Exception e) { // sneaky checked exception
      String message =
          "Unable to deserialize BloomFilter from InputStream."
              + " strategyOrdinal: "
              + strategyOrdinal
              + " numHashFunctions: "
              + numHashFunctions
              + " dataLength: "
              + dataLength;
      throw new IOException(message, e);
    }
  }

Replace Generic With Diamond BloomFilter<T> with BloomFilter<> in method public readFrom(in InputStream, funnel Funnel<? super T>) : BloomFilter<T> from class dev.mccue.guava.hash.BloomFilter


    private static void ensureSynchronized() {
        if (!hasBeenSynchronized) {
            if (AquaNativeSupport.load()) {
                synchronize();
                Runnable synchronizer = () -> SwingUtilities.invokeLater(OSXSystemProperties::synchronize);
                enableCallback(synchronizer);
            } else {
                hasBeenSynchronized = true;
            }
        }
    }

    private static void ensureSynchronized() {
        if (!hasBeenSynchronized) {
            if (AquaNativeSupport.load()) {
                synchronize();
                Runnable synchronizer = new Runnable() {
                    @Override
                    public void run() {
                        synchronize();
                    }
                };
                enableCallback(synchronizer);
            } else {
                hasBeenSynchronized = true;
            }
        }
    }

Replace Anonymous With Lambda org.violetlib.aqua.OSXSystemProperties.ensureSynchronized.synchronizer.new Runnable with () -> SwingUtilities.invokeLater(OSXSystemProperties::synchronize) in method private ensureSynchronized() : void from class org.violetlib.aqua.OSXSystemProperties


	/**
	 * Method to dump the oMe matrix
	 *
	 * @param chr: String for the name of teh chromosome
	 * @param output: String path of the output
	 * @return
	 * @throws IOException
	 */
	public boolean dumpObservedMExpected(String chr, String output, int resolution) throws IOException{
		int exitValue=1;
		Runtime runtime = Runtime.getRuntime();
		String obs = output.replaceAll(".txt", "_obs.txt");
		try {
			String cool = this._coolFile+"::/resolutions/"+resolution;
			String line = this._cooler+" dump "+cool+" --balanced -r "+chr+" -r2 "+ chr+" -o "+obs +" --join --na-rep NaN";
			//System.out.println(line);
			this._log = this._log+"\n"+obs+"\t"+line;
			Process process = runtime.exec(line);

			new ReturnFlux(process.getInputStream()).start();
			new ReturnFlux(process.getErrorStream()).start();
			exitValue=process.waitFor();
		}
		catch (IOException | InterruptedException e) {
			e.printStackTrace();
		}
		if(_logError!=""){
			System.out.println(_logError);
			System.exit(0);
		}
		observedMExpected(obs,output,resolution);
		return exitValue==0;
	}

	/**
	 * Method to dump the oMe matrix
	 *
	 * @param chr: String for the name of teh chromosome
	 * @param output: String path of the output
	 * @return
	 * @throws IOException
	 */
	public boolean dumpObservedMExpected(String chr, String output, int resolution) throws IOException{
		int exitValue=1;
		Runtime runtime = Runtime.getRuntime();
		String obs = output.replaceAll(".txt", "_obs.txt");
		try {
			String cool = this._coolFile+"::/resolutions/"+resolution;
			String line = this._cooler+" dump "+cool+" --balanced -r "+chr+" -r2 "+ chr+" -o "+obs +" --join --na-rep NaN";
			//System.out.println(line);
			this._log = this._log+"\n"+obs+"\t"+line;
			Process process = runtime.exec(line);

			new ReturnFlux(process.getInputStream()).start();
			new ReturnFlux(process.getErrorStream()).start();
			exitValue=process.waitFor();
		}
		catch (IOException e) {	e.printStackTrace();}
		catch (InterruptedException e) {e.printStackTrace();}
		if(_logError!=""){
			System.out.println(_logError);
			System.exit(0);
		}
		observedMExpected(obs,output,resolution);
		return exitValue==0;
	}

Merge Catch [catch(IOException e), catch(InterruptedException e)] to catch(IOException|InterruptedException e) in method public dumpObservedMExpected(chr String, output String, resolution int) : boolean from class plop.process.CoolerDumpData


	/**
	 * Getter of loop corrdinate, return arraylist 0: x; 1: x_end; 2: y; 3: y_end
	 * @return ArrayList of integer
	 */
	public ArrayList<Integer> getCoordinates(){
		ArrayList<Integer> listCoord = new ArrayList<>();
		listCoord.add(this._x);
		listCoord.add(this._xEnd);
		listCoord.add(this._y);
		listCoord.add(this._yEnd);
		return listCoord;
	}

	/**
	 * Getter of loop corrdinate, return arraylist 0: x; 1: x_end; 2: y; 3: y_end
	 * @return ArrayList of integer
	 */
	public ArrayList<Integer> getCoordinates(){
		ArrayList<Integer> listCoord = new ArrayList<Integer>();
		listCoord.add(this._x);
		listCoord.add(this._xEnd);
		listCoord.add(this._y);
		listCoord.add(this._yEnd);
		return listCoord;
	}

Replace Generic With Diamond ArrayList<Integer> with ArrayList<> in method public getCoordinates() : ArrayList<Integer> from class plop.loops.Loop


    public List<T> getAll() {
        String query = new SQLQuery.SQLQueryBuilder().select().from(clz).build().toString();
        List<T> results = null;

        try (SQLConnection connection = SQLConnection.createSQLConnection("connectionData.json")) {
            Statement stmt = connection.getConnection().createStatement();
            ResultSet resultSet = stmt.executeQuery(query);
            results = (List<T>) extractResults(resultSet);
        } catch (Exception e) {
            System.out.println(e);
        }

        return results;
    }

    public List<T> getAll() {
        String query = new SQLQuery.SQLQueryBuilder().select().from(clz).build().toString();
        List<T> results = null;

        try {
            SQLConnection connection = SQLConnection.getInstance("connectionData.json");
            Statement stmt = connection.getConnection().createStatement();
            ResultSet resultSet = stmt.executeQuery(query);
            results = (List<T>) extractResults(resultSet);
        } catch (Exception e) {
            System.out.println(e);
        }

        return results;
    }

Try With Resources try(SQLConnection connection=SQLConnection.createSQLConnection("connectionData.json")) in method public getAll() : List<T> from class repository.Repository


    public void insertOne(T object) {
        String query = new SQLQuery.SQLQueryBuilder().insertInto(object).build().toString();

        try (SQLConnection connection = SQLConnection.createSQLConnection("connectionData.json")) {
            Statement statement = connection.getConnection().createStatement();
            statement.execute(query);
            System.out.println("Item was successfully inserted");
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void insertOne(T object) {
        String query = new SQLQuery.SQLQueryBuilder().insertInto(object).build().toString();

        try {
            SQLConnection connection = SQLConnection.getInstance("connectionData.json");
            Statement statement = connection.getConnection().createStatement();
            statement.execute(query);
            System.out.println("Item was successfully inserted");
        }
        catch (ClassNotFoundException e) {
            System.out.println("An Mysql drivers were not found");
        } catch (SQLException e) {
            System.out.println("An error has occurred on insertOne");
            throw new RuntimeException(e);
        }
    }

Try With Resources try(SQLConnection connection=SQLConnection.createSQLConnection("connectionData.json")) in method public insertOne(object T) : void from class repository.Repository


    public void createTable() {
        String query = new SQLQuery.SQLQueryBuilder().createTable(clz).build().toString();

        try (SQLConnection connection = SQLConnection.createSQLConnection("connectionData.json")) {
            Statement statement = connection.getConnection().createStatement();
            statement.executeUpdate(query);
            System.out.println("Table Created");
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void createTable() {
        String query = new SQLQuery.SQLQueryBuilder().createTable(clz).build().toString();

        try {
            SQLConnection connection = SQLConnection.getInstance("connectionData.json");
            Statement statement = connection.getConnection().createStatement();
            statement.executeUpdate(query);
            System.out.println("Table Created");
        }
        catch (ClassNotFoundException e) {
            System.out.println("An Mysql drivers were not found");
        } catch (SQLException e) {
            System.out.println("An error has occurred on Table Creation");
            throw new RuntimeException(e);
        }
    }

Try With Resources try(SQLConnection connection=SQLConnection.createSQLConnection("connectionData.json")) in method public createTable() : void from class repository.Repository


    /**
     * Get a connected AS400 object from the connection pool with the specified Locale.  If an appropriate one is
     * not found, one is created.  If the maximum connection limit has been reached, an exception
     * will be thrown.
     *
     * @param   systemName  The name of the system where the object should exist.
     * @param   userID  The name of the user.
     * @param   password  The password of the user.
     * @param   service  The service to connect. See the service number constants defined by AS400 class.
     * @param   locale   The Locale used to set the National Language Version (NLV) on the system for the AS400 object returned.
     * Only the COMMAND, PRINT, and DATABASE services accept an NLV.
     * @return     A connected AS400 object.
     * @exception ConnectionPoolException If a connection pool error occurred.
     **/
    public AS400 getConnection(String systemName, String userID, char[] password, int service, Locale locale) throws ConnectionPoolException
    {
        try
        {
            //@B4D AS400.addPasswordCacheEntry(systemName, userID, password);
            AS400 releaseConnection = getConnection(systemName, userID, service, true, false, locale, password);     //@B4C
            if (poolListeners_ != null)
            {
                ConnectionPoolEvent event = new ConnectionPoolEvent(releaseConnection, ConnectionPoolEvent.CONNECTION_RELEASED);
                poolListeners_.fireConnectionReleasedEvent(event);
            }

            return releaseConnection;
        }
        catch (AS400SecurityException|IOException e) {
            throw new ConnectionPoolException(e);
        }
    }

  /**
   * Get a connected AS400 object from the connection pool with the specified Locale.  If an appropriate one is
   * not found, one is created.  If the maximum connection limit has been reached, an exception
   * will be thrown.
   *
   * @param   systemName  The name of the system where the object should exist.
   * @param   userID  The name of the user.
   * @param   password  The password of the user.
   * @param   service  The service to connect. See the service number constants defined by AS400 class.
   * @param   locale   The Locale used to set the National Language Version (NLV) on the system for the AS400 object returned.
   * Only the COMMAND, PRINT, and DATABASE services accept an NLV.
   * @return     A connected AS400 object.
   * @exception ConnectionPoolException If a connection pool error occurred.
   **/
  public AS400 getConnection(String systemName, String userID, char[] password, int service, Locale locale)
  throws ConnectionPoolException
  {
    try
    {
      //@B4D AS400.addPasswordCacheEntry(systemName, userID, password);
      AS400 releaseConnection = getConnection(systemName, userID, service, true, false, locale, password);     //@B4C
      if (poolListeners_ != null)
      {
        ConnectionPoolEvent event = new ConnectionPoolEvent(releaseConnection, ConnectionPoolEvent.CONNECTION_RELEASED);
        poolListeners_.fireConnectionReleasedEvent(event);
      }
      return releaseConnection;
    }
    catch (AS400SecurityException e)
    {
      throw new ConnectionPoolException(e);
    }
    catch (IOException ie)
    {
      throw new ConnectionPoolException(ie);
    }
  }

Merge Catch [catch(AS400SecurityException e), catch(IOException ie)] to catch(AS400SecurityException|IOException e) in method public getConnection(systemName String, userID String, password char[], service int, locale Locale) : AS400 from class com.ibm.as400.access.AS400ConnectionPool


    /**
     * Get an AS400 object from the connection pool with the specified Locale.  If an appropriate one is not found,
     * one is created.  If the maximum connection limit has been reached, an exception
     * will be thrown.  The AS400 object may not be connected to any services.
     *
     * @param   systemName  The name of the system where the object should exist.
     * @param   userID  The name of the user.
     * @param   password  The password of the user.
     * @param   locale   The Locale used to set the National Language Version (NLV) on the system for the AS400 object returned.
     * Only the COMMAND, PRINT, and DATABASE services accept an NLV.
     * @return     An AS400 object.
     * @exception ConnectionPoolException If a connection pool error occurred.
     **/
    public AS400 getConnection(String systemName, String userID, char[] password, Locale locale) throws ConnectionPoolException
    {
        try
        {
            //@B4D AS400.addPasswordCacheEntry(systemName, userID, password);
            AS400 releaseConnection = getConnection(systemName, userID, 0, false, false, locale, password); //@B4C
            if (poolListeners_ != null)
            {
                ConnectionPoolEvent event = new ConnectionPoolEvent(releaseConnection, ConnectionPoolEvent.CONNECTION_RELEASED);
                poolListeners_.fireConnectionReleasedEvent(event);
            }

            return releaseConnection;
        }
        catch (AS400SecurityException|IOException e) {
            throw new ConnectionPoolException(e);
        }
    }

  /**
   * Get an AS400 object from the connection pool with the specified Locale.  If an appropriate one is not found,
   * one is created.  If the maximum connection limit has been reached, an exception
   * will be thrown.  The AS400 object may not be connected to any services.
   *
   * @param   systemName  The name of the system where the object should exist.
   * @param   userID  The name of the user.
   * @param   password  The password of the user.
   * @param   locale   The Locale used to set the National Language Version (NLV) on the system for the AS400 object returned.
   * Only the COMMAND, PRINT, and DATABASE services accept an NLV.
   * @return     An AS400 object.
   * @exception ConnectionPoolException If a connection pool error occurred.
   **/
  public AS400 getConnection(String systemName, String userID, char[] password, Locale locale)
  throws ConnectionPoolException
  {
    try
    {
      //@B4D AS400.addPasswordCacheEntry(systemName, userID, password);
      AS400 releaseConnection = getConnection(systemName, userID, 0, false, false, locale, password); //@B4C
      if (poolListeners_ != null)
      {
        ConnectionPoolEvent event = new ConnectionPoolEvent(releaseConnection, ConnectionPoolEvent.CONNECTION_RELEASED);
        poolListeners_.fireConnectionReleasedEvent(event);
      }
      return releaseConnection;
    }
    catch (AS400SecurityException e)
    {
      throw new ConnectionPoolException(e);
    }
    catch (IOException ie)
    {
      throw new ConnectionPoolException(ie);
    }
  }

Merge Catch [catch(AS400SecurityException e), catch(IOException ie)] to catch(AS400SecurityException|IOException e) in method public getConnection(systemName String, userID String, password char[], locale Locale) : AS400 from class com.ibm.as400.access.AS400ConnectionPool


/**
     * Get a connected AS400 object from the connection pool.  If an appropriate one is
     * not found, one is created.  If the maximum connection limit has been reached, an exception
     * will be thrown.
     * Note that the profileTokenCredential is validated only when creating a new
     * connection, of the match criteria to pull a connection out of the pool.  This means
     * that if an existing connection in the pool matches the systemName and
     * userID passed in, a connection will be returned without the profileTokenCredential
     * being validated.
     *
     * @param   systemName  The name of the system where the object should exist.
     * @param   userID  The name of the user.
     * @param   profileToken  The profile token to use to authenticate to the system.
     * @param   service  The service to connect. See the service number constants defined by AS400 class.
     * @return     A connected AS400 object.
     * @exception ConnectionPoolException If a connection pool error occurred.
     **/
    public AS400 getConnection(String systemName, String userID, ProfileTokenCredential profileToken, int service) throws ConnectionPoolException
    {
        try
        {
            AS400 releaseConnection = getConnection(systemName, userID, service, true, false, null, profileToken);
            if (poolListeners_ != null)
            {
                ConnectionPoolEvent event = new ConnectionPoolEvent(releaseConnection, ConnectionPoolEvent.CONNECTION_RELEASED);
                poolListeners_.fireConnectionReleasedEvent(event);
            }

            return releaseConnection;
        }
        catch (AS400SecurityException|IOException e) {
            throw new ConnectionPoolException(e);
        }
    }

/**
   * Get a connected AS400 object from the connection pool.  If an appropriate one is
   * not found, one is created.  If the maximum connection limit has been reached, an exception
   * will be thrown.
   * Note that the profileTokenCredential is validated only when creating a new
   * connection, of the match criteria to pull a connection out of the pool.  This means
   * that if an existing connection in the pool matches the systemName and
   * userID passed in, a connection will be returned without the profileTokenCredential
   * being validated.
   *
   * @param   systemName  The name of the system where the object should exist.
   * @param   userID  The name of the user.
   * @param   profileToken  The profile token to use to authenticate to the system.
   * @param   service  The service to connect. See the service number constants defined by AS400 class.
   * @return     A connected AS400 object.
   * @exception ConnectionPoolException If a connection pool error occurred.
   **/
  public AS400 getConnection(String systemName, String userID, ProfileTokenCredential profileToken, int service) //@C1A
  throws ConnectionPoolException
  {
    try
    {
      AS400 releaseConnection = getConnection(systemName, userID, service, true, false, null, profileToken);
      if (poolListeners_ != null)
      {
        ConnectionPoolEvent event = new ConnectionPoolEvent(releaseConnection, ConnectionPoolEvent.CONNECTION_RELEASED);
        poolListeners_.fireConnectionReleasedEvent(event);
      }
      return releaseConnection;
    }
    catch (AS400SecurityException e)
    {
      throw new ConnectionPoolException(e);
    }
    catch (IOException ie)
    {
      throw new ConnectionPoolException(ie);
    }
  }

Merge Catch [catch(AS400SecurityException e), catch(IOException ie)] to catch(AS400SecurityException|IOException e) in method public getConnection(systemName String, userID String, profileToken ProfileTokenCredential, service int) : AS400 from class com.ibm.as400.access.AS400ConnectionPool


    /**
     * Get an AS400 object from the connection pool.  If an appropriate one is not found,
     * one is created.  If the maximum connection limit has been reached, an exception
     * will be thrown.  The AS400 object may not be connected to any services.
     * Note that the password is validated only when creating a new connection, not as part
     * of the match criteria to pull a connection out of the pool.  This means that
     * if a connection in the pool matches the systemName and userID passed in, a
     * connection will be returned without the password being validated.
     *
     * @param   systemName  The name of the system where the object should exist.
     * @param   userID  The name of the user.
     * @param   profileToken  The profile token to use to authenticate to the system.
     * @return     An AS400 object.
     * @exception ConnectionPoolException If a connection pool error occurred.
     **/
    public AS400 getConnection(String systemName, String userID, ProfileTokenCredential profileToken) throws ConnectionPoolException
    {
        try
        {
            AS400 releaseConnection = getConnection(systemName, userID, 0, false, false, null, profileToken);
            if (poolListeners_ != null)
            {
                ConnectionPoolEvent event = new ConnectionPoolEvent(releaseConnection, ConnectionPoolEvent.CONNECTION_RELEASED);
                poolListeners_.fireConnectionReleasedEvent(event);
            }

            return releaseConnection;
        }
        catch (AS400SecurityException|IOException e) {
            throw new ConnectionPoolException(e);
        }
    }

  /**
   * Get an AS400 object from the connection pool.  If an appropriate one is not found,
   * one is created.  If the maximum connection limit has been reached, an exception
   * will be thrown.  The AS400 object may not be connected to any services.
     * Note that the password is validated only when creating a new connection, not as part
     * of the match criteria to pull a connection out of the pool.  This means that
     * if a connection in the pool matches the systemName and userID passed in, a
     * connection will be returned without the password being validated.
   *
   * @param   systemName  The name of the system where the object should exist.
   * @param   userID  The name of the user.
   * @param   profileToken  The profile token to use to authenticate to the system.
   * @return     An AS400 object.
   * @exception ConnectionPoolException If a connection pool error occurred.
   **/
  public AS400 getConnection(String systemName, String userID, ProfileTokenCredential profileToken) //@C1A
  throws ConnectionPoolException
  {
    try
    {
      AS400 releaseConnection = getConnection(systemName, userID, 0, false, false, null, profileToken);
      if (poolListeners_ != null)
      {
        ConnectionPoolEvent event = new ConnectionPoolEvent(releaseConnection, ConnectionPoolEvent.CONNECTION_RELEASED);
        poolListeners_.fireConnectionReleasedEvent(event);
      }
      return releaseConnection;
    }
    catch (AS400SecurityException e)
    {
      throw new ConnectionPoolException(e);
    }
    catch (IOException ie)
    {
      throw new ConnectionPoolException(ie);
    }
  }

Merge Catch [catch(AS400SecurityException e), catch(IOException ie)] to catch(AS400SecurityException|IOException e) in method public getConnection(systemName String, userID String, profileToken ProfileTokenCredential) : AS400 from class com.ibm.as400.access.AS400ConnectionPool


    /**
     * Get an AS400 object from the connection pool with the specified Locale.  If an appropriate one is not found,
     * one is created.  If the maximum connection limit has been reached, an exception
     * will be thrown.  The AS400 object may not be connected to any services.
     *
     * @param   systemName  The name of the system where the object should exist.
     * @param   userID  The name of the user.
     * @param   profileToken  The profile token to use to authenticate to the system.
     * @param   locale   The Locale used to set the National Language Version (NLV) on the system for the AS400 object returned.
     * Only the COMMAND, PRINT, and DATABASE services accept an NLV.
     * @return     An AS400 object.
     * @exception ConnectionPoolException If a connection pool error occurred.
     **/
    public AS400 getConnection(String systemName, String userID, ProfileTokenCredential profileToken, Locale locale) throws ConnectionPoolException
    {
        try
        {
            AS400 releaseConnection = getConnection(systemName, userID, 0, false, false, locale, profileToken);
            if (poolListeners_ != null)
            {
                ConnectionPoolEvent event = new ConnectionPoolEvent(releaseConnection, ConnectionPoolEvent.CONNECTION_RELEASED);
                poolListeners_.fireConnectionReleasedEvent(event);
            }

            return releaseConnection;
        }
        catch (AS400SecurityException|IOException e) {
            throw new ConnectionPoolException(e);
        }
    }

  /**
   * Get an AS400 object from the connection pool with the specified Locale.  If an appropriate one is not found,
   * one is created.  If the maximum connection limit has been reached, an exception
   * will be thrown.  The AS400 object may not be connected to any services.
   *
   * @param   systemName  The name of the system where the object should exist.
   * @param   userID  The name of the user.
   * @param   profileToken  The profile token to use to authenticate to the system.
   * @param   locale   The Locale used to set the National Language Version (NLV) on the system for the AS400 object returned.
   * Only the COMMAND, PRINT, and DATABASE services accept an NLV.
   * @return     An AS400 object.
   * @exception ConnectionPoolException If a connection pool error occurred.
   **/
  public AS400 getConnection(String systemName, String userID, ProfileTokenCredential profileToken, Locale locale) //@C1A
  throws ConnectionPoolException
  {
    try
    {
      AS400 releaseConnection = getConnection(systemName, userID, 0, false, false, locale, profileToken);
      if (poolListeners_ != null)
      {
        ConnectionPoolEvent event = new ConnectionPoolEvent(releaseConnection, ConnectionPoolEvent.CONNECTION_RELEASED);
        poolListeners_.fireConnectionReleasedEvent(event);
      }
      return releaseConnection;
    }
    catch (AS400SecurityException e)
    {
      throw new ConnectionPoolException(e);
    }
    catch (IOException ie)
    {
      throw new ConnectionPoolException(ie);
    }
  }

Merge Catch [catch(AS400SecurityException e), catch(IOException ie)] to catch(AS400SecurityException|IOException e) in method public getConnection(systemName String, userID String, profileToken ProfileTokenCredential, locale Locale) : AS400 from class com.ibm.as400.access.AS400ConnectionPool


/**
     * Get a secure connected AS400 object from the connection pool.  If an appropriate one is
     * not found, one is created.  If the maximum connection limit has been reached, an exception
     * will be thrown.
     * Note that the password is validated only when creating a new connection,
     * of the match criteria to pull a connection out of the pool.  This means that
     * if an existing connection in the pool matches the systemName and userID
     * passed in, a connection will be returned without the password being validated.
     *
     * @param   systemName  The name of the system where the object should exist.
     * @param   userID  The name of the user.
     * @param   password  The password of the user.
     * @param   service  The service to connect. See the service number constants defined by AS400 class.
     * @return     A connected AS400 object.
     * @exception ConnectionPoolException If a connection pool error occurred.
     **/
    public AS400 getSecureConnection(String systemName, String userID, char[] password, int service) throws ConnectionPoolException
    {
        try
        {
            //@B4D AS400.addPasswordCacheEntry(systemName, userID, password);
            AS400 releaseConnection = getConnection(systemName, userID, service, true, true, null, password);  //@B3C add null locale //@B4C
            if (poolListeners_ != null)
            {
                ConnectionPoolEvent event = new ConnectionPoolEvent(releaseConnection, ConnectionPoolEvent.CONNECTION_RELEASED); //@A7C
                poolListeners_.fireConnectionReleasedEvent(event);
            }

            return releaseConnection;
        }
        catch (AS400SecurityException|IOException e) {
            throw new ConnectionPoolException(e);
        }
    }

/**
   * Get a secure connected AS400 object from the connection pool.  If an appropriate one is
   * not found, one is created.  If the maximum connection limit has been reached, an exception
     * will be thrown.
     * Note that the password is validated only when creating a new connection,
     * of the match criteria to pull a connection out of the pool.  This means that
     * if an existing connection in the pool matches the systemName and userID
     * passed in, a connection will be returned without the password being validated.
   *
   * @param   systemName  The name of the system where the object should exist.
   * @param   userID  The name of the user.
   * @param   password  The password of the user.
   * @param   service  The service to connect. See the service number constants defined by AS400 class.
   * @return     A connected AS400 object.
   * @exception ConnectionPoolException If a connection pool error occurred.
  **/
  public AS400 getSecureConnection(String systemName, String userID, char[] password, int service)
  throws ConnectionPoolException
  {
    try
    {
      //@B4D AS400.addPasswordCacheEntry(systemName, userID, password);
      AS400 releaseConnection = getConnection(systemName, userID, service, true, true, null, password);  //@B3C add null locale //@B4C
      if (poolListeners_ != null)
      {
        ConnectionPoolEvent event = new ConnectionPoolEvent(releaseConnection, ConnectionPoolEvent.CONNECTION_RELEASED); //@A7C
        poolListeners_.fireConnectionReleasedEvent(event);
      }
      return releaseConnection;
    }
    catch (AS400SecurityException e)
    {
      throw new ConnectionPoolException(e);
    }
    catch (IOException ie)
    {
      throw new ConnectionPoolException(ie);
    }
  }

Merge Catch [catch(AS400SecurityException e), catch(IOException ie)] to catch(AS400SecurityException|IOException e) in method public getSecureConnection(systemName String, userID String, password char[], service int) : AS400 from class com.ibm.as400.access.AS400ConnectionPool


/**
     * Get a secure connected AS400 object from the connection pool.  If an appropriate one is
     * not found, one is created.  If the maximum connection limit has been reached, an exception
     * will be thrown.
     * Note that the profileTokenCredential is validated only when creating a new
     * connection, of the match criteria to pull a connection out of the pool.  This means
     * that if an existing connection in the pool matches the systemName and
     * userID passed in, a connection will be returned without the profileTokenCredential
     * being validated.
     *
     * @param   systemName  The name of the system where the object should exist.
     * @param   userID  The name of the user.
     * @param   profileToken  The profile token to use to authenticate to the system.
     * @param   service  The service to connect. See the service number constants defined by AS400 class.
     * @return     A connected AS400 object.
     * @exception ConnectionPoolException If a connection pool error occurred.
     **/
    public AS400 getSecureConnection(String systemName, String userID, ProfileTokenCredential profileToken, int service) throws ConnectionPoolException
    {
        try
        {
            AS400 releaseConnection = getConnection(systemName, userID, service, true, true, null, profileToken);
            if (poolListeners_ != null)
            {
                ConnectionPoolEvent event = new ConnectionPoolEvent(releaseConnection, ConnectionPoolEvent.CONNECTION_RELEASED);
                poolListeners_.fireConnectionReleasedEvent(event);
            }

            return releaseConnection;
        }
        catch (AS400SecurityException|IOException e) {
            throw new ConnectionPoolException(e);
        }
    }

/**
   * Get a secure connected AS400 object from the connection pool.  If an appropriate one is
   * not found, one is created.  If the maximum connection limit has been reached, an exception
   * will be thrown.
   * Note that the profileTokenCredential is validated only when creating a new
   * connection, of the match criteria to pull a connection out of the pool.  This means
   * that if an existing connection in the pool matches the systemName and
   * userID passed in, a connection will be returned without the profileTokenCredential
   * being validated.
   *
   * @param   systemName  The name of the system where the object should exist.
   * @param   userID  The name of the user.
   * @param   profileToken  The profile token to use to authenticate to the system.
   * @param   service  The service to connect. See the service number constants defined by AS400 class.
   * @return     A connected AS400 object.
   * @exception ConnectionPoolException If a connection pool error occurred.
  **/
  public AS400 getSecureConnection(String systemName, String userID, ProfileTokenCredential profileToken, int service) //@C1A
  throws ConnectionPoolException
  {
    try
    {
      AS400 releaseConnection = getConnection(systemName, userID, service, true, true, null, profileToken);
      if (poolListeners_ != null)
      {
        ConnectionPoolEvent event = new ConnectionPoolEvent(releaseConnection, ConnectionPoolEvent.CONNECTION_RELEASED);
        poolListeners_.fireConnectionReleasedEvent(event);
      }
      return releaseConnection;
    }
    catch (AS400SecurityException e)
    {
      throw new ConnectionPoolException(e);
    }
    catch (IOException ie)
    {
      throw new ConnectionPoolException(ie);
    }
  }

Merge Catch [catch(AS400SecurityException e), catch(IOException ie)] to catch(AS400SecurityException|IOException e) in method public getSecureConnection(systemName String, userID String, profileToken ProfileTokenCredential, service int) : AS400 from class com.ibm.as400.access.AS400ConnectionPool


    static Socket getSocketConnection(String systemName, int port, SocketProperties socketProperties) throws IOException
    {
      //Code to make use of new method java.net.Socket.connect(host, timeout) in jdk 1.4
      //only really needed on first socket connect so we do not hang when a system is down.
      //Socket pmSocket = new Socket(systemName, port);
      Socket pmSocket = null;
      try
      {
        /*  Due to various jvm and compile issues, there are many possible types of exceptions that could
         be thrown, depending on jvm version and implementation etc.  Class.forName() seems to be the best
         solution to finding the jvm version that does not degrade performance. */
        Class.forName("java.net.InetSocketAddress"); //throws ClassNotFoundException (common to all jvm implementations)

        pmSocket = new Socket();

        int loginTimeout = 0;
        if(socketProperties.isLoginTimeoutSet())
        {
          loginTimeout = socketProperties.getLoginTimeout();
        }

        if (Trace.traceOn_) Trace.log(Trace.DIAGNOSTIC, "Connect to socket: system '"+systemName+"', port " +port+ ", login timeout " + loginTimeout + " ms.");

        InetSocketAddress hostAddr = systemName != null ? new InetSocketAddress(systemName, port) :
          new InetSocketAddress(InetAddress.getByName(null), port);

        //pmSocket.connect(hostAddr, timeout); //fyi, PortMapper will not load and gets NoClassDefFoundError in jvm1.3 due to SocketAddress parameter type, must use reflection below
        boolean done = false;
        // Retry 3 times if get a bindException
        int bindExceptionRetries = 3;
        long bindExceptionRetrySleepTime=100;
        while (!done)  // up to two tries
        {
          try
          {
            Class thisClass = pmSocket.getClass();
            Method method = thisClass.getMethod("connect", new Class[]{ SocketAddress.class, java.lang.Integer.TYPE});
            //method.setAccessible(true);                   //@CRS (applet gets exception when calling setAccessible())
            Object args[] = new Object[2];
            args[0] = hostAddr;
            args[1] = Integer.valueOf(loginTimeout);

            method.invoke(pmSocket, args);
            done = true;  // if no exception thrown, then no need to try again
          }
          catch (InvocationTargetException e) {
            Trace.log(Trace.ERROR, e);
            Throwable e2 = e.getTargetException();
            if (e2 != null) Trace.log(Trace.ERROR, e2);
            // If we get a java.net.BindException then too many of the sockets are still reserved.
            // I've only see this when testing.  Retry three times if this occurs.
            //
            if (e2 instanceof java.net.BindException) {
              if (bindExceptionRetries > 0) {
                // try again
                bindExceptionRetries--;
                try {
                  Thread.sleep(bindExceptionRetrySleepTime);
                  bindExceptionRetrySleepTime = bindExceptionRetrySleepTime * 2;
                } catch (Exception sleepException) {

                }
                done = false;
              } else {
                 throw (java.net.BindException) e2;
              }
            } else if(e2 instanceof IOException)
            {
              //Here is the actual timeout or network exceptions that we throw back to caller
              throw (IOException) e2;
            }
            else
            {
              //Else this is some sort of issue related to reflection not being supported.  Just throw ClassNotFoundException and catch it below.
              throw new ClassNotFoundException();
            }
          }
          catch (IllegalAccessException | NoSuchMethodException e) {
            //Else this is some sort of issue related to reflection not being supported.  Just throw ClassNotFoundException and catch it below.
            Trace.log(Trace.ERROR, e);
            throw new ClassNotFoundException();
          }
          catch (Exception e) { // compiler won't let us catch "IOException"
            if (e instanceof NoRouteToHostException)
            {
              // If we previously specified "localhost", retry with "ipv6-localhost".
              if ("localhost".equalsIgnoreCase(hostAddr.getHostName()))
              {
                if (Trace.traceOn_) {
                  Trace.log(Trace.DIAGNOSTIC, e.getMessage());
                  Trace.log(Trace.DIAGNOSTIC, "Retrying with hostname 'ipv6-localhost' instead of 'localhost'.");
                }
                hostAddr = new InetSocketAddress("ipv6-localhost", port);
                done = false;  // iterate the loop
              }
              else throw (NoRouteToHostException)e; // don't retry
            }
            else if (e instanceof IOException) throw (IOException)e;
            else throw new RuntimeException(e);  // should never happen
          }
        } // while
      } // outer try
      catch(ClassNotFoundException e){
        //Here we catch any exception related to running in jdk 1.3 or reflection exceptions
        //Just create socket the way we did before without a timeout.
        if (Trace.traceOn_) Trace.log(Trace.DIAGNOSTIC, "Connect to port mapper: system '"+systemName+"', port " +port+ ", no login timeout (JVM 1.3 or lower).");
        pmSocket = new Socket(systemName, port); //for pre jdk1.4
      }

      // Make sure the properties are set before returning it
      PortMapper.setSocketProperties(pmSocket, socketProperties);
      return pmSocket;
    }

    static Socket getSocketConnection(String systemName, int port, SocketProperties socketProperties) throws IOException
    {
      //Code to make use of new method java.net.Socket.connect(host, timeout) in jdk 1.4
      //only really needed on first socket connect so we do not hang when a system is down.
      //Socket pmSocket = new Socket(systemName, port);
      Socket pmSocket = null;
      try
      {
        /*  Due to various jvm and compile issues, there are many possible types of exceptions that could
         be thrown, depending on jvm version and implementation etc.  Class.forName() seems to be the best
         solution to finding the jvm version that does not degrade performance. */
        Class.forName("java.net.InetSocketAddress"); //throws ClassNotFoundException (common to all jvm implementations)

        pmSocket = new Socket();

        int loginTimeout = 0;
        if(socketProperties.isLoginTimeoutSet())
        {
          loginTimeout = socketProperties.getLoginTimeout();
        }

        if (Trace.traceOn_) Trace.log(Trace.DIAGNOSTIC, "Connect to socket: system '"+systemName+"', port " +port+ ", login timeout " + loginTimeout + " ms.");

        InetSocketAddress hostAddr = systemName != null ? new InetSocketAddress(systemName, port) :
          new InetSocketAddress(InetAddress.getByName(null), port);

        //pmSocket.connect(hostAddr, timeout); //fyi, PortMapper will not load and gets NoClassDefFoundError in jvm1.3 due to SocketAddress parameter type, must use reflection below
        boolean done = false;
        // Retry 3 times if get a bindException
        int bindExceptionRetries = 3;
        long bindExceptionRetrySleepTime=100;
        while (!done)  // up to two tries
        {
          try
          {
            Class thisClass = pmSocket.getClass();
            Method method = thisClass.getMethod("connect", new Class[]{ SocketAddress.class, java.lang.Integer.TYPE});
            //method.setAccessible(true);                   //@CRS (applet gets exception when calling setAccessible())
            Object args[] = new Object[2];
            args[0] = hostAddr;
            args[1] = Integer.valueOf(loginTimeout);

            method.invoke(pmSocket, args);
            done = true;  // if no exception thrown, then no need to try again
          }
          catch (InvocationTargetException e) {
            Trace.log(Trace.ERROR, e);
            Throwable e2 = e.getTargetException();
            if (e2 != null) Trace.log(Trace.ERROR, e2);
            // If we get a java.net.BindException then too many of the sockets are still reserved.
            // I've only see this when testing.  Retry three times if this occurs.
            //
            if (e2 instanceof java.net.BindException) {
              if (bindExceptionRetries > 0) {
                // try again
                bindExceptionRetries--;
                try {
                  Thread.sleep(bindExceptionRetrySleepTime);
                  bindExceptionRetrySleepTime = bindExceptionRetrySleepTime * 2;
                } catch (Exception sleepException) {

                }
                done = false;
              } else {
                 throw (java.net.BindException) e2;
              }
            } else if(e2 instanceof IOException)
            {
              //Here is the actual timeout or network exceptions that we throw back to caller
              throw (IOException) e2;
            }
            else
            {
              //Else this is some sort of issue related to reflection not being supported.  Just throw ClassNotFoundException and catch it below.
              throw new ClassNotFoundException();
            }
          }
          catch (IllegalAccessException e) {
            //Else this is some sort of issue related to reflection not being supported.  Just throw ClassNotFoundException and catch it below.
            Trace.log(Trace.ERROR, e);
            throw new ClassNotFoundException();
          }
          catch (NoSuchMethodException e) {
            //Else this is some sort of issue related to reflection not being supported.  Just throw ClassNotFoundException and catch it below.
            Trace.log(Trace.ERROR, e);
            throw new ClassNotFoundException();
          }
          catch (Exception e) { // compiler won't let us catch "IOException"
            if (e instanceof NoRouteToHostException)
            {
              // If we previously specified "localhost", retry with "ipv6-localhost".
              if ("localhost".equalsIgnoreCase(hostAddr.getHostName()))
              {
                if (Trace.traceOn_) {
                  Trace.log(Trace.DIAGNOSTIC, e.getMessage());
                  Trace.log(Trace.DIAGNOSTIC, "Retrying with hostname 'ipv6-localhost' instead of 'localhost'.");
                }
                hostAddr = new InetSocketAddress("ipv6-localhost", port);
                done = false;  // iterate the loop
              }
              else throw (NoRouteToHostException)e; // don't retry
            }
            else if (e instanceof IOException) throw (IOException)e;
            else throw new RuntimeException(e);  // should never happen
          }
        } // while
      } // outer try
      catch(ClassNotFoundException e){
        //Here we catch any exception related to running in jdk 1.3 or reflection exceptions
        //Just create socket the way we did before without a timeout.
        if (Trace.traceOn_) Trace.log(Trace.DIAGNOSTIC, "Connect to port mapper: system '"+systemName+"', port " +port+ ", no login timeout (JVM 1.3 or lower).");
        pmSocket = new Socket(systemName, port); //for pre jdk1.4
      }

      // Make sure the properties are set before returning it
      PortMapper.setSocketProperties(pmSocket, socketProperties);
      return pmSocket;
    }

Merge Catch [catch(IllegalAccessException e), catch(NoSuchMethodException e)] to catch(IllegalAccessException|NoSuchMethodException e) in method package getSocketConnection(systemName String, port int, socketProperties SocketProperties) : Socket from class com.ibm.as400.access.PortMapper


    @Override
    public void run() {

        init();

        while (keepConnected) {

            Object returnedValue;

            try {

                returnedValue = handleServerRequest();

                handleClientResponse(returnedValue);

            } catch (IOException | ClassNotFoundException e) {
                e.printStackTrace();
            }

        }

        try {
            server.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void run() {

        init();

        while (keepConnected) {

            Object returnedValue;

            try {

                returnedValue = handleServerRequest();

                handleClientResponse(returnedValue);

            } catch (IOException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }

        }

        try {
            server.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

Merge Catch [catch(IOException e), catch(ClassNotFoundException e)] to catch(IOException|ClassNotFoundException e) in method public run() : void from class it.polimi.ingsw.client.NetworkHandler


    /**
     * Allows to move one worker's enemy.
     *
     * @param enemyWorkers It's the list of the neighbour movable enemy workers.
     * @param myWorker     It's the chosen worker of the current player.
     * @return The Worker to move selected by the player.
     */
    public String askWorkerToMove(ArrayList<Worker> enemyWorkers, Worker myWorker) {

        ArrayList<WorkerClient> enemyWorkersClient = new ArrayList<>(enemyWorkers.size());

        for (Worker worker : enemyWorkers)
            enemyWorkersClient.add(new WorkerClient(worker));

        return (String) sendMessageWithReturn(new Message("askWorkerToMove", enemyWorkersClient, new WorkerClient(myWorker)));

    }

    /**
     * Allows to move one worker's enemy.
     *
     * @param enemyWorkers It's the list of the neighbour movable enemy workers.
     * @param myWorker     It's the chosen worker of the current player.
     * @return The Worker to move selected by the player.
     */
    public String askWorkerToMove(ArrayList<Worker> enemyWorkers, Worker myWorker) {

        ArrayList<WorkerClient> enemyWorkersClient = new ArrayList<WorkerClient>(enemyWorkers.size());

        for (Worker worker : enemyWorkers)
            enemyWorkersClient.add(new WorkerClient(worker));

        return (String) sendMessageWithReturn(new Message("askWorkerToMove", enemyWorkersClient, new WorkerClient(myWorker)));

    }

Replace Generic With Diamond ArrayList<WorkerClient> with ArrayList<> in method public askWorkerToMove(enemyWorkers ArrayList<Worker>, myWorker Worker) : String from class it.polimi.ingsw.server.ViewClient


        @Override
        public <T> LinkedBindingBuilder<T> bind(Key<T> sourceKey) {
            checkNotNull(sourceKey);
            return new FluentInterfaceImpl<>(this.binder, sourceKey, this.strategy);
        }

        @Override
        public <T> LinkedBindingBuilder<T> bind(Key<T> sourceKey) {
            checkNotNull(sourceKey);
            return new FluentInterfaceImpl<T>(this.binder, sourceKey, this.strategy);
        }

Replace Generic With Diamond FluentInterfaceImpl<T> with FluentInterfaceImpl<> in method public bind(sourceKey Key<T>) : LinkedBindingBuilder<T> from class de.skuzzle.inject.proxy.ScopedProxyBinder.ScopedProxyBuilderImpl


    /**
     * Builds a scoped proxy instance which is a subtype of the given class.
     *
     * @param type The class.
     * @return Builder object for further configuration.
     */
    public static <E> InstanceBuilder<E> forType(Class<E> type) {
        Preconditions.checkNotNull(type, "type");
        Preconditions.checkArgument(!Modifier.isFinal(type.getModifiers()),
                "can not proxy final type %s", type.getName());
        return new InstanceBuilder<>(type);
    }

    /**
     * Builds a scoped proxy instance which is a subtype of the given class.
     *
     * @param type The class.
     * @return Builder object for further configuration.
     */
    public static <E> InstanceBuilder<E> forType(Class<E> type) {
        Preconditions.checkNotNull(type, "type");
        Preconditions.checkArgument(!Modifier.isFinal(type.getModifiers()),
                "can not proxy final type %s", type.getName());
        return new InstanceBuilder<E>(type);
    }

Replace Generic With Diamond InstanceBuilder<E> with InstanceBuilder<> in method public forType(type Class<E>) : InstanceBuilder<E> from class de.skuzzle.inject.proxy.InstanceBuilder


    public static void readBinary(TaskList tasks, File file) {
        try (FileInputStream fis = new FileInputStream(file)) {
            read(tasks, fis);
        } catch (IOException e) {
            log.error("IO exception reading or writing file");
        }
    }

    public static void readBinary(TaskList tasks, File file) throws IOException{
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(file);
            read(tasks, fis);
        }
        catch (IOException e){
            log.error("IO exception reading or writing file");
        }
        finally {
            fis.close();
        }
    }

Try With Resources try(FileInputStream fis=new FileInputStream(file)) in method public readBinary(tasks TaskList, file File) : void from class tasks.services.TaskIO


	private MIMEEntry checkForTextOrBinary(Path file) throws FileSystemException, IOException {
		/*
		 * If no magic rule matches the data (or if the content is not
		 * available), use the default type of application/octet-stream for
		 * binary data, or text/plain for textual data. If there was no glob
		 * match the magic match as the result.
		 */

		try(InputStream in = Files.newInputStream(file)) {
			byte[] buf = new byte[(int) Math.min(32l, Files.size(file))];
			DataInputStream din = new DataInputStream(in);
			din.readFully(buf);
			for (byte b : buf) {
				if (b < 32) {
					return getEntity("application/octet-stream");
				}
			}
		}
		return getEntity("text/plain");
	}

	private MIMEEntry checkForTextOrBinary(Path file) throws FileSystemException, IOException {
		/*
		 * If no magic rule matches the data (or if the content is not
		 * available), use the default type of application/octet-stream for
		 * binary data, or text/plain for textual data. If there was no glob
		 * match the magic match as the result.
		 */
		InputStream in = Files.newInputStream(file);
		try {
			byte[] buf = new byte[(int) Math.min(32l, Files.size(file))];
			DataInputStream din = new DataInputStream(in);
			din.readFully(buf);
			for (byte b : buf) {
				if (b < 32) {
					return getEntity("application/octet-stream");
				}
			}
		} finally {
			in.close();
		}
		return getEntity("text/plain");
	}

Try With Resources try(InputStream in=Files.newInputStream(file)) in method private checkForTextOrBinary(file Path) : MIMEEntry from class org.freedesktop.mime.DefaultMIMEService


    @Override
    protected Collection<AliasEntry> scanBase(Path base) throws IOException {
    	Path f = base.resolve("aliases");
        AliasBase aliasBase = new AliasBase();
        aliasBases.put(base, aliasBase);
        try(BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(f)))) {
            String line;
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (!line.equals("") && !line.startsWith("#")) {
                    int idx = line.indexOf(' ');
                    if(idx == -1) {
                        throw new IOException(f + " contains invalid data '" + line  +"'.");
                    }
                    String mimeType = line.substring(0, idx);
                    String alias = line.substring(idx + 1);
                    AliasEntry entry = new AliasEntry(mimeType, alias);
                    aliasBase.byType.put(mimeType, entry);
                    aliasBase.byAlias.put(alias, entry);
                }
            }
        }
        return aliasBase.byType.values();
    }

    @Override
    protected Collection<AliasEntry> scanBase(FileObject base) throws IOException {
    	FileObject f = base.resolveFile("aliases");
        AliasBase aliasBase = new AliasBase();
        aliasBases.put(base, aliasBase);
        InputStream fin = f.getContent().getInputStream();
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(fin));
            String line;
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (!line.equals("") && !line.startsWith("#")) {
                    int idx = line.indexOf(' ');
                    if(idx == -1) {
                        throw new IOException(f + " contains invalid data '" + line  +"'.");
                    }
                    String mimeType = line.substring(0, idx);
                    String alias = line.substring(idx + 1);
                    AliasEntry entry = new AliasEntry(mimeType, alias);
                    aliasBase.byType.put(mimeType, entry);
                    aliasBase.byAlias.put(alias, entry);
                }
            }
        } finally {
            fin.close();
        }
        return aliasBase.byType.values();
    }

Try With Resources try(BufferedReader reader=new BufferedReader(new InputStreamReader(Files.newInputStream(f)))) in method protected scanBase(base Path) : Collection<AliasEntry> from class org.freedesktop.mime.DefaultAliasService


    public static void test() {
        ArrayStack<Integer> stack = new ArrayStack<>(Integer.class);
        for (int i = 0; i < 10; i++) {
            int toPush = ThreadLocalRandom.current().nextInt();
            System.out.print(toPush + ", ");
            stack.push(toPush);
        }

        System.out.println();

        for (int i = 0; i < 10; i++) {
            System.out.print(stack.pop() + ", ");
        }
    }

    public static void test() {
        ArrayStack stack = new ArrayStack<Integer>(Integer.class);
        for (int i = 0; i < 10; i++) {
            int toPush = ThreadLocalRandom.current().nextInt();
            System.out.print(toPush + ", ");
            stack.push(toPush);
        }

        System.out.println();

        for (int i = 0; i < 10; i++) {
            System.out.print(stack.pop() + ", ");
        }
    }

Replace Generic With Diamond ArrayStack<Integer> with ArrayStack<> in method public test() : void from class JavaBasic.ArrayStack


    public static HashMap<String, User> createRandomUserMap(int amount)
    {
        HashMap<String, User> UserMap = new HashMap<>();
        for (int i = 0; i < amount; i++) {
            User user = User.createRandomUser();
            UserMap.put(user.Id, user);
        }
        return UserMap;
    }

    public static HashMap<String, User> createRandomUserMap(int amount)
    {
        HashMap<String, User> UserMap = new HashMap<String, User>();
        for (int i = 0; i < amount; i++) {
            User user = User.createRandomUser();
            UserMap.put(user.Id, user);
        }
        return UserMap;
    }

Replace Generic With Diamond HashMap<String,User> with HashMap<> in method public createRandomUserMap(amount int) : HashMap<String,User> from class JavaBasic.User


    public static Civilization load() {
        try {
            ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("saves/Civilization.txt"));
            return (Civilization) objectInputStream.readObject();
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static Civilization load() {
        try {
            ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("saves/Civilization.txt"));
            return (Civilization) objectInputStream.readObject();
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }

Merge Catch [catch(IOException e), catch(ClassNotFoundException e)] to catch(IOException|ClassNotFoundException e) in method public load() : Civilization from class model.game.Civilization


  /**
   * Creates a new, empty {@code ArrayList} to hold the collection of values for an arbitrary key.
   */
  @Override
  List<V> createCollection() {
    return new ArrayList<>(expectedValuesPerKey);
  }

  /**
   * Creates a new, empty {@code ArrayList} to hold the collection of values for an arbitrary key.
   */
  @Override
  List<V> createCollection() {
    return new ArrayList<V>(expectedValuesPerKey);
  }

Replace Generic With Diamond ArrayList<V> with ArrayList<> in method package createCollection() : List<V> from class dev.mccue.guava.collect.ArrayListMultimap


    PermutationIterator(List<E> list) {
      this.list = new ArrayList<>(list);
      int n = list.size();
      c = new int[n];
      o = new int[n];
      Arrays.fill(c, 0);
      Arrays.fill(o, 1);
      j = Integer.MAX_VALUE;
    }

    PermutationIterator(List<E> list) {
      this.list = new ArrayList<E>(list);
      int n = list.size();
      c = new int[n];
      o = new int[n];
      Arrays.fill(c, 0);
      Arrays.fill(o, 1);
      j = Integer.MAX_VALUE;
    }

Replace Generic With Diamond ArrayList<E> with ArrayList<> in method package PermutationIterator(list List<E>) from class dev.mccue.guava.collect.Collections2.PermutationIterator


/**
   * Returns the elements of {@code unfiltered} that satisfy a predicate. The returned collection is
   * a live view of {@code unfiltered}; changes to one affect the other.
   *
   *
The resulting collection's iterator does not support {@code remove()}, but all other
   * collection methods are supported. When given an element that doesn't satisfy the predicate, the
   * collection's {@code add()} and {@code addAll()} methods throw an {@code
   * IllegalArgumentException}. When methods such as {@code removeAll()} and {@code clear()} are
   * called on the filtered collection, only elements that satisfy the filter will be removed from
   * the underlying collection.
   *
   *
The returned collection isn't threadsafe or serializable, even if {@code unfiltered} is.
   *
   *
Many of the filtered collection's methods, such as {@code size()}, iterate across every
   * element in the underlying collection and determine which elements satisfy the filter. When a
   * live view is not needed, it may be faster to copy {@code Iterables.filter(unfiltered,
   * predicate)} and use the copy.
   *
   *
Warning: {@code predicate} must be consistent with equals, as documented at
   * {@code Predicate#apply}. Do not provide a predicate such as {@code
   * Predicates.instanceOf(ArrayList.class)}, which is inconsistent with equals. (See {@code
   * Iterables#filter(Iterable, Class)} for related functionality.)
   *
   *
{@code Stream} equivalent: {@code java.util.stream.Stream#filter Stream.filter}.
   */
  // TODO(kevinb): how can we omit that Iterables link when building gwt
  // javadoc?
  public static <E extends @Nullable Object> Collection<E> filter(
      Collection<E> unfiltered, Predicate<? super E> predicate) {
    if (unfiltered instanceof FilteredCollection) {
      // Support clear(), removeAll(), and retainAll() when filtering a filtered
      // collection.
      return ((FilteredCollection<E>) unfiltered).createCombined(predicate);
    }

    return new FilteredCollection<>(checkNotNull(unfiltered), checkNotNull(predicate));
  }

/**
   * Returns the elements of {@code unfiltered} that satisfy a predicate. The returned collection is
   * a live view of {@code unfiltered}; changes to one affect the other.
   *
   *
The resulting collection's iterator does not support {@code remove()}, but all other
   * collection methods are supported. When given an element that doesn't satisfy the predicate, the
   * collection's {@code add()} and {@code addAll()} methods throw an {@code
   * IllegalArgumentException}. When methods such as {@code removeAll()} and {@code clear()} are
   * called on the filtered collection, only elements that satisfy the filter will be removed from
   * the underlying collection.
   *
   *
The returned collection isn't threadsafe or serializable, even if {@code unfiltered} is.
   *
   *
Many of the filtered collection's methods, such as {@code size()}, iterate across every
   * element in the underlying collection and determine which elements satisfy the filter. When a
   * live view is not needed, it may be faster to copy {@code Iterables.filter(unfiltered,
   * predicate)} and use the copy.
   *
   *
Warning: {@code predicate} must be consistent with equals, as documented at
   * {@code Predicate#apply}. Do not provide a predicate such as {@code
   * Predicates.instanceOf(ArrayList.class)}, which is inconsistent with equals. (See {@code
   * Iterables#filter(Iterable, Class)} for related functionality.)
   *
   *
{@code Stream} equivalent: {@code java.util.stream.Stream#filter Stream.filter}.
   */
  // TODO(kevinb): how can we omit that Iterables link when building gwt
  // javadoc?
  public static <E extends @Nullable Object> Collection<E> filter(
      Collection<E> unfiltered, Predicate<? super E> predicate) {
    if (unfiltered instanceof FilteredCollection) {
      // Support clear(), removeAll(), and retainAll() when filtering a filtered
      // collection.
      return ((FilteredCollection<E>) unfiltered).createCombined(predicate);
    }

    return new FilteredCollection<E>(checkNotNull(unfiltered), checkNotNull(predicate));
  }

Replace Generic With Diamond FilteredCollection<E> with FilteredCollection<> in method public filter(unfiltered Collection<E>, predicate Predicate<? super E>) : Collection<E> from class dev.mccue.guava.collect.Collections2


  @Override
  Map<K, V> createHashFloodingResistantDelegate(int tableSize) {
    return new LinkedHashMap<>(tableSize, 1.0f, accessOrder);
  }

  @Override
  Map<K, V> createHashFloodingResistantDelegate(int tableSize) {
    return new LinkedHashMap<K, V>(tableSize, 1.0f, accessOrder);
  }

Replace Generic With Diamond LinkedHashMap<K,V> with LinkedHashMap<> in method package createHashFloodingResistantDelegate(tableSize int) : Map<K,V> from class dev.mccue.guava.collect.CompactLinkedHashMap


  /** Creates an empty {@code EnumMultiset}. */
  public static <E extends Enum<E>> EnumMultiset<E> create(Class<E> type) {
    return new EnumMultiset<>(type);
  }

  /** Creates an empty {@code EnumMultiset}. */
  public static <E extends Enum<E>> EnumMultiset<E> create(Class<E> type) {
    return new EnumMultiset<E>(type);
  }

Replace Generic With Diamond EnumMultiset<E> with EnumMultiset<> in method public create(type Class<E>) : EnumMultiset<E> from class dev.mccue.guava.collect.EnumMultiset


  /** Creates a new, empty {@code HashMultiset} using the default initial capacity. */
  public static <E extends @Nullable Object> HashMultiset<E> create() {
    return new HashMultiset<>();
  }

  /** Creates a new, empty {@code HashMultiset} using the default initial capacity. */
  public static <E extends @Nullable Object> HashMultiset<E> create() {
    return new HashMultiset<E>();
  }

Replace Generic With Diamond HashMultiset<E> with HashMultiset<> in method public create() : HashMultiset<E> from class dev.mccue.guava.collect.HashMultiset


  /**
   * Creates a new, empty {@code HashMultiset} with the specified expected number of distinct
   * elements.
   *
   * @param distinctElements the expected number of distinct elements
   * @throws IllegalArgumentException if {@code distinctElements} is negative
   */
  public static <E extends @Nullable Object> HashMultiset<E> create(int distinctElements) {
    return new HashMultiset<>(distinctElements);
  }

  /**
   * Creates a new, empty {@code HashMultiset} with the specified expected number of distinct
   * elements.
   *
   * @param distinctElements the expected number of distinct elements
   * @throws IllegalArgumentException if {@code distinctElements} is negative
   */
  public static <E extends @Nullable Object> HashMultiset<E> create(int distinctElements) {
    return new HashMultiset<E>(distinctElements);
  }

Replace Generic With Diamond HashMultiset<E> with HashMultiset<> in method public create(distinctElements int) : HashMultiset<E> from class dev.mccue.guava.collect.HashMultiset


/**
   * Returns an {@code ImmutableList} containing the same elements, in the same order, as this
   * collection.
   *
   *
Performance note: in most cases this method can return quickly without actually
   * copying anything. The exact circumstances under which the copy is performed are undefined and
   * subject to change.
   *
   * @since 2.0
   */
  public ImmutableList<E> asList() {
    switch (size()) {
      case 0:
        return ImmutableList.of();
      case 1:
        return ImmutableList.of(iterator().next());
      default:
        return new RegularImmutableAsList<>(this, toArray());
    }
  }

/**
   * Returns an {@code ImmutableList} containing the same elements, in the same order, as this
   * collection.
   *
   *
Performance note: in most cases this method can return quickly without actually
   * copying anything. The exact circumstances under which the copy is performed are undefined and
   * subject to change.
   *
   * @since 2.0
   */
  public ImmutableList<E> asList() {
    switch (size()) {
      case 0:
        return ImmutableList.of();
      case 1:
        return ImmutableList.of(iterator().next());
      default:
        return new RegularImmutableAsList<E>(this, toArray());
    }
  }

Replace Generic With Diamond RegularImmutableAsList<E> with RegularImmutableAsList<> in method public asList() : ImmutableList<E> from class dev.mccue.guava.collect.ImmutableCollection


  static <E extends Enum<E>> ImmutableSet<E> asImmutable(EnumSet<E> set) {
    switch (set.size()) {
      case 0:
        return ImmutableSet.of();
      case 1:
        return ImmutableSet.of(Iterables.getOnlyElement(set));
      default:
        return new ImmutableEnumSet<>(set);
    }
  }

  static <E extends Enum<E>> ImmutableSet<E> asImmutable(EnumSet<E> set) {
    switch (set.size()) {
      case 0:
        return ImmutableSet.of();
      case 1:
        return ImmutableSet.of(Iterables.getOnlyElement(set));
      default:
        return new ImmutableEnumSet<E>(set);
    }
  }

Replace Generic With Diamond ImmutableEnumSet<E> with ImmutableEnumSet<> in method package asImmutable(set EnumSet<E>) : ImmutableSet<E> from class dev.mccue.guava.collect.ImmutableEnumSet


  /**
   * Returns an immutable list containing a single element. This list behaves and performs
   * comparably to {@code Collections#singletonList}, but will not accept a null element. It is
   * preferable mainly for consistency and maintainability of your code.
   *
   * @throws NullPointerException if {@code element} is null
   */
  public static <E> ImmutableList<E> of(E element) {
    return new SingletonImmutableList<>(element);
  }

  /**
   * Returns an immutable list containing a single element. This list behaves and performs
   * comparably to {@code Collections#singletonList}, but will not accept a null element. It is
   * preferable mainly for consistency and maintainability of your code.
   *
   * @throws NullPointerException if {@code element} is null
   */
  public static <E> ImmutableList<E> of(E element) {
    return new SingletonImmutableList<E>(element);
  }

Replace Generic With Diamond SingletonImmutableList<E> with SingletonImmutableList<> in method public of(element E) : ImmutableList<E> from class dev.mccue.guava.collect.ImmutableList


  /**
   * Views the array as an immutable list. Copies if the specified range does not cover the complete
   * array. Does not check for nulls.
   */
  static <E> ImmutableList<E> asImmutableList(@Nullable Object[] elements, int length) {
    switch (length) {
      case 0:
        return of();
      case 1:
        /*
         * requireNonNull is safe because the callers promise to put non-null objects in the first
         * `length` array elements.
         */
        @SuppressWarnings("unchecked") // our callers put only E instances into the array
        E onlyElement = (E) requireNonNull(elements[0]);
        return of(onlyElement);
      default:
        /*
         * The suppression is safe because the callers promise to put non-null objects in the first
         * `length` array elements.
         */
        @SuppressWarnings("nullness")
        Object[] elementsWithoutTrailingNulls =
            length < elements.length ? Arrays.copyOf(elements, length) : elements;
        return new RegularImmutableList<>(elementsWithoutTrailingNulls);
    }
  }

  /**
   * Views the array as an immutable list. Copies if the specified range does not cover the complete
   * array. Does not check for nulls.
   */
  static <E> ImmutableList<E> asImmutableList(@Nullable Object[] elements, int length) {
    switch (length) {
      case 0:
        return of();
      case 1:
        /*
         * requireNonNull is safe because the callers promise to put non-null objects in the first
         * `length` array elements.
         */
        @SuppressWarnings("unchecked") // our callers put only E instances into the array
        E onlyElement = (E) requireNonNull(elements[0]);
        return of(onlyElement);
      default:
        /*
         * The suppression is safe because the callers promise to put non-null objects in the first
         * `length` array elements.
         */
        @SuppressWarnings("nullness")
        Object[] elementsWithoutTrailingNulls =
            length < elements.length ? Arrays.copyOf(elements, length) : elements;
        return new RegularImmutableList<E>(elementsWithoutTrailingNulls);
    }
  }

Replace Generic With Diamond RegularImmutableList<E> with RegularImmutableList<> in method package asImmutableList(elements Object[], length int) : ImmutableList<E> from class dev.mccue.guava.collect.ImmutableList


  /**
   * Returns a new builder. The generated builder is equivalent to the builder created by the {@code
   * Builder} constructor.
   */
  public static <E> Builder<E> builder() {
    return new Builder<>();
  }

  /**
   * Returns a new builder. The generated builder is equivalent to the builder created by the {@code
   * Builder} constructor.
   */
  public static <E> Builder<E> builder() {
    return new Builder<E>();
  }

Replace Generic With Diamond Builder<E> with Builder<> in method public builder() : Builder<E> from class dev.mccue.guava.collect.ImmutableList


/**
   * Returns a new builder, expecting the specified number of elements to be added.
   *
   *
If {@code expectedSize} is exactly the number of elements added to the builder before {@code
   * Builder#build} is called, the builder is likely to perform better than an unsized {@code
   * #builder()} would have.
   *
   *
It is not specified if any performance benefits apply if {@code expectedSize} is close to,
   * but not exactly, the number of elements added to the builder.
   *
   * @since 23.1
   */
  public static <E> Builder<E> builderWithExpectedSize(int expectedSize) {
    checkNonnegative(expectedSize, "expectedSize");
    return new ImmutableList.Builder<>(expectedSize);
  }

/**
   * Returns a new builder, expecting the specified number of elements to be added.
   *
   *
If {@code expectedSize} is exactly the number of elements added to the builder before {@code
   * Builder#build} is called, the builder is likely to perform better than an unsized {@code
   * #builder()} would have.
   *
   *
It is not specified if any performance benefits apply if {@code expectedSize} is close to,
   * but not exactly, the number of elements added to the builder.
   *
   * @since 23.1
   */
  public static <E> Builder<E> builderWithExpectedSize(int expectedSize) {
    checkNonnegative(expectedSize, "expectedSize");
    return new ImmutableList.Builder<E>(expectedSize);
  }

Replace Generic With Diamond ImmutableList.Builder<E> with ImmutableList.Builder<> in method public builderWithExpectedSize(expectedSize int) : Builder<E> from class dev.mccue.guava.collect.ImmutableList


    /**
     * Returns an {@code ImmutableRangeMap} containing the associations previously added to this
     * builder.
     *
     * @throws IllegalArgumentException if any two ranges inserted into this builder overlap
     */
    public ImmutableRangeMap<K, V> build() {
      Collections.sort(entries, Range.<K>rangeLexOrdering().onKeys());
      ImmutableList.Builder<Range<K>> rangesBuilder = new ImmutableList.Builder<>(entries.size());
      ImmutableList.Builder<V> valuesBuilder = new ImmutableList.Builder<>(entries.size());
      for (int i = 0; i < entries.size(); i++) {
        Range<K> range = entries.get(i).getKey();
        if (i > 0) {
          Range<K> prevRange = entries.get(i - 1).getKey();
          if (range.isConnected(prevRange) && !range.intersection(prevRange).isEmpty()) {
            throw new IllegalArgumentException(
                "Overlapping ranges: range " + prevRange + " overlaps with entry " + range);
          }
        }
        rangesBuilder.add(range);
        valuesBuilder.add(entries.get(i).getValue());
      }
      return new ImmutableRangeMap<>(rangesBuilder.build(), valuesBuilder.build());
    }

    /**
     * Returns an {@code ImmutableRangeMap} containing the associations previously added to this
     * builder.
     *
     * @throws IllegalArgumentException if any two ranges inserted into this builder overlap
     */
    public ImmutableRangeMap<K, V> build() {
      Collections.sort(entries, Range.<K>rangeLexOrdering().onKeys());
      ImmutableList.Builder<Range<K>> rangesBuilder = new ImmutableList.Builder<>(entries.size());
      ImmutableList.Builder<V> valuesBuilder = new ImmutableList.Builder<V>(entries.size());
      for (int i = 0; i < entries.size(); i++) {
        Range<K> range = entries.get(i).getKey();
        if (i > 0) {
          Range<K> prevRange = entries.get(i - 1).getKey();
          if (range.isConnected(prevRange) && !range.intersection(prevRange).isEmpty()) {
            throw new IllegalArgumentException(
                "Overlapping ranges: range " + prevRange + " overlaps with entry " + range);
          }
        }
        rangesBuilder.add(range);
        valuesBuilder.add(entries.get(i).getValue());
      }
      return new ImmutableRangeMap<>(rangesBuilder.build(), valuesBuilder.build());
    }

Replace Generic With Diamond ImmutableList.Builder<V> with ImmutableList.Builder<> in method public build() : ImmutableRangeMap<K,V> from class dev.mccue.guava.collect.ImmutableRangeMap.Builder


  @SuppressWarnings("unchecked")
  public static <K extends Comparable<?>, V> ImmutableRangeMap<K, V> copyOf(
      RangeMap<K, ? extends V> rangeMap) {
    if (rangeMap instanceof ImmutableRangeMap) {
      return (ImmutableRangeMap<K, V>) rangeMap;
    }
    Map<Range<K>, ? extends V> map = rangeMap.asMapOfRanges();
    ImmutableList.Builder<Range<K>> rangesBuilder = new ImmutableList.Builder<>(map.size());
    ImmutableList.Builder<V> valuesBuilder = new ImmutableList.Builder<>(map.size());
    for (Entry<Range<K>, ? extends V> entry : map.entrySet()) {
      rangesBuilder.add(entry.getKey());
      valuesBuilder.add(entry.getValue());
    }
    return new ImmutableRangeMap<>(rangesBuilder.build(), valuesBuilder.build());
  }

  @SuppressWarnings("unchecked")
  public static <K extends Comparable<?>, V> ImmutableRangeMap<K, V> copyOf(
      RangeMap<K, ? extends V> rangeMap) {
    if (rangeMap instanceof ImmutableRangeMap) {
      return (ImmutableRangeMap<K, V>) rangeMap;
    }
    Map<Range<K>, ? extends V> map = rangeMap.asMapOfRanges();
    ImmutableList.Builder<Range<K>> rangesBuilder = new ImmutableList.Builder<>(map.size());
    ImmutableList.Builder<V> valuesBuilder = new ImmutableList.Builder<V>(map.size());
    for (Entry<Range<K>, ? extends V> entry : map.entrySet()) {
      rangesBuilder.add(entry.getKey());
      valuesBuilder.add(entry.getValue());
    }
    return new ImmutableRangeMap<>(rangesBuilder.build(), valuesBuilder.build());
  }

Replace Generic With Diamond ImmutableList.Builder<V> with ImmutableList.Builder<> in method public copyOf(rangeMap RangeMap<K,? extends V>) : ImmutableRangeMap<K,V> from class dev.mccue.guava.collect.ImmutableRangeMap


    @Override
    ImmutableSortedSet<C> createDescendingSet() {
      return new DescendingImmutableSortedSet<>(this);
    }

    @Override
    ImmutableSortedSet<C> createDescendingSet() {
      return new DescendingImmutableSortedSet<C>(this);
    }

Replace Generic With Diamond DescendingImmutableSortedSet<C> with DescendingImmutableSortedSet<> in method package createDescendingSet() : ImmutableSortedSet<C> from class dev.mccue.guava.collect.ImmutableRangeSet.AsSet