Skip to content

Commit

Permalink
Merge branch 'release/1.12'
Browse files Browse the repository at this point in the history
Conflicts:
	README.md
  • Loading branch information
astrapi69 committed Jul 17, 2018
2 parents f93569e + 1cd9dbb commit a35193c
Show file tree
Hide file tree
Showing 69 changed files with 3,681 additions and 486 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
## Change log
----------------------

Version 1.12
-------------

ADDED:

- new deploy scripts for module projects jobject-diff and jobject-evaluate
- new checker classes for objects created with a declarative enum return type if a violation occurs

CHANGED:

- update of parent version to 4
- update of test-objects dependency version from 4.26 to 4.28
- update of vintage-time dependency version from 4.11.0 to 4.12
- remove of experimental lombok annotation ExtensionMethod
- unit tests extended for improve code coverage

Version 1.11
-------------

Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

The jobject-extensions project provides main operation that you can do with java objects.

When programming with java you have offen to clone or copy to compare or to diff and some times you have even merge objects. For some reasons you have to evaluate bean classes.
When programming with java you have offen to clone or copy to compare or to diff and some times you have even merge objects.
Thats exactly the functionality what this library provides.
There are several extension methods for the java core class Object. The feature extension methods can be provided over the lombok library.

## Key features:

1. very small size
2. extension methods for java core class Object for clone, compare, copy, diff, evaluate and merge
2. extension methods for java core class Object for clone, compare, copy, diff, check, evaluate and merge
3. modularizable, import only the functionality you need
4. simple to use

Expand Down Expand Up @@ -55,7 +55,7 @@ Than you can add the dependency to your dependencies:
<properties>
...
<!-- JOBJECT-EXTENSIONS versions -->
<jobject-extensions.version>1.11</jobject-extensions.version>
<jobject-extensions.version>1.12</jobject-extensions.version>
<jobject-clone.version>${jobject-extensions.version}</jobject-clone.version>
<jobject-compare.version>${jobject-extensions.version}</jobject-compare.version>
<jobject-copy.version>${jobject-extensions.version}</jobject-copy.version>
Expand Down Expand Up @@ -223,7 +223,17 @@ Release version numbers will be incremented in the following format:

`<major>.<minor>.<patch>`

