Skip to content

Method: static {...}

1: package cz.cvut.kbss.jopa.model.metamodel.gen;
2:
3: import cz.cvut.kbss.jopa.model.metamodel.AnnotatedAccessor;
4: import net.bytebuddy.description.method.MethodDescription;
5:
6: import java.beans.Introspector;
7: import java.util.Optional;
8:
9: /**
10: * Matches only persistent attribute setters.
11: * <p>
12: * This matcher checks that there exists a persistent field corresponding to the method name that appears to be a
13: * setter.
14: *
15: * @param <T> MethodDescription
16: */
17: public class PersistentPropertySetterMatcher<T extends MethodDescription> extends PersistentPropertyMatcher<T> {
18:
19: public PersistentPropertySetterMatcher(Class<?> parentType) {
20: super(parentType);
21: }
22:
23: @Override
24: protected Optional<String> resolveFieldName(String methodName, MethodDescription methodDesc) {
25: assert methodName.startsWith(AnnotatedAccessor.SET_PREFIX) && methodDesc.getParameters().size() == 1;
26:
27: return Optional.of(Introspector.decapitalize(methodName.substring(AnnotatedAccessor.SET_PREFIX.length())));
28: }
29: }