MCPcopy
hub / github.com/apache/groovy / isVisibleProperty

Method isVisibleProperty

src/main/java/groovy/lang/MetaClassImpl.java:2352–2366  ·  view source on GitHub ↗
(final MetaProperty field, final MetaMethod method, final Class<?> sender)

Source from the content-addressed store, hash-verified

2350 }
2351
2352 private boolean isVisibleProperty(final MetaProperty field, final MetaMethod method, final Class<?> sender) {
2353 if (field == null
2354 || sender == null // GROOVY-11745
2355 || field.isPrivate()
2356 || !(field instanceof CachedField cachedField)) return false;
2357
2358 Class<?> owner = cachedField.getDeclaringClass();
2359 // ensure access originates within the type hierarchy of the field owner
2360 if (owner.equals(sender) || !owner.isAssignableFrom(sender)) return false;
2361
2362 if (!field.isPublic() && !field.isProtected() && !inSamePackage(owner, sender)) return false;
2363
2364 // GROOVY-8283: non-private field that hides class access method
2365 return !owner.isAssignableFrom(method.getDeclaringClass().getTheClass()) && !method.getDeclaringClass().isInterface();
2366 }
2367
2368 private Tuple2<MetaMethod, MetaProperty> createMetaMethodAndMetaProperty(final Class<?> sender, final String name, final boolean useSuper, final boolean isStatic) {
2369 MetaMethod mm = null;

Callers 3

getPropertyMethod · 0.95
setPropertyMethod · 0.95

Calls 9

inSamePackageMethod · 0.80
isPrivateMethod · 0.65
equalsMethod · 0.65
isPublicMethod · 0.65
isProtectedMethod · 0.65
getTheClassMethod · 0.65
isInterfaceMethod · 0.65
getDeclaringClassMethod · 0.45
isAssignableFromMethod · 0.45

Tested by

no test coverage detected