Skip to content

Commit

Permalink
Update ReflectionExtensions.java
Browse files Browse the repository at this point in the history
  • Loading branch information
tatjana19 committed Apr 4, 2019
1 parent 77a043d commit c7bd4dd
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,25 @@ public static List<String> getFieldNames(final @NonNull Class<?> cls)
.filter(ReflectionExtensions::isNotSynthetic)
.map(Field::getName)
.collect(Collectors.toList());
}

/**
* Gets all field names from the given class as an String list list minus the given ignored field names
*
* @param cls
* The class object to get the field names
* @param ignoreFieldNames
* a list with field names that shell be ignored
*
* @return Gets all field names from the given class as an String list minus the given ignored field names
*/
public static List<String> getFieldNames(final @NonNull Class<?> cls, List<String> ignoreFieldNames)
{
return Arrays.stream(cls.getDeclaredFields())
.filter(ReflectionExtensions::isNotSynthetic)
.map(Field::getName)
.filter(name -> !ignoreFieldNames.contains(name))
.collect(Collectors.toList());
}

/**
Expand Down

0 comments on commit c7bd4dd

Please sign in to comment.