MetaProperty metaProperty = super.getMetaProperty(propertyName); if (metaProperty instanceof MetaBeanProperty) { boolean staticProp = Modifier.isStatic(metaProperty.getModifiers()); if (isStatic==staticProp) { beanProperty = (MetaBeanProperty) metaProperty;
method = mbp.getSetter(); MetaProperty f = mbp.getField(); if (method != null || (f != null && !Modifier.isFinal(f.getModifiers()))) { arguments = new Object[]{newValue}; field = f; if (Modifier.isFinal(field.getModifiers())) { if(!(this.isMap && isPrivateOrPkgPrivate(field.getModifiers()))) { field.setProperty(object, newValue); return;
MetaPropertyClosureCaller(MetaProperty metaProperty) { this.metaProperty = metaProperty; if (Modifier.isStatic(metaProperty.getModifiers())) { cloneFirst = true; } }
MetaPropertyClosureCaller(MetaProperty metaProperty) { this.metaProperty = metaProperty; if (Modifier.isStatic(metaProperty.getModifiers())) { cloneFirst = true; } }
@Nullable @Override protected MetaProperty lookupProperty(MetaClass metaClass, String name) { MetaProperty metaProperty = super.lookupProperty(metaClass, name); if (metaProperty != null) { return metaProperty; } metaProperty = classMetaData.getMetaProperty(name); if (metaProperty != null && Modifier.isStatic(metaProperty.getModifiers())) { return metaProperty; } return null; }
public Class getPropertyType(String name, boolean onlyInstanceProperties) { MetaProperty metaProperty = theMetaClass.getMetaProperty(name); if(metaProperty != null) { boolean isStatic = Modifier.isStatic(metaProperty.getModifiers()); if(onlyInstanceProperties && isStatic) { return null; } else { return metaProperty.getType(); } } return null; }
public List<PropertyDescriptor> getPropertiesOfType(Class javaClass) { List<MetaProperty> properties = theMetaClass.getProperties(); List<PropertyDescriptor> propertyDescriptors = new ArrayList<>(2); for (MetaProperty property : properties) { int modifiers = property.getModifiers(); if(Modifier.isStatic(modifiers) || property.getName().contains("$") || !property.getType().equals(javaClass)) continue; addBeanProperty(propertyDescriptors, property); } return propertyDescriptors; }
@SuppressWarnings("unchecked") public List<PropertyDescriptor> getPropertiesAssignableFromType(Class assignableType) { List<MetaProperty> properties = theMetaClass.getProperties(); List<PropertyDescriptor> propertyDescriptors = new ArrayList<>(2); for (MetaProperty property : properties) { int modifiers = property.getModifiers(); if(Modifier.isStatic(modifiers) || property.getName().contains("$") || !property.getType().isAssignableFrom( assignableType )) continue; addBeanProperty(propertyDescriptors, property); } return propertyDescriptors; }
@SuppressWarnings("unchecked") public List<PropertyDescriptor> getPropertiesAssignableToType(Class assignableType) { List<MetaProperty> properties = theMetaClass.getProperties(); List<PropertyDescriptor> propertyDescriptors = new ArrayList<>(2); for (MetaProperty property : properties) { int modifiers = property.getModifiers(); if(Modifier.isStatic(modifiers) || property.getName().contains("$") || !assignableType.isAssignableFrom(property.getType())) { continue; } addBeanProperty(propertyDescriptors, property); } return propertyDescriptors; }
private static Object getStaticPropertyValue(MetaClass theMetaClass, String name) { MetaProperty metaProperty = theMetaClass.getMetaProperty(name); if(metaProperty != null && Modifier.isStatic(metaProperty.getModifiers())) { return metaProperty.getProperty(theMetaClass.getTheClass()); } return null; }
public String[] getIdentifierName() { if(idPropertiesArray != null) { return idPropertiesArray; } List<String> idProperties = new ArrayList<>(); ClassPropertyFetcher cpf = ClassPropertyFetcher.forClass(entity.getJavaClass()); for (MetaProperty metaProperty : cpf.getMetaProperties()) { int modifiers = metaProperty.getModifiers(); if(Modifier.isStatic(modifiers) || Modifier.isAbstract(modifiers)) { continue; } PropertyDescriptor pd = propertyFactory.createPropertyDescriptor(entity.getJavaClass(), metaProperty); if(pd != null) { if (hasAnnotation(cpf, pd, Id.class)) { idProperties.add(metaProperty.getName()); } else if (hasAnnotation(cpf, pd, EmbeddedId.class)) { idProperties.add(metaProperty.getName()); } } } if(idProperties.isEmpty()) { // default to just use 'id' idProperties.add(GormProperties.IDENTITY); } idPropertiesArray = idProperties.toArray(new String[idProperties.size()]); return idPropertiesArray; }
if(cachedClass.isInterface()) continue; MetaProperty metaProperty = current.getMetaClass().getMetaProperty(name); if(metaProperty != null && Modifier.isStatic(metaProperty.getModifiers())) { Class type = metaProperty.getType(); if(type == Object.class || c.isAssignableFrom(type)) {
if(Modifier.isStatic(metaProperty.getModifiers())) { continue;
this.metaProperties = new ArrayList<>(properties.size()); for (MetaProperty property : properties) { int modifiers = property.getModifiers(); String propertyName = property.getName(); if(!Modifier.isPublic(modifiers) || Modifier.isStatic(modifiers) || EXCLUDED_PROPERTIES.contains(propertyName)) {
int modifiers = property.getModifiers(); if(!Modifier.isStatic(modifiers)) { String propertyName = property.getName();
@Override public Map<FieldSignature, CompletionItem> getFields(CompletionContext context) { final Map<FieldSignature, CompletionItem> result = new HashMap<FieldSignature, CompletionItem>(); final Class clazz = loadClass(context.getTypeName()); if (clazz != null) { final MetaClass metaClass = GroovySystem.getMetaClassRegistry().getMetaClass(clazz); if (metaClass != null) { for (Object field : metaClass.getProperties()) { MetaProperty prop = (MetaProperty) field; if (prop.getName().startsWith(context.getPrefix())) { result.put(new FieldSignature(prop.getName()), new CompletionItem.FieldItem( prop.getType().getSimpleName(), prop.getName(), prop.getModifiers(), context.getAnchor())); } } } } return result; }
private static Object getInstancePropertyValue(Object instance, String name, MetaClass metaClass) { MetaProperty metaProperty = metaClass.getMetaProperty(name); if(metaProperty != null && !Modifier.isStatic(metaProperty.getModifiers())) { if(metaProperty instanceof MetaBeanProperty) { MetaBeanProperty beanProperty = (MetaBeanProperty) metaProperty; CachedField field = beanProperty.getField(); MetaMethod getter = beanProperty.getGetter(); Object result = getPropertyWithFieldOrGetter(instance, name, field, getter); if (result != null) return result; } else if(metaProperty instanceof MultipleSetterProperty) { MultipleSetterProperty msp = (MultipleSetterProperty) metaProperty; CachedField field = msp.getField(); MetaMethod getter = msp.getGetter(); Object result = getPropertyWithFieldOrGetter(instance, name, field, getter); if (result != null) return result; } else { return metaProperty.getProperty(instance); } } return null; }
method = mbp.getSetter(); MetaProperty f = mbp.getField(); if (method != null || (f != null && !Modifier.isFinal(f.getModifiers()))) { arguments = new Object[]{newValue}; field = f; if (Modifier.isFinal(field.getModifiers())) { throw new ReadOnlyPropertyException(name, theClass); if(!(this.isMap && isPrivateOrPkgPrivate(field.getModifiers()))) { field.setProperty(object, newValue); return;
method = mbp.getSetter(); MetaProperty f = mbp.getField(); if (method != null || (f != null && !Modifier.isFinal(f.getModifiers()))) { arguments = new Object[]{newValue}; field = f; if (Modifier.isFinal(field.getModifiers())) { throw new ReadOnlyPropertyException(name, theClass);
method = mbp.getSetter(); MetaProperty f = mbp.getField(); if (method != null || (f != null && !Modifier.isFinal(f.getModifiers()))) { arguments = new Object[]{newValue}; field = f; if (Modifier.isFinal(field.getModifiers())) { throw new ReadOnlyPropertyException(name, theClass);