Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Optional;
import java.util.Spliterator;
Expand Down Expand Up @@ -48,12 +49,12 @@ public static EntityIntrospectionResult introspect(Class<?> entity) {
* @param entity a Java entity class to introspect
* @param propertyName the name of the property
* @return true if property has Transient annotation or transient field modifier
* @throws RuntimeException if property does not exists
* @throws NoSuchElementException if property does not exists
*/
public static boolean isTransient(Class<?> entity, String propertyName) {
return introspect(entity).getPropertyDescriptor(propertyName)
.map(AttributePropertyDescriptor::isTransient)
.orElseThrow(() -> new RuntimeException(new NoSuchFieldException(propertyName)));
.orElseThrow(() -> new NoSuchElementException(propertyName));
}

/**
Expand All @@ -62,9 +63,9 @@ public static boolean isTransient(Class<?> entity, String propertyName) {
* @param entity a Java entity class to introspect
* @param propertyName the name of the property
* @return true if property is persitent
* @throws RuntimeException if property does not exists
* @throws NoSuchElementException if property does not exists
*/
public static boolean isPesistent(Class<?> entity, String propertyName) {
public static boolean isPersistent(Class<?> entity, String propertyName) {
return !isTransient(entity, propertyName);
}

Expand All @@ -74,12 +75,12 @@ public static boolean isPesistent(Class<?> entity, String propertyName) {
* @param entity a Java entity class to introspect
* @param propertyName the name of the property
* @return true if property has GraphQLIgnore annotation
* @throws RuntimeException if property does not exists
* @throws NoSuchElementException if property does not exists
*/
public static boolean isIgnored(Class<?> entity, String propertyName) {
return introspect(entity).getPropertyDescriptor(propertyName)
.map(AttributePropertyDescriptor::isIgnored)
.orElseThrow(() -> new RuntimeException(new NoSuchFieldException(propertyName)));
.orElseThrow(() -> new NoSuchElementException(propertyName));
}

/**
Expand All @@ -88,7 +89,7 @@ public static boolean isIgnored(Class<?> entity, String propertyName) {
* @param entity a Java entity class to introspect
* @param propertyName the name of the property
* @return true if property has no GraphQLIgnore annotation
* @throws RuntimeException if property does not exists
* @throws NoSuchElementException if property does not exists
*/
public static boolean isNotIgnored(Class<?> entity, String propertyName) {
return !isIgnored(entity, propertyName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public void testIgnoreFields() {
" fieldMem" +
" fieldFun" +
" logic" +
" age" +
" customLogic" +
" hideField" +
" hideFieldFunction" +
Expand Down
Loading