From 916a581768463cc48d423136c25dcc454e00faf3 Mon Sep 17 00:00:00 2001 From: "J. Neugebauer" Date: Tue, 26 Jul 2022 18:14:59 +0200 Subject: [PATCH] Refactorings --- src/main/java/schule/ngb/zm/anim/Animations.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/schule/ngb/zm/anim/Animations.java b/src/main/java/schule/ngb/zm/anim/Animations.java index 533e129..b5b37e8 100644 --- a/src/main/java/schule/ngb/zm/anim/Animations.java +++ b/src/main/java/schule/ngb/zm/anim/Animations.java @@ -14,7 +14,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.function.*; -@SuppressWarnings( "unchecked" ) +@SuppressWarnings( "unused" ) public class Animations { public static final Future animateProperty( String propName, T target, double to, int runtime, DoubleUnaryOperator easing ) { @@ -92,27 +92,28 @@ public class Animations { }); } - private static final R callGetter( T target, String propName, Class propType ) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + @SuppressWarnings( "unchecked" ) + private static R callGetter( T target, String propName, Class propType ) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { String getterName = makeMethodName("get", propName); Method getter = target.getClass().getMethod(getterName); - if( getter != null && getter.getReturnType().equals(propType) ) { + if( getter.getReturnType().equals(propType) ) { return (R) getter.invoke(target); } else { throw new NoSuchMethodException(String.format("No getter for property <%s> found.", propName)); } } - private static final Method findSetter( T target, String propName, Class propType ) throws NoSuchMethodException { + private static Method findSetter( T target, String propName, Class propType ) throws NoSuchMethodException { String setterName = makeMethodName("set", propName); Method setter = target.getClass().getMethod(setterName, propType); - if( setter != null && setter.getReturnType().equals(void.class) && setter.getParameterCount() == 1 ) { + if( setter.getReturnType().equals(void.class) && setter.getParameterCount() == 1 ) { return setter; } else { throw new NoSuchMethodException(String.format("No setter for property <%s> found.", propName)); } } - private static final String makeMethodName( String prefix, String propName ) { + private static String makeMethodName( String prefix, String propName ) { String firstChar = propName.substring(0, 1).toUpperCase(); String tail = ""; if( propName.length() > 1 ) {