Here you can find the source of areStringEquals(String string1, String string2)
Parameter | Description |
---|---|
string1 | from tree element |
string2 | from rule element |
public static boolean areStringEquals(String string1, String string2)
//package com.java2s; /**/* ww w . ja va 2s. c om*/ * Copyright (C) 2012 cogroo <cogroo@cogroo.org> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Checks if two strings are equals. * The strings can be both null, one of them null or none of them null. * * @param string1 from tree element * @param string2 from rule element * @return true if and only if the two strings are equal (both equal or both null) */ public static boolean areStringEquals(String string1, String string2) { /* string1 string2 outcome * null null true * null x false * x null false * x y false * x x true */ // XXX both null must be unequal? If yes, boolean must be too? if (string1 == null && string2 == null) { return false; } else if (string1 != null && !string1.equals(string2)) { return false; } else if (string2 != null && !string2.equals(string1)) { return false; } return true; } }