Java tutorial
/* * Copyright 2013 EK3 Technologies, Inc. * * 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 ei.ne.ke.cassandra.cql3.template; import org.apache.commons.lang.builder.HashCodeBuilder; import org.springframework.util.ObjectUtils; import com.google.common.base.Preconditions; /** * */ public class Ordering { private final Identifier ordering; private final Identifier direction; /** * * * @param ordering * @param direction */ public Ordering(Identifier ordering, Identifier direction) { this.ordering = Preconditions.checkNotNull(ordering); this.direction = direction; } /** * * * @param ordering * @param direction */ public Ordering(Identifier ordering) { this.ordering = Preconditions.checkNotNull(ordering); this.direction = null; } /** * {@inheritDoc} */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ordering); if (direction != null) { sb.append(" "); sb.append(direction); } return sb.toString(); } /** * {@inheritDoc} */ @Override public boolean equals(Object rhs) { if (this == rhs) { return true; } else if (!(rhs instanceof Ordering)) { return false; } else { Ordering that = (Ordering) rhs; return ObjectUtils.nullSafeEquals(this.ordering, that.ordering) && ObjectUtils.nullSafeEquals(this.direction, that.direction); } } /** * {@inheritDoc} */ @Override public int hashCode() { return HashCodeBuilder.reflectionHashCode(this); } /** * @return the ordering */ public Identifier getOrdering() { return ordering; } /** * @return the direction */ public Identifier getDirection() { return direction; } }