Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright 2013-2016 Guoqiang Chen, Shanghai, China. All rights reserved.
*
* Author: Guoqiang Chen
* Email: [email protected]
* WebURL: https://github.com/subchen
*
* 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 jetbrick.util.builder;
import java.util.Comparator;
public final class CompareToBuilder {
private int result = 0;
public CompareToBuilder append(Object lhs, Object rhs) {
return append(lhs, rhs, null);
}
public CompareToBuilder append(Object lhs, Object rhs, Comparator> comparator) {
if (result != 0) {
return this;
}
if (lhs == rhs) {
return this;
}
if (lhs == null) {
result = -1;
return this;
}
if (rhs == null) {
result = 1;
return this;
}
if (lhs.getClass().isArray()) {
if ((lhs instanceof long[])) {
append((long[]) lhs, (long[]) rhs);
} else if ((lhs instanceof int[])) {
append((int[]) lhs, (int[]) rhs);
} else if ((lhs instanceof short[])) {
append((short[]) lhs, (short[]) rhs);
} else if ((lhs instanceof char[])) {
append((char[]) lhs, (char[]) rhs);
} else if ((lhs instanceof byte[])) {
append((byte[]) lhs, (byte[]) rhs);
} else if ((lhs instanceof double[])) {
append((double[]) lhs, (double[]) rhs);
} else if ((lhs instanceof float[])) {
append((float[]) lhs, (float[]) rhs);
} else if ((lhs instanceof boolean[])) {
append((boolean[]) lhs, (boolean[]) rhs);
} else {
append((Object[]) lhs, (Object[]) rhs, comparator);
}
} else if (comparator == null) {
@SuppressWarnings("unchecked")
Comparable