~slub.team/goobi-production/bug-1013622

« back to all changes in this revision

Viewing changes to src/de/unigoettingen/sub/commons/util/ArrayUtils.java

  • Committer: Ralf Claussnitzer
  • Date: 2012-05-29 10:55:34 UTC
  • mfrom: (66.1.1 integrate-util)
  • Revision ID: ralf.claussnitzer@slub-dresden.de-20120529105534-t5u5vxj9x5v2vifb
fixes lp:1005844 integrate sub-commons util library

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of the SUB Commons project.
 
3
 * Visit the websites for more information. 
 
4
 *              - http://gdz.sub.uni-goettingen.de 
 
5
 * 
 
6
 * Copyright 2009, Center for Retrospective Digitization, Göttingen (GDZ),
 
7
 * 
 
8
 * Licensed under the Apache License, Version 2.0 (the “License”);
 
9
 * you may not use this file except in compliance with the License.
 
10
 * You may obtain a copy of the License at
 
11
 * 
 
12
 *  http://www.apache.org/licenses/LICENSE-2.0
 
13
 * 
 
14
 * Unless required by applicable law or agreed to in writing, software
 
15
 * distributed under the License is distributed on an “AS IS” BASIS,
 
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
17
 * See the License for the specific language governing permissions and
 
18
 * limitations under the License.
 
19
 */
 
20
 
 
21
package de.unigoettingen.sub.commons.util;
 
22
 
 
23
 
 
24
/**
 
25
 * The Class ArrayUtils.
 
26
 */
 
27
public class ArrayUtils {
 
28
 
 
29
        /**
 
30
         * Checks if a array contains the given obeject
 
31
         * 
 
32
         * @param array the array to search
 
33
         * @param search the obeject to look after
 
34
         * 
 
35
         * @return true, if successful
 
36
         */
 
37
        public static boolean contains(Object[] array, Object search)  {
 
38
                if (array.getClass().isInstance(search)) {
 
39
                        throw new IllegalArgumentException();
 
40
                }
 
41
                for (Object o: array) {
 
42
                        if (o.equals(search)) {
 
43
                                return true;
 
44
                        }
 
45
                }
 
46
                return false;
 
47
        }
 
48
        
 
49
}