2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.persistence
.fetch
;
11 import org
.apache
.logging
.log4j
.LogManager
;
12 import org
.apache
.logging
.log4j
.Logger
;
18 public class CdmFetch
{
19 private static final Logger logger
= LogManager
.getLogger();
21 public static CdmFetch
NO_FETCH() {return new CdmFetch(0);}
22 public static CdmFetch
FETCH_NOTHING() {return new CdmFetch(0);}
24 public static CdmFetch
FETCH_DESCRIPTIONS() {return new CdmFetch(1);}
25 public static CdmFetch
FETCH_CHILDTAXA() {return new CdmFetch(2);}
26 public static CdmFetch
FETCH_PARENT_TAXA() {return new CdmFetch(3);}
27 public static CdmFetch
FETCH_ANNOTATIONS_ALL() {return new CdmFetch(4);}
28 public static CdmFetch
FETCH_MARKER_ALL() {return new CdmFetch(5);}
29 public static CdmFetch
FETCH_SYNONYMS() {return new CdmFetch(6);}
31 protected int fetchSum
;
33 private CdmFetch(int fetchId
) {
34 this.fetchSum
= (int)Math
.pow(2, fetchId
);
37 public void add(CdmFetch cdmFetch
) {
38 this.fetchSum
= (this.fetchSum
| cdmFetch
.fetchSum
);
41 public boolean includes(CdmFetch cdmFetch
){
42 int andFetch
= cdmFetch
.fetchSum
& this.fetchSum
;
43 if (andFetch
== cdmFetch
.fetchSum
){
50 public static void main(String
[] args
) {
51 CdmFetch fetch1
= FETCH_DESCRIPTIONS();
52 CdmFetch fetch2
= FETCH_MARKER_ALL();
53 CdmFetch fetch3
= FETCH_SYNONYMS();
54 CdmFetch fetch4
= FETCH_DESCRIPTIONS();
57 logger
.warn(fetch3
.includes(fetch1
));
58 logger
.warn(fetch1
.includes(fetch2
));
59 logger
.warn(fetch2
.includes(fetch1
));
61 logger
.warn(fetch2
.includes(fetch1
));
63 logger
.warn(fetch1
.includes(fetch4
));