Java List Difference hasRemoval(List differences, String path)

Here you can find the source of hasRemoval(List differences, String path)

Description

Check if the list of differences contains the removal of a key, the key is a path part1.part2.part3

License

MIT License

Parameter

Parameter Description
differences The list of differences as generated by the compareMaps() function.
path The path of the value in the map.

Return

Was the key removed from the map?

Declaration

public static boolean hasRemoval(List<String> differences, String path) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2012-2015 Bruno Ranschaert
 * Released under the MIT License: http://opensource.org/licenses/MIT
 * Library "jsonutil"/*from w  ww  .  j  av a2 s  .c o  m*/
 ******************************************************************************/

import java.util.*;

public class Main {
    /**
     * Check if the list of differences contains the removal of a key, the key
     * is a path part1.part2.part3
     * 
     * @param differences
     *            The list of differences as generated by the compareMaps()
     *            function.
     * @param path
     *            The path of the value in the map.
     * @return Was the key removed from the map?
     */
    public static boolean hasRemoval(List<String> differences, String path) {
        final String pattern = String.format("-%s:", path);
        return lookForPattern(differences, pattern);
    }

    private static boolean lookForPattern(List<String> differences, String pattern) {
        for (String diff : differences) {
            if (diff.startsWith(pattern)) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. getDifference(List bigger, List smaller)
  2. getDiffInfo(List infoList)
  3. getLeftDiff(List list1, List list2)
  4. getListsDiffFormatted(List list0, List list1)
  5. getScoreSeriesByMinMaxAndDiff(List percentClaimedHistory)
  6. maxDiffBetweenCompressedWayNodes(final List wayNodeOffsets)
  7. retrieveMinimumNotZeroDifference(List percentClaimedHistory)