For detailed information on versioning you can visit the [wiki page](https://github.com/lightblueseas/mvn-parent-projects/wiki/Semantic-Versioning).
The only exception from the official guidelines are the following:

If the minor and patch version ends with a zero then the minor and the patch can be omitted.

For instance if the project version is '1.0.0' we will write '1'. So we omit the '.0.0'.

The same applies if only the patch version ends with a zero then the patch can be omitted.

For instance if the project version is '1.1.0' we will write '1.1'. So we omit the '.0'.

For more information on SemVer you can visit [semver.org](http://semver.org/).

## Want to Help and improve it? ###

Expand Down
2 changes: 1 addition & 1 deletion jobject-clone/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>de.alpharogroup</groupId>
<artifactId>jobject-extensions</artifactId>
<version>1.11</version>
<version>1.12</version>
</parent>

<artifactId>jobject-clone</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@

import de.alpharogroup.date.CreateDateExtensions;
import de.alpharogroup.test.objects.A;
import lombok.experimental.ExtensionMethod;

/**
* The unit test class for the class {@link CloneObjectExtensions}.
*/
@ExtensionMethod(CloneObjectExtensions.class)
public class CloneObjectExtensionsTest
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@
import de.alpharogroup.date.CreateDateExtensions;
import de.alpharogroup.test.objects.A;
import de.alpharogroup.test.objects.NotSerializable;
import lombok.experimental.ExtensionMethod;

/**
* The unit test class for the class {@link CloneObjectQuietlyExtensions}.
*/
@ExtensionMethod(CloneObjectQuietlyExtensions.class)
public class CloneObjectQuietlyExtensionsTest
{

Expand Down
2 changes: 1 addition & 1 deletion jobject-compare/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>de.alpharogroup</groupId>
<artifactId>jobject-extensions</artifactId>
<version>1.11</version>
<version>1.12</version>
</parent>

<artifactId>jobject-compare</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.Comparator;

import lombok.Builder;
import lombok.EqualsAndHashCode;

/**
* The class {@link NullCheckComparator} decorates another {@link Comparator} object to compare null
Expand All @@ -35,7 +34,6 @@
* @param <T>
* the generic type of the {@link Comparator} object that will be decorated
*/
@EqualsAndHashCode
@Builder
public class NullCheckComparator<T> implements Comparator<T>, Serializable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;

import de.alpharogroup.comparators.ComparatorExtensions;
import lombok.experimental.UtilityClass;
Expand All @@ -39,9 +38,6 @@
public final class CompareObjectExtensions
{

/** The logger constant. */
private static final Logger LOG = Logger.getLogger(CompareObjectExtensions.class.getName());

/**
* Compares the given two objects.
*
Expand Down Expand Up @@ -163,59 +159,6 @@ public static int compareTo(final Object sourceOjbect, final Object objectToComp
return new BeanComparator(property).compare(sourceOjbect, objectToCompare);
}

/**
* Compares the given object over the given property quietly.
*
* @param sourceOjbect
* the source ojbect
* @param objectToCompare
* the object to compare
* @param property
* the property
* @return the int
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static int compareToQuietly(final Object sourceOjbect, final Object objectToCompare,
final String property)
{
Map<?, ?> beanDescription = null;
try
{
beanDescription = BeanUtils.describe(sourceOjbect);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e)
{
LOG.error("BeanUtils.describe(sourceOjbect) throws an exception...", e);
return 0;
}
Map<?, ?> clonedBeanDescription = null;
try
{
clonedBeanDescription = BeanUtils.describe(objectToCompare);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e)
{
LOG.error("BeanUtils.describe(objectToCompare) throws an exception...", e);
return 0;
}
final Object sourceAttribute = beanDescription.get(property);
final Object changedAttribute = clonedBeanDescription.get(property);
if (sourceAttribute == null && changedAttribute == null)
{
return 0;
}
if (sourceAttribute != null && changedAttribute == null)
{
return 1;
}
else if (sourceAttribute == null && changedAttribute != null)
{
return -1;
}
return new BeanComparator(property).compare(sourceOjbect, objectToCompare);
}


/**
* Gets the compare to result.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* The MIT License
*
* Copyright (C) 2015 Asterios Raptis
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package de.alpharogroup.compare.object;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;

import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.beanutils.BeanUtils;

import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;

/**
* The class {@link CompareObjectQuietlyExtensions} provide methods for compare an object with
* another given object.
*/
@UtilityClass
@Slf4j
public final class CompareObjectQuietlyExtensions
{

/**
* Compares the given object over the given property quietly.
*
* @param sourceOjbect
* the source ojbect
* @param objectToCompare
* the object to compare
* @param property
* the property
* @return the int
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static int compareToQuietly(final Object sourceOjbect, final Object objectToCompare,
final String property)
{
Map<?, ?> beanDescription = null;
try
{
beanDescription = BeanUtils.describe(sourceOjbect);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e)
{
log.error("BeanUtils.describe(sourceOjbect) throws an exception...", e);
return 0;
}
Map<?, ?> clonedBeanDescription = null;
try
{
clonedBeanDescription = BeanUtils.describe(objectToCompare);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e)
{
log.error("BeanUtils.describe(objectToCompare) throws an exception...", e);
return 0;
}
final Object sourceAttribute = beanDescription.get(property);
final Object changedAttribute = clonedBeanDescription.get(property);
if (sourceAttribute == null && changedAttribute == null)
{
return 0;
}
if (sourceAttribute != null && changedAttribute == null)
{
return 1;
}
else if (sourceAttribute == null && changedAttribute != null)
{
return -1;
}
return new BeanComparator(property).compare(sourceOjbect, objectToCompare);
}

}
Loading

0 comments on commit a35193c

Please sign in to comment.