Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
commons-collections4-4.2-sources.jar - Apache Commons Collections
commons-collections4-4.2-sources.jar is the source JAR file for Apache Commons Collections 4.2, which provides additional collection handling functionalities on top of JDK library.
JAR File Size and Download Location:
JAR name: commons-collections4-4.2-sources.jar Target JDK version: 1.7 Dependency: None File size: 708,599 bytes Release date: 08-Jul-2018 Download: Apache Commons Collections
✍: FYIcenter.com
⏎ org/apache/commons/collections4/comparators/ComparableComparator.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 org.apache.commons.collections4.comparators; import java.io.Serializable; import java.util.Comparator; /** * A {@link Comparator Comparator} that compares {@link Comparable Comparable} * objects. * <p> * This Comparator is useful, for example, for enforcing the natural order in * custom implementations of {@link java.util.SortedSet SortedSet} and * {@link java.util.SortedMap SortedMap}. * <p> * Note: In the 2.0 and 2.1 releases of Commons Collections, this class would * throw a {@link ClassCastException} if either of the arguments to * {@link #compare(Object, Object) compare} were <code>null</code>, not * {@link Comparable Comparable}, or for which * {@link Comparable#compareTo(Object) compareTo} gave inconsistent results. * This is no longer the case. See {@link #compare(Object, Object) compare} for * details. * * @param <E> the type of objects compared by this comparator * * @since 2.0 * @see java.util.Collections#reverseOrder() */ public class ComparableComparator<E extends Comparable<? super E>> implements Comparator<E>, Serializable { /** Serialization version. */ private static final long serialVersionUID=-291439688585137865L; /** The singleton instance. */ @SuppressWarnings("rawtypes") public static final ComparableComparator INSTANCE = new ComparableComparator(); //----------------------------------------------------------------------- /** * Gets the singleton instance of a ComparableComparator. * <p> * Developers are encouraged to use the comparator returned from this method * instead of constructing a new instance to reduce allocation and GC overhead * when multiple comparable comparators may be used in the same VM. * * @param <E> the element type * @return the singleton ComparableComparator * @since 4.0 */ @SuppressWarnings("unchecked") public static <E extends Comparable<? super E>> ComparableComparator<E> comparableComparator() { return INSTANCE; } //----------------------------------------------------------------------- /** * Constructor whose use should be avoided. * <p> * Please use the {@link #comparableComparator()} method whenever possible. */ public ComparableComparator() { super(); } //----------------------------------------------------------------------- /** * Compare the two {@link Comparable Comparable} arguments. * This method is equivalent to: * <pre>((Comparable)obj1).compareTo(obj2)</pre> * * @param obj1 the first object to compare * @param obj2 the second object to compare * @return negative if obj1 is less, positive if greater, zero if equal * @throws NullPointerException if <i>obj1</i> is <code>null</code>, * or when <code>((Comparable)obj1).compareTo(obj2)</code> does * @throws ClassCastException if <i>obj1</i> is not a <code>Comparable</code>, * or when <code>((Comparable)obj1).compareTo(obj2)</code> does */ @Override public int compare(final E obj1, final E obj2) { return obj1.compareTo(obj2); } //----------------------------------------------------------------------- /** * Implement a hash code for this comparator that is consistent with * {@link #equals(Object) equals}. * * @return a hash code for this comparator. * @since 3.0 */ @Override public int hashCode() { return "ComparableComparator".hashCode(); } /** * Returns {@code true} iff <i>that</i> Object is is a {@link Comparator Comparator} * whose ordering is known to be equivalent to mine. * <p> * This implementation returns {@code true} iff * <code><i>object</i>.{@link Object#getClass() getClass()}</code> equals * <code>this.getClass()</code>. Subclasses may want to override this behavior to remain * consistent with the {@link Comparator#equals(Object)} contract. * * @param object the object to compare with * @return {@code true} if equal * @since 3.0 */ @Override public boolean equals(final Object object) { return this == object || null != object && object.getClass().equals(this.getClass()); } }
⏎ org/apache/commons/collections4/comparators/ComparableComparator.java
Or download all of them as a single archive file:
File name: commons-collections4-4.2-sources.jar File size: 708599 bytes Release date: 2018-07-08 Download
⇒ Download and Install commons-collections4-4.1-bin.zip
⇐ What Is commons-collections4-4.2.jar
2023-03-28, 27544👍, 0💬
Popular Posts:
Where to find answers to frequently asked questions on Downloading and Installing Connector/J - JDBC...
How to download and install Apache XMLBeans-2.6.0.zip? If you want to try the XMLBeans Java library,...
JDK 11 jdk.jdi.jmod is the JMOD file for JDK 11 JDI (Java Debug Interface) tool. JDK 11 JDI tool com...
JRE 5 sunjce_provider.jar is the JAR file for JRE 5 Sun JCE Provider, which provides implementations...
commons-fileupload-1.3.3 -sources.jaris the source JAR file for Apache Commons FileUpload 1.3., whic...