Re: [lang] [LANG-1360] Add methods to ObjectUtils to get various forms of class names in a null-safe manner
On Sat, Oct 21, 2017 at 6:36 PM, Benedikt Ritterwrote: > > > > Am 21.10.2017 um 13:54 schrieb Allon Mureinik : > > > > Hi guys, > > > > This patch break the CI on GitHub (the checkstyle check). > > > > It's pretty straight forward to fix [1], and if someone could merge it to > > unblock the CI, that would be great. > > Done. > Many thanks! > > > > > > > TIA, > > Allon > > > > [1] https://github.com/apache/commons-lang/pull/302 > > > > On Sat, Oct 21, 2017 at 11:27 AM, Benedikt Ritter > > wrote: > > > >> Hello Gary, > >> > >>> Am 20.10.2017 um 21:19 schrieb ggreg...@apache.org: > >>> > >>> Repository: commons-lang > >>> Updated Branches: > >>> refs/heads/master 88654b79c -> 6ea2fc8d3 > >>> > >>> > >>> [LANG-1360] Add methods to ObjectUtils to get various forms of class > >>> names in a null-safe manner > >> > >> I think this belongs to ClassUtils. > >> > >> Regards, > >> Benedikt > >> > >>> > >>> Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo > >>> Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/ > >> 6ea2fc8d > >>> Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/ > 6ea2fc8d > >>> Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/ > 6ea2fc8d > >>> > >>> Branch: refs/heads/master > >>> Commit: 6ea2fc8d38e035bafaa92c7d3b007be38c2e9000 > >>> Parents: 88654b7 > >>> Author: Gary Gregory > >>> Authored: Fri Oct 20 13:19:56 2017 -0600 > >>> Committer: Gary Gregory > >>> Committed: Fri Oct 20 13:19:56 2017 -0600 > >>> > >>> -- > >>> src/changes/changes.xml | 1 + > >>> .../org/apache/commons/lang3/ObjectUtils.java | 32 > +++ > >>> .../apache/commons/lang3/ObjectUtilsTest.java | 33 > >> > >>> 3 files changed, 66 insertions(+) > >>> -- > >>> > >>> > >>> http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ > >> 6ea2fc8d/src/changes/changes.xml > >>> -- > >>> diff --git a/src/changes/changes.xml b/src/changes/changes.xml > >>> index cf4296e..66dd510 100644 > >>> --- a/src/changes/changes.xml > >>> +++ b/src/changes/changes.xml > >>> @@ -53,6 +53,7 @@ The type attribute can be > >> add,update,fix,remove. > >>>ConstructorUtils.invokeConstructor(Class, Object...) > >> regression > >>>EqualsBuilder#isRegistered: swappedPair construction > bug > >>> >> due-to="BruceKuiLiu">org.apache.commons.lang3.time.FastDateParser > should > >> use toUpperCase(Locale) > >>> +Add methods to ObjectUtils to get various forms of class names > in > >> a null-safe manner > >>> > >>> > >>> > >>> > >>> http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ > >> 6ea2fc8d/src/main/java/org/apache/commons/lang3/ObjectUtils.java > >>> -- > >>> diff --git a/src/main/java/org/apache/commons/lang3/ObjectUtils.java > >> b/src/main/java/org/apache/commons/lang3/ObjectUtils.java > >>> index 1ec0956..16a6b93 100644 > >>> --- a/src/main/java/org/apache/commons/lang3/ObjectUtils.java > >>> +++ b/src/main/java/org/apache/commons/lang3/ObjectUtils.java > >>> @@ -1033,4 +1033,36 @@ public class ObjectUtils { > >>>return v; > >>>} > >>> > >>> +/** > >>> + * Gets the class name of the given object. > >>> + * > >>> + * @param object the object to query, may be null > >>> + * @return the given object's class name or null if the object is > >> null > >>> + * @since 3.7 > >>> + */ > >>> +public static String getClassName(final Object object) { > >>> +return object == null ? null : object.getClass().getName(); > >>> +} > >>> + > >>> +/** > >>> + * Gets the class simple name of the given object. > >>> + * > >>> + * @param object the object to query, may be null > >>> + * @return the given object's class simple name or null if the > >> object is null > >>> + * @since 3.7 > >>> + */ > >>> +public static String getClassSimpleName(final Object object) { > >>> +return object == null ? null : object.getClass(). > >> getSimpleName(); > >>> +} > >>> + > >>> +/** > >>> + * Gets the class canonical name of the given object. > >>> + * > >>> + * @param object the object to query, may be null > >>> + * @return the given object's class canonical name or null if the > >> object is null > >>> + * @since 3.7 > >>> + */ > >>> +public static String getClassCanonicalName(final Object object) { > >>> +return object == null ? null : object.getClass(). > >> getCanonicalName(); > >>> +} > >>> } > >>> > >>> http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ > >>
Re: [lang] [LANG-1360] Add methods to ObjectUtils to get various forms of class names in a null-safe manner
> Am 21.10.2017 um 13:54 schrieb Allon Mureinik: > > Hi guys, > > This patch break the CI on GitHub (the checkstyle check). > > It's pretty straight forward to fix [1], and if someone could merge it to > unblock the CI, that would be great. Done. > > > TIA, > Allon > > [1] https://github.com/apache/commons-lang/pull/302 > > On Sat, Oct 21, 2017 at 11:27 AM, Benedikt Ritter > wrote: > >> Hello Gary, >> >>> Am 20.10.2017 um 21:19 schrieb ggreg...@apache.org: >>> >>> Repository: commons-lang >>> Updated Branches: >>> refs/heads/master 88654b79c -> 6ea2fc8d3 >>> >>> >>> [LANG-1360] Add methods to ObjectUtils to get various forms of class >>> names in a null-safe manner >> >> I think this belongs to ClassUtils. >> >> Regards, >> Benedikt >> >>> >>> Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo >>> Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/ >> 6ea2fc8d >>> Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/6ea2fc8d >>> Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/6ea2fc8d >>> >>> Branch: refs/heads/master >>> Commit: 6ea2fc8d38e035bafaa92c7d3b007be38c2e9000 >>> Parents: 88654b7 >>> Author: Gary Gregory >>> Authored: Fri Oct 20 13:19:56 2017 -0600 >>> Committer: Gary Gregory >>> Committed: Fri Oct 20 13:19:56 2017 -0600 >>> >>> -- >>> src/changes/changes.xml | 1 + >>> .../org/apache/commons/lang3/ObjectUtils.java | 32 +++ >>> .../apache/commons/lang3/ObjectUtilsTest.java | 33 >> >>> 3 files changed, 66 insertions(+) >>> -- >>> >>> >>> http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ >> 6ea2fc8d/src/changes/changes.xml >>> -- >>> diff --git a/src/changes/changes.xml b/src/changes/changes.xml >>> index cf4296e..66dd510 100644 >>> --- a/src/changes/changes.xml >>> +++ b/src/changes/changes.xml >>> @@ -53,6 +53,7 @@ The type attribute can be >> add,update,fix,remove. >>>ConstructorUtils.invokeConstructor(Class, Object...) >> regression >>>EqualsBuilder#isRegistered: swappedPair construction bug >>>> due-to="BruceKuiLiu">org.apache.commons.lang3.time.FastDateParser should >> use toUpperCase(Locale) >>> +Add methods to ObjectUtils to get various forms of class names in >> a null-safe manner >>> >>> >>> >>> >>> http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ >> 6ea2fc8d/src/main/java/org/apache/commons/lang3/ObjectUtils.java >>> -- >>> diff --git a/src/main/java/org/apache/commons/lang3/ObjectUtils.java >> b/src/main/java/org/apache/commons/lang3/ObjectUtils.java >>> index 1ec0956..16a6b93 100644 >>> --- a/src/main/java/org/apache/commons/lang3/ObjectUtils.java >>> +++ b/src/main/java/org/apache/commons/lang3/ObjectUtils.java >>> @@ -1033,4 +1033,36 @@ public class ObjectUtils { >>>return v; >>>} >>> >>> +/** >>> + * Gets the class name of the given object. >>> + * >>> + * @param object the object to query, may be null >>> + * @return the given object's class name or null if the object is >> null >>> + * @since 3.7 >>> + */ >>> +public static String getClassName(final Object object) { >>> +return object == null ? null : object.getClass().getName(); >>> +} >>> + >>> +/** >>> + * Gets the class simple name of the given object. >>> + * >>> + * @param object the object to query, may be null >>> + * @return the given object's class simple name or null if the >> object is null >>> + * @since 3.7 >>> + */ >>> +public static String getClassSimpleName(final Object object) { >>> +return object == null ? null : object.getClass(). >> getSimpleName(); >>> +} >>> + >>> +/** >>> + * Gets the class canonical name of the given object. >>> + * >>> + * @param object the object to query, may be null >>> + * @return the given object's class canonical name or null if the >> object is null >>> + * @since 3.7 >>> + */ >>> +public static String getClassCanonicalName(final Object object) { >>> +return object == null ? null : object.getClass(). >> getCanonicalName(); >>> +} >>> } >>> >>> http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ >> 6ea2fc8d/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java >>> -- >>> diff --git a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java >> b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java >>> index 3da8443..2bf036c 100644 >>> --- a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java >>> +++
Re: [lang] [LANG-1360] Add methods to ObjectUtils to get various forms of class names in a null-safe manner
Hi guys, This patch break the CI on GitHub (the checkstyle check). It's pretty straight forward to fix [1], and if someone could merge it to unblock the CI, that would be great. TIA, Allon [1] https://github.com/apache/commons-lang/pull/302 On Sat, Oct 21, 2017 at 11:27 AM, Benedikt Ritterwrote: > Hello Gary, > > > Am 20.10.2017 um 21:19 schrieb ggreg...@apache.org: > > > > Repository: commons-lang > > Updated Branches: > > refs/heads/master 88654b79c -> 6ea2fc8d3 > > > > > > [LANG-1360] Add methods to ObjectUtils to get various forms of class > > names in a null-safe manner > > I think this belongs to ClassUtils. > > Regards, > Benedikt > > > > > Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo > > Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/ > 6ea2fc8d > > Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/6ea2fc8d > > Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/6ea2fc8d > > > > Branch: refs/heads/master > > Commit: 6ea2fc8d38e035bafaa92c7d3b007be38c2e9000 > > Parents: 88654b7 > > Author: Gary Gregory > > Authored: Fri Oct 20 13:19:56 2017 -0600 > > Committer: Gary Gregory > > Committed: Fri Oct 20 13:19:56 2017 -0600 > > > > -- > > src/changes/changes.xml | 1 + > > .../org/apache/commons/lang3/ObjectUtils.java | 32 +++ > > .../apache/commons/lang3/ObjectUtilsTest.java | 33 > > > 3 files changed, 66 insertions(+) > > -- > > > > > > http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ > 6ea2fc8d/src/changes/changes.xml > > -- > > diff --git a/src/changes/changes.xml b/src/changes/changes.xml > > index cf4296e..66dd510 100644 > > --- a/src/changes/changes.xml > > +++ b/src/changes/changes.xml > > @@ -53,6 +53,7 @@ The type attribute can be > add,update,fix,remove. > > ConstructorUtils.invokeConstructor(Class, Object...) > regression > > EqualsBuilder#isRegistered: swappedPair construction bug > > due-to="BruceKuiLiu">org.apache.commons.lang3.time.FastDateParser should > use toUpperCase(Locale) > > +Add methods to ObjectUtils to get various forms of class names in > a null-safe manner > > > > > > > > > > http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ > 6ea2fc8d/src/main/java/org/apache/commons/lang3/ObjectUtils.java > > -- > > diff --git a/src/main/java/org/apache/commons/lang3/ObjectUtils.java > b/src/main/java/org/apache/commons/lang3/ObjectUtils.java > > index 1ec0956..16a6b93 100644 > > --- a/src/main/java/org/apache/commons/lang3/ObjectUtils.java > > +++ b/src/main/java/org/apache/commons/lang3/ObjectUtils.java > > @@ -1033,4 +1033,36 @@ public class ObjectUtils { > > return v; > > } > > > > +/** > > + * Gets the class name of the given object. > > + * > > + * @param object the object to query, may be null > > + * @return the given object's class name or null if the object is > null > > + * @since 3.7 > > + */ > > +public static String getClassName(final Object object) { > > +return object == null ? null : object.getClass().getName(); > > +} > > + > > +/** > > + * Gets the class simple name of the given object. > > + * > > + * @param object the object to query, may be null > > + * @return the given object's class simple name or null if the > object is null > > + * @since 3.7 > > + */ > > +public static String getClassSimpleName(final Object object) { > > +return object == null ? null : object.getClass(). > getSimpleName(); > > +} > > + > > +/** > > + * Gets the class canonical name of the given object. > > + * > > + * @param object the object to query, may be null > > + * @return the given object's class canonical name or null if the > object is null > > + * @since 3.7 > > + */ > > +public static String getClassCanonicalName(final Object object) { > > +return object == null ? null : object.getClass(). > getCanonicalName(); > > +} > > } > > > > http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ > 6ea2fc8d/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java > > -- > > diff --git a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java > b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java > > index 3da8443..2bf036c 100644 > > --- a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java > > +++ b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java > > @@ -38,6 +38,7 @@ import java.util.List; > > import
Re: [lang] [LANG-1360] Add methods to ObjectUtils to get various forms of class names in a null-safe manner
Hello Gary, > Am 20.10.2017 um 21:19 schrieb ggreg...@apache.org: > > Repository: commons-lang > Updated Branches: > refs/heads/master 88654b79c -> 6ea2fc8d3 > > > [LANG-1360] Add methods to ObjectUtils to get various forms of class > names in a null-safe manner I think this belongs to ClassUtils. Regards, Benedikt > > Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo > Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/6ea2fc8d > Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/6ea2fc8d > Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/6ea2fc8d > > Branch: refs/heads/master > Commit: 6ea2fc8d38e035bafaa92c7d3b007be38c2e9000 > Parents: 88654b7 > Author: Gary Gregory> Authored: Fri Oct 20 13:19:56 2017 -0600 > Committer: Gary Gregory > Committed: Fri Oct 20 13:19:56 2017 -0600 > > -- > src/changes/changes.xml | 1 + > .../org/apache/commons/lang3/ObjectUtils.java | 32 +++ > .../apache/commons/lang3/ObjectUtilsTest.java | 33 > 3 files changed, 66 insertions(+) > -- > > > http://git-wip-us.apache.org/repos/asf/commons-lang/blob/6ea2fc8d/src/changes/changes.xml > -- > diff --git a/src/changes/changes.xml b/src/changes/changes.xml > index cf4296e..66dd510 100644 > --- a/src/changes/changes.xml > +++ b/src/changes/changes.xml > @@ -53,6 +53,7 @@ The type attribute can be add,update,fix,remove. > ConstructorUtils.invokeConstructor(Class, Object...) regression > EqualsBuilder#isRegistered: swappedPair construction bug > due-to="BruceKuiLiu">org.apache.commons.lang3.time.FastDateParser should use > toUpperCase(Locale) > +Add methods to ObjectUtils to get various forms of class names in a > null-safe manner > > > > > http://git-wip-us.apache.org/repos/asf/commons-lang/blob/6ea2fc8d/src/main/java/org/apache/commons/lang3/ObjectUtils.java > -- > diff --git a/src/main/java/org/apache/commons/lang3/ObjectUtils.java > b/src/main/java/org/apache/commons/lang3/ObjectUtils.java > index 1ec0956..16a6b93 100644 > --- a/src/main/java/org/apache/commons/lang3/ObjectUtils.java > +++ b/src/main/java/org/apache/commons/lang3/ObjectUtils.java > @@ -1033,4 +1033,36 @@ public class ObjectUtils { > return v; > } > > +/** > + * Gets the class name of the given object. > + * > + * @param object the object to query, may be null > + * @return the given object's class name or null if the object is null > + * @since 3.7 > + */ > +public static String getClassName(final Object object) { > +return object == null ? null : object.getClass().getName(); > +} > + > +/** > + * Gets the class simple name of the given object. > + * > + * @param object the object to query, may be null > + * @return the given object's class simple name or null if the object is > null > + * @since 3.7 > + */ > +public static String getClassSimpleName(final Object object) { > +return object == null ? null : object.getClass().getSimpleName(); > +} > + > +/** > + * Gets the class canonical name of the given object. > + * > + * @param object the object to query, may be null > + * @return the given object's class canonical name or null if the object > is null > + * @since 3.7 > + */ > +public static String getClassCanonicalName(final Object object) { > +return object == null ? null : object.getClass().getCanonicalName(); > +} > } > > http://git-wip-us.apache.org/repos/asf/commons-lang/blob/6ea2fc8d/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java > -- > diff --git a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java > b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java > index 3da8443..2bf036c 100644 > --- a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java > +++ b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java > @@ -38,6 +38,7 @@ import java.util.List; > import org.apache.commons.lang3.exception.CloneFailedException; > import org.apache.commons.lang3.mutable.MutableObject; > import org.apache.commons.lang3.text.StrBuilder; > +import org.junit.Assert; > import org.junit.Test; > > /** > @@ -666,4 +667,36 @@ public class ObjectUtilsTest { > } > > } > + > +/** > + * @since 3.7 > + */ > +@Test > +public void testGetClassName() { > +Assert.assertNull(ObjectUtils.getClassName(null)); > +Assert.assertEquals("java.lang.String", ObjectUtils.getClassName(new > String())); > + >