Java Properties isKeySame(String key, Properties p1, Properties p2)

Here you can find the source of isKeySame(String key, Properties p1, Properties p2)

Description

is Key Same

License

Open Source License

Declaration

private static boolean isKeySame(String key, Properties p1, Properties p2) 

Method Source Code


//package com.java2s;
/*//from   w w  w  .ja  v a  2  s .co m
    
Copyright (c) 2000-2003 Board of Trustees of Leland Stanford Jr. University,
all rights reserved.
    
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
    
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
    
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
STANFORD UNIVERSITY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    
Except as contained in this notice, the name of Stanford University shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Stanford University.
    
*/

import java.util.*;

public class Main {
    private static final String noProp = new String();

    private static boolean isKeySame(String key, Properties p1, Properties p2) {
        Object o1 = p1.getProperty(key);
        Object o2 = p2.getProperty(key, noProp);
        return (o1 == o2) ||
        // o2 == noProp means p2 didn't have key that p1 has.
        // we know o1 != o2, so if o1 == null, o2 != null.
                !((o2 == noProp || o1 == null || !o1.equals(o2)));
    }
}

Related

  1. createScriptBodyFromScriptSet(Properties scriptSet)
  2. differentKeys(Properties p1, Properties p2)
  3. equalProps(Properties p1, Properties p2)
  4. extractFromPropertiesAsList(String prefix, Properties properties)
  5. extractFromPropertiesAsMap(String prefix, Properties properties)
  6. isSupportedJVM(Map jdkProperties)
  7. maskApplicationEnvProperties(Map environmentVariables, Set variablesToMask)
  8. mergePropertiesIntoMap(Properties props, Map map)
  9. mergePropertiesIntoMap(Properties props, Map map)