aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/query/QueryHelper.java
blob: 7e6bd6d0dba2c136d261c56316dd0fbec8dbb67a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query;

/**
 * @author Arne Bergene Fossaa
 */
class QueryHelper {

    /** Compares two objects which may be null */
    public static boolean equals(Object a,Object b) {
        if (a == null) return b == null;
        return a.equals(b);
    }

    /**
     * Helper method that finds the hashcode for a group of objects.
     * Inspired by java.util.List
     */
    public static int combineHash(Object... objs) {
       int hash = 1;
       for (Object o:objs) {
           hash = 31*hash + (o == null ? 0 : o.hashCode());
       }
       return hash;
    }

}