public List<MetaProperty> getProperties() { return delegate.getProperties(); }
/** * Returns a string detailing possible solutions to a missing field or property * if no good solutions can be found a empty string is returned. * * @param fieldName the missing field * @param type the class on which the field is sought * @return a string with probable solutions to the exception */ public static String getPropertySuggestionString(String fieldName, Class type){ ClassInfo ci = ClassInfo.getClassInfo(type); List<MetaProperty> fi = ci.getMetaClass().getProperties(); List<RankableField> rf = new ArrayList<RankableField>(fi.size()); StringBuilder sb = new StringBuilder(); sb.append("\nPossible solutions: "); for(MetaProperty mp : fi) rf.add(new RankableField(fieldName, mp)); Collections.sort(rf); int i = 0; for (RankableField f : rf) { if (i > MAX_RECOMENDATIONS) break; if (f.score > MAX_FIELD_SCORE) break; if(i > 0) sb.append(", "); sb.append(f.f.getName()); i++; } return i > 0? sb.toString(): ""; }
/** * Retrieves the list of {@link groovy.lang.MetaProperty} objects for 'self' and wraps it * in a list of {@link groovy.lang.PropertyValue} objects that additionally provide * the value for each property of 'self'. * * @param self the receiver object * @return list of {@link groovy.lang.PropertyValue} objects * @see groovy.util.Expando#getMetaPropertyValues() * @since 1.0 */ public static List<PropertyValue> getMetaPropertyValues(Object self) { MetaClass metaClass = InvokerHelper.getMetaClass(self); List<MetaProperty> mps = metaClass.getProperties(); List<PropertyValue> props = new ArrayList<PropertyValue>(mps.size()); for (MetaProperty mp : mps) { props.add(new PropertyValue(self, mp)); } return props; }
public List<MetaProperty> getProperties() { final Object owner = getOwner(); final MetaClass ownerMetaClass = getOwnerMetaClass(owner); return ownerMetaClass.getProperties(); }
final List<MetaProperty> propList = metaClass.getProperties(); for (MetaProperty prop : propList) if (self.getMetaProperty(prop.getName()) == null) {
public void apply(Project project) { final LenskitExtension lenskit = project.getExtensions().create("lenskit", LenskitExtension.class, project); for (MetaProperty prop : DefaultGroovyMethods.getMetaClass(lenskit).getProperties()) { String prjProp = "lenskit." + prop.getName(); if (project.hasProperty(prjProp)) {
public List getProperties() { return adaptee.getProperties(); }
public List getProperties() { return delegate.getProperties(); } /* (non-Javadoc)
public List getProperties() { return delegate.getProperties(); } /* (non-Javadoc)
public List<MetaProperty> getProperties() { return delegate.getProperties(); }
public List<MetaProperty> getProperties() { return delegate.getProperties(); }
/** * Retrieves the list of {@link MetaProperty} objects for 'self' and wraps it * in a list of {@link PropertyValue} objects that additionally provide * the value for each property of 'self'. * * @param self the receiver object * @return list of {@link PropertyValue} objects * @see groovy.util.Expando#getMetaPropertyValues() * @since 1.0 */ public static List getMetaPropertyValues(Object self) { MetaClass metaClass = InvokerHelper.getMetaClass(self); List mps = metaClass.getProperties(); List props = new ArrayList(mps.size()); for (Iterator itr = mps.iterator(); itr.hasNext();) { MetaProperty mp = (MetaProperty) itr.next(); PropertyValue pv = new PropertyValue(self, mp); props.add(pv); } return props; }
@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; }
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; }
/** * Retrieves the list of {@link MetaProperty} objects for 'self' and wraps it * in a list of {@link PropertyValue} objects that additionally provide * the value for each property of 'self'. * * @param self the receiver object * @return list of {@link PropertyValue} objects * @see groovy.util.Expando#getMetaPropertyValues() * @since 1.0 */ public static List<PropertyValue> getMetaPropertyValues(Object self) { MetaClass metaClass = InvokerHelper.getMetaClass(self); List<MetaProperty> mps = metaClass.getProperties(); List<PropertyValue> props = new ArrayList<PropertyValue>(mps.size()); for (MetaProperty mp : mps) { props.add(new PropertyValue(self, mp)); } return props; }
public List<MetaProperty> getProperties() { final Object owner = getOwner(); final MetaClass ownerMetaClass = getOwnerMetaClass(owner); return ownerMetaClass.getProperties(); }
public List<MetaProperty> getProperties() { final Object owner = getOwner(); final MetaClass ownerMetaClass = getOwnerMetaClass(owner); return ownerMetaClass.getProperties(); }
public List getProperties() { final Object owner = getOwner(); final MetaClass ownerMetaClass = getOwnerMetaClass(owner); return ownerMetaClass.getProperties(); }
private void initGroovyCommands(final ScriptEngine scriptEngine, final ScriptContext scriptContext) { Commands commands = new Commands(scriptContext); for (MetaProperty mp : commands.getMetaClass().getProperties()) { String propertyType = mp.getType().getCanonicalName(); String propertyName = mp.getName(); if (propertyType.equals(groovy.lang.Closure.class.getCanonicalName())) { scriptEngine.put(propertyName, commands.getProperty(propertyName)); } } }