All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sfm.reflect.SetterHelper Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 1.10.3
Show newest version
package org.sfm.reflect;

import java.lang.reflect.Modifier;

public class SetterHelper {
	public static boolean methodModifiersMatches(final int modifiers) {
		return !Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers);
	}

	public static boolean methodNameMatchesProperty(final String name, final String property) {
		return (isSetter(name) && name.regionMatches(true, 3, property, 0, property.length())) 
				|| name.equalsIgnoreCase(property);
	}
	
	public static boolean fieldModifiersMatches(final int modifiers) {
		return !Modifier.isStatic(modifiers) &&  ! Modifier.isFinal(modifiers);
	}

	public static boolean fieldNameMatchesProperty(final String name, final String property) {
		return  name.equalsIgnoreCase(property);
	}
	
	public static String getPropertyNameFromMethodName(final String name) {
		return name.substring(3,4).toLowerCase() +  name.substring(4);
	}
	

	public static boolean isSetter(final String name) {
		return name.length() > 3 && name.startsWith("set");
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy