Rewrite our build as modular maven components
This refactoring splits the code up into different components, with their own per-component CLASSPATH. By moving all of our classes into isolated components we can better isolate the classpaths and try to avoid unexpected dependency problems. It also allows us to more clearly define which components are used by the GWT UI and thus must be compiled under GWT, and which components are run on the server and can therefore use more of the J2SE API. Change-Id: I833cc22bacc5655d1c9099ed7c2b0e0a5b08855a Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// 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.
|
||||
|
||||
package com.google.gerrit.server.query;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An abstract predicate tree for any form of query.
|
||||
* <p>
|
||||
* Implementations should be immutable, and therefore also be thread-safe. They
|
||||
* also should ensure their immutable promise by defensively copying any
|
||||
* structures which might be modified externally, but were passed into the
|
||||
* object's constructor.
|
||||
* <p>
|
||||
* Predicates should support deep inspection whenever possible, so that generic
|
||||
* algorithms can be written to operate against them. Predicates which contain
|
||||
* other predicates should override {@link #getChildren()} to return the list of
|
||||
* children nested within the predicate.
|
||||
*/
|
||||
public abstract class Predicate {
|
||||
/** Combine the passed predicates into a single AND node. */
|
||||
public static Predicate and(final Predicate... that) {
|
||||
return new AndPredicate(that);
|
||||
}
|
||||
|
||||
/** Combine the passed predicates into a single AND node. */
|
||||
public static Predicate and(final Collection<Predicate> that) {
|
||||
return new AndPredicate(that);
|
||||
}
|
||||
|
||||
/** Combine the passed predicates into a single OR node. */
|
||||
public static Predicate or(final Predicate... that) {
|
||||
return new OrPredicate(that);
|
||||
}
|
||||
|
||||
/** Combine the passed predicates into a single OR node. */
|
||||
public static Predicate or(final Collection<Predicate> that) {
|
||||
return new OrPredicate(that);
|
||||
}
|
||||
|
||||
/** Invert the passed node; same as {@code that.not()}. */
|
||||
public static Predicate not(final Predicate that) {
|
||||
return that.not();
|
||||
}
|
||||
|
||||
/** Get the children of this predicate, if any. */
|
||||
public List<Predicate> getChildren() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/** Same as {@code getChildren().size()} */
|
||||
public int getChildCount() {
|
||||
return getChildren().size();
|
||||
}
|
||||
|
||||
/** Same as {@code getChildren().get(i)} */
|
||||
public Predicate getChild(final int i) {
|
||||
return getChildren().get(i);
|
||||
}
|
||||
|
||||
/** Obtain the inverse of this predicate. */
|
||||
public Predicate not() {
|
||||
return new NotPredicate(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract int hashCode();
|
||||
|
||||
@Override
|
||||
public abstract boolean equals(Object other);
|
||||
}
|
Reference in New Issue
Block a user