Java Code Examples for groovy.lang.MetaClass#getProperty()

The following examples show how to use groovy.lang.MetaClass#getProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GrailsHibernateUtil.java    From gorm-hibernate5 with Apache License 2.0 5 votes vote down vote up
/**
 * Increments the entities version number in order to force an update
 * @param target The target entity
 */
public static void incrementVersion(Object target) {
    MetaClass metaClass = GroovySystem.getMetaClassRegistry().getMetaClass(target.getClass());
    if (metaClass.hasProperty(target, GormProperties.VERSION)!=null) {
        Object version = metaClass.getProperty(target, GormProperties.VERSION);
        if (version instanceof Long) {
            Long newVersion = (Long) version + 1;
            metaClass.setProperty(target, GormProperties.VERSION, newVersion);
        }
    }
}
 
Example 2
Source File: ManagedConcurrentValueMapStressTest.java    From groovy with Apache License 2.0 4 votes vote down vote up
private static int size(ManagedConcurrentValueMap<String, Object> map) {
    MetaClass metaClass = InvokerHelper.getMetaClass(map);
    ConcurrentHashMap<String, Object> internalMap = (ConcurrentHashMap<String, Object>)metaClass.getProperty(map, "internalMap");
    return internalMap.size();
}
 
Example 3
Source File: OwnedMetaClass.java    From groovy with Apache License 2.0 4 votes vote down vote up
public Object getProperty(Object object, String property) {
    final Object owner = getOwner();
    final MetaClass ownerMetaClass = getOwnerMetaClass(owner);
    return ownerMetaClass.getProperty(owner, property);
}
 
Example 4
Source File: OwnedMetaClass.java    From groovy with Apache License 2.0 4 votes vote down vote up
public Object getProperty(Class sender, Object receiver, String messageName, boolean useSuper, boolean fromInsideClass) {
    final Object owner = getOwner();
    final MetaClass ownerMetaClass = getOwnerMetaClass(owner);
    return ownerMetaClass.getProperty(sender, receiver, messageName, useSuper, fromInsideClass);
}