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:
Apache Commons Lang v3 Source Code Files
Apache Commons Lang 3 is the 3rd version of Apache Commons Lang, which provides a host of helper utilities for the java.lang API.
Apache Commons Lang 3 Source Code files are provided in both binary packge (commons-lang3-3.12.0-bin.zip) and source package (commons-lang3-3.12.0-src.zip). You can download them at Apache Commons Lang Website.
Apache Commons Lang 3 Source Code has no dependencies and is compatible with Java 8 and newer versions. You can compile it to generate your own version of Apache Commons Lang 3 JAR file.
You can also browse the source code below:
✍: FYIcenter
⏎ org/apache/commons/lang3/builder/ReflectionDiffBuilder.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.lang3.builder; import static org.apache.commons.lang3.reflect.FieldUtils.readField; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import org.apache.commons.lang3.ClassUtils; import org.apache.commons.lang3.reflect.FieldUtils; /** * <p> * Assists in implementing {@link Diffable#diff(Object)} methods. * </p> * <p> * All non-static, non-transient fields (including inherited fields) * of the objects to diff are discovered using reflection and compared * for differences. * </p> * * <p> * To use this class, write code as follows: * </p> * * <pre> * public class Person implements Diffable<Person> { * String name; * int age; * boolean smoker; * ... * * public DiffResult diff(Person obj) { * // No need for null check, as NullPointerException correct if obj is null * return new ReflectionDiffBuilder(this, obj, ToStringStyle.SHORT_PREFIX_STYLE) * .build(); * } * } * </pre> * * <p> * The {@code ToStringStyle} passed to the constructor is embedded in the * returned {@code DiffResult} and influences the style of the * {@code DiffResult.toString()} method. This style choice can be overridden by * calling {@link DiffResult#toString(ToStringStyle)}. * </p> * @param <T> * type of the left and right object to diff. * @see Diffable * @see Diff * @see DiffResult * @see ToStringStyle * @since 3.6 */ public class ReflectionDiffBuilder<T> implements Builder<DiffResult<T>> { private final Object left; private final Object right; private final DiffBuilder<T> diffBuilder; /** * <p> * Constructs a builder for the specified objects with the specified style. * </p> * * <p> * If {@code lhs == rhs} or {@code lhs.equals(rhs)} then the builder will * not evaluate any calls to {@code append(...)} and will return an empty * {@link DiffResult} when {@link #build()} is executed. * </p> * @param lhs * {@code this} object * @param rhs * the object to diff against * @param style * the style will use when outputting the objects, {@code null} * uses the default * @throws IllegalArgumentException * if {@code lhs} or {@code rhs} is {@code null} */ public ReflectionDiffBuilder(final T lhs, final T rhs, final ToStringStyle style) { this.left = lhs; this.right = rhs; diffBuilder = new DiffBuilder<>(lhs, rhs, style); } @Override public DiffResult<T> build() { if (left.equals(right)) { return diffBuilder.build(); } appendFields(left.getClass()); return diffBuilder.build(); } private void appendFields(final Class<?> clazz) { for (final Field field : FieldUtils.getAllFields(clazz)) { if (accept(field)) { try { diffBuilder.append(field.getName(), readField(field, left, true), readField(field, right, true)); } catch (final IllegalAccessException ex) { //this can't happen. Would get a Security exception instead //throw a runtime exception in case the impossible happens. throw new InternalError("Unexpected IllegalAccessException: " + ex.getMessage()); } } } } private boolean accept(final Field field) { if (field.getName().indexOf(ClassUtils.INNER_CLASS_SEPARATOR_CHAR) != -1) { return false; } if (Modifier.isTransient(field.getModifiers())) { return false; } return !Modifier.isStatic(field.getModifiers()); } }
⏎ org/apache/commons/lang3/builder/ReflectionDiffBuilder.java
Or download all of them as a single archive file:
File name: commons-lang3-3.12.0-sources.jar File size: 651724 bytes Release date: 2020-01-22 Download
⇒ Download and Install commons-lang3-3.8.1-bin.zip
⇐ Download Apache Commons Lang v3 Source Package
2022-10-19, 149605👍, 3💬
Popular Posts:
Commons Pool provides an Object-pooling API, with three major aspects: 1. A generic object pool inte...
What Is jtds-1.2.2.jar? jtds-1.2.2.jar is the JAR files of jTDS Java library 1.2.2, which is a JDBC ...
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java"....
How to download and install ojdbc7.jar for Oracle 12c R1? ojdbc8.jar for Oracle 12c R1 is a Java 7 a...
Old version of xml-apis.jar. JAR File Size and Download Location: File name: xmlParserAPIs.jar File ...