Skip to content

Commit

Permalink
Add nameOf shortcut for classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jreznot committed Oct 11, 2017
1 parent 2a92c5c commit e152ea4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Java nameOfProperty implementation
==================================

Java alternative to nameOf operator.
Java alternative to [nameOf](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/nameof) operator.

[![license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)
[![Download](https://api.bintray.com/packages/strangeway-org/libs/nameof/images/download.svg) ](https://bintray.com/strangeway-org/libs/nameof/_latestVersion)
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/strangeway/nameof/LangUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
* Utility class that can provide name of bean property using method reference of a getter.
*/
public final class LangUtils {
public static String nameOf(Class clazz) {
return clazz.getName();
}

public static <T> String nameOfProperty(Class<T> clazz, Function<? super T, ?> bridge) {
T extractor = PropertyNames.getPropertyNameExtractor(clazz);
bridge.apply(extractor);
Expand Down

0 comments on commit e152ea4

Please sign in to comment.